Wednesday, February 9, 2011

Why Installing Maven dependencies with the generatePom option is a good idea

I recently noticed my project's Maven build takes ages to complete. Looking more closely I found out that on each build, Maven was trying to download a number of Poms from all declared repositories, waiting for a response from these repositories took some time and made my build process much longer. All the mentioned dependencies were ones I had to install locally on my local repository for licensing reasons.

So what's happening here? When you skip -DgeneratePom=true while installing a local dependency, Maven will obviously not create a pom.xml for the dependency. Each time you build, Maven will try to download the dependency pom. I removed all problematic dependencies and installed again in the following method:
mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id>
-DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
-DgeneratePom=true

No comments: