Roy Truelove
Roy Truelove

Reputation: 22456

Maven - pointing to a *single* repository

I've got a Nexus Maven repository that I want to be the one and only repository used by my projects.

Per the Nexus documentation, To solve this problem I should change my local .m2/settings.xml.

Changing my settings.xml to solve this problem isn't a good practice, as it's not portable across different developer machines / CI servers.

What I want to do is change my global parent pom to say "use this and only this repository for all projects that use me as a parent." How can I do that? I see that I can add my repository as one of the repositories that are checked, but not the only repository. I tried cutting and pasting the 'mirror' section of the settings file to my pom, but 'mirror' is not allowed there.

Any ideas?

Thanks, Roy

Upvotes: 1

Views: 778

Answers (3)

matsev
matsev

Reputation: 33759

Have you tried to configure the <repositories> element in your pom?

<project>
  ...
    <repositories>
      <repository>
        <id>my-internal-site</id>
        <url>http://myserver/repo</url>
      </repository>
    </repositories>
  ...
</project>

More information and details can be found at the Maven Internal Repositories page.

Upvotes: 0

Sri Sankaran
Sri Sankaran

Reputation: 8310

Tweak Nexus' instructions of modifying your $HOME/.m2/settings.xml. Have a networked settings file that refers to Nexus. This settings file should be used by all developers (and your CI server).

How do all developers refer to this one settings file?

There are a couple of ways of skinning that cat.

Option 1: Alias your Maven command.
   On UNIX: alias mvn=mvn -s /networked/path/to/settings.xml
   ON Windows: Open mvn.bat. Find mvn invocation and alter it similarly

Option 2: Home/settings linked to networked location
  ON UNIX: cd $HOME; rm settings.xml;ln -s /networked/path/to/settings.xml settings.xml
   ON Windows: I don't know the equivalent foo for symbolic linking

Upvotes: 1

parsifal
parsifal

Reputation: 11

Assuming that you have a "standard" Maven install for all developers, you can change $M2_HOME/conf/settings.xml

Otherwise, you're out of luck with anything short of an intelligent network proxy.

Upvotes: 1

Related Questions