Maven – Running Maven offline using local Repository

Sometimes you see Maven downloading POM files for dependencies which are already in your local repository and you’re wondering why it does this.

Downloading: 0.95.pom
Downloading: ommons/1.3.1/xmlgraphics-commons-1.3.1.pom
Downloading: /1.7/batik-svg-dom-1.7.pom

The reason it does is because when these were installed in the local repository, it was not given a flag of -Dgenerate.pom=true

If you run the install with this flag, then it will generate and install a local POM file for you, and will not download the POM from the internet repository.

An example below :

mvn install:install-file -DgroupId=%GROUP_ID% -DartifactId=%ARTIFACT_ID% -Dversion=%VERSION% -Dfile=%COMPONENT%.jar -Dpackaging=jar -DgeneratePom=true

There are 2 other ways to run the build without connecting to the internet or network repository each time – provided you have all the required dependencies available offline.

Note: This is just something I do when I want to run a quick repeat build and I know there are no dependencies updated in the mean time. If you do this regularly you will miss out on updates made to the maven repository by other developers.

1. Run the maven build in offline mode

 mvn -o install

NOTE: Maven is executing in offline mode. Any artifacts not already in your local repository will be inaccessible.

When you see this message, you know that maven will not be updating external dependencies during the build.

2. Point the repository to the local file system.

On my local build, if running repeated code builds when I know there is no change in dependency, I have a profile set up to point the repository to a local file system.

In the repository definition, instead of use:


You will still see the message indicating downloading of POM, but this time from the local file system.

And this will be much faster.

Downloading: file://C:\.m2\cactus\1.7.2\cactus-1.7.2.pom
Downloading: file://C:\.m2\strutstest\2.1.3\strutstest-2.1.3.pom

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s