Maven configuration (also under proxies)
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
What is Maven?
Maven is a project management and comprehension tool. Maven provides developers a complete build lifecycle framework. Development team can automate the project's build infrastructure in almost no time as Maven uses a standard directory layout and a default build lifecycle.
In case of multiple development teams environment, Maven can set-up the way to work as per standards in a very short time. As most of the project setups are simple and reusable, Maven makes life of developer easy while creating reports, checks, build and testing automation setups.
Maven provides developers ways to manage following:
- Builds
- Documentation
- Reporting
- Dependencies
- SCMs
- Releases
- Distribution
- mailing list
To summarize, Maven simplifies and standardizes the project build process. It handles compilation, distribution, documentation, team collaboration and other tasks seamlessly. Maven increases reusability and takes care of most of build related tasks.
Step 1 - verify Java installation on your machine
Now open console and execute the following java command.
OS | Task | Command |
---|---|---|
Windows | Open Command Console | c:\> java -version |
Linux | Open Command Terminal | $ java -version |
Mac | Open Terminal | machine:~ joseph$ java -version |
Let's verify the output for all the operating systems:
OS | Output |
---|---|
Windows | java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)
|
Linux | java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)
|
Mac | java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM)64-Bit Server VM (build 17.0-b17, mixed mode, sharing)
|
If you do not have Java installed, install the Java Software Development Kit (SDK) fromhttp://www.oracle.com/technetwork/java/javase/downloads/index.html. We are assuming Java 1.6.0_21 as installed version for this tutorial.
Step 2: Set JAVA environment
Set the JAVA_HOME environment variable to point to the base directory location where Java is installed on your machine. For example
OS | Output |
---|---|
Windows | Set the environment variable JAVA_HOME to C:\Program Files\Java\jdk1.6.0_21 |
Linux | export JAVA_HOME=/usr/local/java-current |
Mac | export JAVA_HOME=/Library/Java/Home |
Append Java compiler location to System Path.
OS | Output |
---|---|
Windows | Append the string ;C:\Program Files\Java\jdk1.6.0_21\bin to the end of the system variable, Path. |
Linux | export PATH=$PATH:$JAVA_HOME/bin/ |
Mac | not required |
Verify Java Installation using java -version command explained above.
Step 3: Download Maven archive
Download Maven 2.2.1 from http://maven.apache.org/download.html
OS | Archive name |
---|---|
Windows | apache-maven-2.0.11-bin.zip |
Linux | apache-maven-2.0.11-bin.tar.gz |
Mac | apache-maven-2.0.11-bin.tar.gz |
Step 4: Extract the Maven archive
Extract the archive, to the directory you wish to install Maven 2.2.1. The subdirectory apache-maven-2.2.1 will be created from the archive.
OS | Location (can be different based on your installation) |
---|---|
Windows | C:\Program Files\Apache Software Foundation\apache-maven-2.2.1 |
Linux | /usr/local/apache-maven |
Mac | /usr/local/apache-maven |
Step 5: Set Maven environment variables
Add M2_HOME, M2, MAVEN_OPTS to environment variables.
OS | Output |
---|---|
Windows | Set the environment variables using system properties.
M2_HOME=C:\Program Files\Apache Software Foundation\apache-maven-2.2.1
M2=%M2_HOME%\bin
MAVEN_OPTS=-Xms256m -Xmx512m
|
Linux | Open command terminal and set environment variables.
export M2_HOME=/usr/local/apache-maven/apache-maven-2.2.1
export M2=$M2_HOME/bin
export MAVEN_OPTS=-Xms256m -Xmx512m
|
Mac | Open command terminal and set environment variables.
export M2_HOME=/usr/local/apache-maven/apache-maven-2.2.1
export M2=$M2_HOME/bin
export MAVEN_OPTS=-Xms256m -Xmx512m
|
Step 6: Add Maven bin directory location to system path
Now append M2 variable to System Path
OS | Output |
---|---|
Windows | Append the string ;%M2% to the end of the system variable, Path. |
Linux | export PATH=$M2:$PATH |
Mac | export PATH=$M2:$PATH |
Step 8: Verify Maven installation
Now open console, execute the following mvn command.
OS | Task | Command |
---|---|---|
Windows | Open Command Console | c:\> mvn --version |
Linux | Open Command Terminal | $ mvn --version |
Mac | Open Terminal | machine:~ joseph$ mvn --version |
Finally, verify the output of the above commands, which should be something as follows:
OS | Output |
---|---|
Windows | Apache Maven 2.2.1 (r801777; 2009-08-07 00:46:01+0530)
Java version: 1.6.0_21
Java home: C:\Program Files\Java\jdk1.6.0_21\jre
|
Linux | Apache Maven 2.2.1 (r801777; 2009-08-07 00:46:01+0530)
Java version: 1.6.0_21
Java home: C:\Program Files\Java\jdk1.6.0_21\jre
|
Mac | Apache Maven 2.2.1 (r801777; 2009-08-07 00:46:01+0530)
Java version: 1.6.0_21
Java home: C:\Program Files\Java\jdk1.6.0_21\jre
|
Find
{M2_HOME}/conf/settings.xml
, and put your proxies detail inside.
example:
<proxies>
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username>121071050</username>
<password>121071050</password>
<host>172.18.61.11</host>
<port>3128</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>
save and run!!!!!!
You are good to go :)
Following is the complete build
ls/1.5.7/plexus-utils-1.5.7.jar
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugin-tools/m
aven-plugin-tools-api/2.4.3/maven-plugin-tools-api-2.4.3.jar (51 KB at 6.3 KB/se
c)
Downloading: https://repo.maven.apache.org/maven2/jdom/jdom/1.0/jdom-1.0.jar
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-inte
ractivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar (14 KB at 1.6
KB/sec)
Downloading: https://repo.maven.apache.org/maven2/com/thoughtworks/xstream/xstre
am/1.4.3/xstream-1.4.3.jar
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-cont
ainer-default/1.0-alpha-9/plexus-container-default-1.0-alpha-9.jar (191 KB at 23
.2 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/xmlpull/xmlpull/1.1.3.1/xmlpul
l-1.1.3.1.jar
Downloaded: https://repo.maven.apache.org/maven2/junit/junit/3.8.1/junit-3.8.1.j
ar (119 KB at 14.4 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/xpp3/xpp3_min/1.1.4c/xpp3_min-
1.1.4c.jar
Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-util
s/1.5.7/plexus-utils-1.5.7.jar (260 KB at 29.7 KB/sec)
Downloading: https://repo.maven.apache.org/maven2/commons-lang/commons-lang/2.4/
commons-lang-2.4.jar
Downloaded: https://repo.maven.apache.org/maven2/xmlpull/xmlpull/1.1.3.1/xmlpull
-1.1.3.1.jar (8 KB at 0.8 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/xpp3/xpp3_min/1.1.4c/xpp3_min-1
.1.4c.jar (25 KB at 2.7 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/jdom/jdom/1.0/jdom-1.0.jar (150
KB at 16.2 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/commons-lang/commons-lang/2.4/c
ommons-lang-2.4.jar (256 KB at 25.8 KB/sec)
Downloaded: https://repo.maven.apache.org/maven2/com/thoughtworks/xstream/xstrea
m/1.4.3/xstream-1.4.3.jar (471 KB at 46.3 KB/sec)
[INFO]
Effective POMs, after inheritance, interpolation, and profiles are applied:
<!-- ====================================================================== -->
<!-- -->
<!-- Generated by Maven Help Plugin on 2015-09-11T01:26:27 -->
<!-- See: http://maven.apache.org/plugins/maven-help-plugin/ -->
<!-- -->
<!-- ====================================================================== -->
<!-- ====================================================================== -->
<!-- -->
<!-- Effective POM for project -->
<!-- 'com.companyname.project-group:project:jar:1.0' -->
<!-- -->
<!-- ====================================================================== -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/
2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 h
ttp://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.companyname.project-group</groupId>
<artifactId>project</artifactId>
<version>1.0</version>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>C:\Program Files\Maven\apache-maven-3.3.3\Project\src\main\
java</sourceDirectory>
<scriptSourceDirectory>C:\Program Files\Maven\apache-maven-3.3.3\Project\src
\main\scripts</scriptSourceDirectory>
<testSourceDirectory>C:\Program Files\Maven\apache-maven-3.3.3\Project\src\t
est\java</testSourceDirectory>
<outputDirectory>C:\Program Files\Maven\apache-maven-3.3.3\Project\target\cl
asses</outputDirectory>
<testOutputDirectory>C:\Program Files\Maven\apache-maven-3.3.3\Project\targe
t\test-classes</testOutputDirectory>
<resources>
<resource>
<directory>C:\Program Files\Maven\apache-maven-3.3.3\Project\src\main\re
sources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>C:\Program Files\Maven\apache-maven-3.3.3\Project\src\test\re
sources</directory>
</testResource>
</testResources>
<directory>C:\Program Files\Maven\apache-maven-3.3.3\Project\target</directo
ry>
<finalName>project-1.0</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>default-resources</id>
<phase>process-resources</phase>
<goals>
<goal>resources</goal>
</goals>
</execution>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
<execution>
<id>default-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>C:\Program Files\Maven\apache-maven-3.3.3\Project
\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
<execution>
<id>default-deploy</id>
<phase>site-deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<outputDirectory>C:\Program Files\Maven\apache-maven-3.3.3\Project
\target\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
</executions>
<configuration>
<outputDirectory>C:\Program Files\Maven\apache-maven-3.3.3\Project\tar
get\site</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>C:\Program Files\Maven\apache-maven-3.3.3\Project\target\si
te</outputDirectory>
</reporting>
</project>
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:55 min
[INFO] Finished at: 2015-09-11T01:26:28+05:30
[INFO] Final Memory: 12M/247M
[INFO] ------------------------------------------------------------------------
C:\Program Files\Maven\apache-maven-3.3.3\Project>
No comments:
Post a Comment