tags:

views:

25

answers:

3

When I build using maven I see it checking all sort of foreign repositories for artifacts which only my local build should produce. How can I tell it that the com.myorg group can only be found in the local repository? Basically I want to do what m2eclipse does with workspace resolution but on the command line.

[INFO] snapshot com.myorg:core:0.0.1-SNAPSHOT: checking for updates from sun-jms
[INFO] snapshot com.myorg:core:0.0.1-SNAPSHOT: checking for updates from hibernate
[INFO] snapshot com.myorg:util:0.0.1-SNAPSHOT: checking for updates from sun-jms
[INFO] snapshot com.myorg:util:0.0.1-SNAPSHOT: checking for updates from hibernate
...

Background: I have a hierarchical maven project (one level). I want to do a full build so i go to the top and do mvn clean install.

  • com.myorg (parent)
    • pom.xml
    • com.myorg.core
      • pom.xml
    • com.myorg.util
      • pom.xml
+1  A: 

You can try with passing the "-o" option to Maven. -O activates the "Offline mode", in which Maven doesn't query remote repositories to check for updates or new artifacts.

I don't think that you can specify this on a per-dependency basis.

Vivien Barousse
+1  A: 

If the remote repositories that you are using are release repositories and do actually not contain any SNAPSHOT, they you can disable SNAPSHOT for them and Maven won't check them for SNAPSHOT updates. For example:

<repositories>
  <repository>
    <id>java.net</id>
    <url>http://download.java.net/maven/2&lt;/url&gt;
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>
  ...
</repositories> 
Pascal Thivent
pure genius; I would have thought that this would be an attribute which the repository would control, rather than each user.
Justin
A: 

By default maven checks dependencies in your local repository first, then on external repositories. The only case which will make maven check external repositories, is the use of snapshots.

If you use snapshots, you can use the <updatePolicy> markup to change when your external repository will be checked.

If you wan to work in offline mode you can either set a temporary offline option on your mvn command with the "-o" option, or you can set it up in your "~/.m2/settings.xml" with <offline>true</offline>.


Before you do so, remember to use the dependecy:go-offline mojo to download your dependency once before you really activate the offline mode.


Resources :

Colin Hebert