1. This assumes you already have Java 7+ already up and running:
java -version
2. Download latest Apache Maven package from https://maven.apache.org/download.cgi
and move it to /usr/local folder.
Alternatively you can download directly on your linux instance using wget:
wget http://www-eu.apache.org/dist/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz
3. Untar the zip:
sudo tar xzf apache-maven-3.5.2-bin.tar.gz
4. It is by default extracted to an apache-maven-3.5.2 folder. For ease, can create a symbolic link for maven:
ln -s apache-maven-3.5.2 maven
5. Get proper path in place:
export PATH=/usr/local/maven/bin:${PATH}
6. Test by checking maven installed version:
mvn -version
7. To make it work, it also needs a settings.xml file. This file needs to be under /home/user/.m2 folder and can have following sections:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>/user/local/.m2/repository</localRepository><interactiveMode>true</interactiveMode>
<usePluginRegistry>false</usePluginRegistry>
<offline>false</offline>
<pluginGroups>
</pluginGroups>
<servers/>
<mirrors/>
<proxies/>
<profiles/>
<activeProfiles/>
</settings>
8. If you have an already existing project, you can test from within project folder the following command - it shall build succesfully and download any dependency to the repository:
mvn clean install -s /home/user/.m2/settings.xml
No comments:
Post a Comment