Sunday, June 10, 2012

Apache Maven Installation and Maven Configuration

Maven : Apache Maven is a basically used for managing project's build, reporting and documentation. Maven is based on model which is called POM(Project Object Model).

Installation :

1. Download Maven from eg.version Maven 3.0.4
2. unzip into any Directory. ex. C:\Program Files\apache-maven-3.0.4(Windows) or /usr/local/apache-maven/apache-maven-3.0.4(Unix)
3. Add Environment variable M2_HOME = <Installation dir without bin directory> or export M2_HOME = <path of installed without bin>
4. append %M2_HOME%\bin into PATH Environment
Unix : export M2=$M2_HOME/bin and export PATH=$M2:$PATH
6. Optional – add the environment variable MAVEN_OPTS to specify JVM properties, e.g.
Windows : MAVEN_OPTS = -Xms256m -Xmx512m
Unix : export MAVEN_OPTS=”-Xms256m -Xmx512m”
5. goto cmd and check Maven as : mvn -version

Configuring Maven :
Maven will run with sensible defaults, so you can get right into it. However, if you are operating under a restricted environment or
behind a firewall, you might need to prepare to run Maven, as it requires write access to the home directory (~/.m2 on Unix/Mac OS X
and C:\Documents and Settings\username\.m2 on Windows) and network access to download binary dependencies.

Building Project :
The vast majority of Maven-built projects can be built with the following command:

mvn clean install

This command tells Maven to build all the modules, and to install it in the local repository.

Configuring your Local Repository :
The location of your local repository can be changed in your user configuration. The default value is ${user.home}/.m2/repository/.



Configuring Parallel Artifact Resolution :

By default, Maven 2.1.0+ will download up to 5 artifacts (from different groups) at once. To change the size of the thread pool,
start Maven using -Dmaven.artifact.threads. For example, to only download single artifacts at a time:
mvn -Dmaven.artifact.threads=1 clean install
You may wish to set this option permanently, in which case you can use the MAVEN_OPTS environment variable. For example:
export MAVEN_OPTS=-Dmaven.artifact.threads=3

Security and Deployment Settings
Repositories to deploy to are defined in a project in the <distributionManagement> section. However, you cannot put your username, password, or other security settings in that project. For that reason, you should add a server definition to your own settings with an id that matches that of the deployment repository in the project.

In addition, some repositories may require authorization to download from, so the corresponding settings can be specified in a server element in the same way.

Which settings are required will depend on the type of repository you are deploying to. As of the first release, only SCP deployments and file deployments are supported by default, so only the following SCP configuration is needed:


<!– other optional elements:
<privateKey>/path/to/identity</privateKey> (default is ~/.ssh/id_dsa)



Links :

No comments:

Post a Comment