views:

806

answers:

2

Hi all.

I'm using maven in my project and I need to run the build in a non-internet-access machine.

When I test my project build everything is working, but when I run the build in a future moment, the maven try to update the mvn-plugins and this sht* is broking my build.

My config file: settings.xml from mvn.

    <profile>
      <id>blaProfile</id>
      <repositories>
        <repository>
          <id>blaRepo</id>
          <url>file://${bla.3rdParty.home}/maven/.m2/repository</url>
          <layout>default</layout>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>blaRepo</id>
          <url>file://${bla.3rdParty.home}/maven/.m2/repository</url>
          <layout>default</layout>
        </pluginRepository>
      </pluginRepositories>
    </profile>

  <activeProfiles>
    <activeProfile>blaProfile</activeProfile>
  </activeProfiles>

And I ran my maven is with the params:

mvn -npu -bla.3rdParty.home="$(THE_CORRECT_PATH)" package

I saw that maven try to update some mvn-plugins for some time, but the option:

-npu,--no-plugin-updates      Suppress upToDate check for any relevant

Should work for this updates.

Well waiting some help on that!

Thanks in advance!


UPDATE(1):
What I'm looking at, is that I could use the setting:

<usePluginRegistry>true</usePluginRegistry>

Inside my settings.xml and with this, I'll have a plugin-registry.xml inside ${user.home}/.m2 that I can config and force the maven plugins versions.

But it's not working! :(

A: 

I think this happens because Maven hasn't got the metadata available locally to determine if its plugin versions are correct. If you specify exact versions for your plugins (which is a good idea for reproducability anyway), it doesn't need to do the check, so will not try to connect to the remote repositories.

By specify exact versions, I mean that in your project's POM you should add the version to the plugin declaration. For example:

<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <!-- set the version explicitly-->
    <version>2.0</version>
  </plugin>
</plugins>

Note you can also force Maven to use internal repositories instead of Central by setting up repository mirrors. See this answer for more details on using repository managers and mirrors.

In the config you included, you're setting your remote repository to point to your local repository, this is not a good idea. To run offline you should either pass -o at the command line or add this to your settings.xml:

<offline>true</offline>
Rich Seller
@Rich, when you mention in specify the version of my plugins you are saying MAVEN plugins right? Which is the best way to do this specification ?? Please see my update in my post to see if I'm doing right. Thanks!
Castanho
+1  A: 

Before you go offline run the following:

mvn dependency:go-offline

That will download all your dependencies and plugins that you need to build your project into ~/.m2/repository.

Once you've run that you can now build your project offline using the '-o' flag:

mvn install -o
hohonuuli
This is a good point, but my idea is to create a kind of CD/DVD with the procedures to create a war file, with MVN in this example. By that I create a 'file' repository, that contains all dependencies that I need. With your idea I'll have to force the user to put all dependencies into his .m2 dir. This is a option, but I'm running to some other direction.
Castanho