Friday, June 3, 2011

Avoiding recurring POM downloads during maven build...

We might often end up in seeing the maven build trying to download poms for many of the dependencies, even if the dependent artifact is available in local repository.

This is a side effect of improper installation of maven dependency artifact.

We generally try to install a maven dependency manually as:

mvn install:install-file -Dfile=your-artifact-1.0.jar \
[-DpomFile=your-pom.xml] \
[-Dsources=src.jar] \
[-Djavadoc=apidocs.jar] \
[-DgroupId=org.some.group] \
[-DartifactId=your-artifact] \
[-Dversion=1.0] \
[-Dpackaging=jar] \
[-Dclassifier=sources] \
[-DgeneratePom=true] \
[-DcreateChecksum=true]

Courtesy: http://maven.apache.org/plugins/maven-install-plugin/usage.html

Since many of the parameters are optional, we tend to avoid -DgeneratePom option. When -DgeneratePom is not given, the manual dependency installation into the local repository will not have an associated pom generated with it. This is the root cause of your build always trying to download certain poms and there by increasing your build time. The solution is just to add -DgeneratePom=true while doing maven dependency installation.

No comments:

Post a Comment