Thursday, January 26, 2012

Maven3: Working in Offline Mode

Maven provides the option of running the command offline. If you have have the packages JAR/WAR/EAR available on local repository, then you can run the command in offline mode. It also speeds up the command since it does not check centralized SCMs, central repositories, and issue tracking systems.

There are two ways in which you can work in offline mode:

1. Use an -o switch for any Maven command. For example:

mvn clean install -o
mvn test -o

If there is some dependency issue and you have the dependent jar file in your local system, following command can be used for setting the dependency manually:

mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id>
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>

2. Set it permanently in the Maven settings file settings.xml. The settings file can be
found in the <m2_home>/conf/ folder or the <user_home>/m2/ directories.


No comments: