views:

228

answers:

3

I'm working in a Continuous Integration environment and part of the automated build process includes the compilation of Maven managed projects.

What I want to know is if there is a way to make the Maven build independent of the network connection.

Currently we have the all the jar's that we need installed in the repository but the problem is that Maven tries to check for plugins updates and that makes the build fail if, eventually, the connection is down.

+3  A: 

use the -o (offline) option

dfa
+5  A: 

You can either run offline with the -o switch or by adding <offline>true<offline> to your settings.xml.

It's worth pointing out though that Maven may fail the build when running offline if it decides it needs to check for dependency or plugin updates. If you set your repositories with <updatePolicy>never</updatePolicy> you can avoid this, but you'll need to force updates periodically (with -U and/or -cpu).

If you are using a repository manager, you can set your repository to be a mirror of the external repositories. This still involves a network connection, but only your internal network (or if the repository manager is on your local machine, no connection at all).

For example this config redirects all calls to central to my local Nexus server running on my development box:

<mirrors>
  <mirror>
    <id>central-proxy</id>
    <mirrorOf>central</mirrorOf>
    <url>http://localhost/nexus/content/groups/public&lt;/url&gt;
  </mirror>
</mirrors>
Rich Seller
Nexus can be found at: http://nexus.sonatype.org/I found it a breeze to install and setup.
extraneon
It looks like that the <updatePolicy> solution is just what I need. Does anyone knows a way to test if it is working?
Alceu Costa
you can manually modify your maven-metadata-[repository].xml file for an artifact in your local repository to be outside the range. Say you've set updatePolicy to *daily*, change the date to be 2 days ago, then run a build that depends on that artifact, the corresponding repository should be checked for updates
Rich Seller
There's no maven-metadata-[reporisitory].xml files in my repository. I wonder if something went wrong when I created it...
Alceu Costa
That may be out of date information, it certainly used to do this for maven 2.0.x, but I just checked my maven 2.2.0 repository and I have no maven-metadata-*.xml files either
Rich Seller
There is some background information on this in the Maven book: http://www.sonatype.com/books/maven-book/reference/pom-relationships-sect-pom.html
Rich Seller
A: 

You can try installing a "Build Artifact Repository Manager" like Archiva (http://archiva.apache.org/) in you local network. It will work as a mirror, so maven will try to download and check for updates on your local network and not over internet. Uou should also build your own artifacts and use it on archiva.

Diego Dias