tags:

views:

336

answers:

2

Hi, my problem with maven is that if the maven repository is not responding, one cannot build. It seems to fetch every "mvn package" time some poms, which won't change, because they are of the same version.

How can I say to maven that please don't look them up from server, and instead download them permanetly to offline repository?

Thanks!

+3  A: 

You can configure the repository to only check for updates occasionally, or never by setting the updatePolicy element on the repository declaration. From the settings documentation:

The frequency for downloading updates - can be "always", "daily" (default), "interval:XXX" (in minutes) or "never" (only if it doesn't exist locally).

Adding the following to your POM or the settings will configure the central repository to only download if the artifact doesn't exist locally:

<repositories>
  <repository>
    <id>central</id>
    <releases>
      <updatePolicy>never</updatePolicy>
    </releases>
  </repository>
</repositories>


If the repository in question is an internal remote repository, you need to ensure the maven-metadata.xml is configured correctly in the remote repository or Maven will attempt to download it each time. The simplest way to do this is to use a repository manager that will manage the metadata automatically

Rich Seller
+2  A: 

You can run maven with the -o flag:

 -o,--offline                           Work offline

This will cause Maven to never look for dependencies in remote repositories. On the other hand, your build will fail if the dependencies are not found in the local repository.

Robert Munteanu