Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven command to install remote dependency locally

Tags:

maven-2

I have a base pom which defines repository locations for the nexus we are running behind our firewall and all of our projects inherit from this base pom. However the base exists in one of the repositories defined in the base, so you can see the circular reference problem. I'd like a maven install:install-file like command I can have new team members run in order to pull down and install the base project locally without having to check the project out from source control and mvn install it.

like image 293
Bryan J Swift Avatar asked Nov 11 '10 17:11

Bryan J Swift


1 Answers

I'd like a maven install:install-file like command I can have new team members run in order to pull down and install the base project locally without having to check the project out from source control and mvn install it.

The Maven Dependency Plugin and its dependency:get goal might help here, you could do something like this:

mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get \
    -Dartifact=groupId:artifactId:version[:packaging] \
    -DrepoUrl=http://repository.mycompany.com/ 

But let me come back on the following:

However the base exists in one of the repositories defined in the base (...)

Unless this is really what you want (adding a repository for thing not found in central), this is usually not how people declare a Nexus repository in a corporate environment.

People usually want all requests to go though their Nexus repository and store artifacts in it. Storing all the artifacts you need yourself is the only way to be sure that you'll be able to repeat your build in 1, 5, 10 years. Sure, the maven folks are doing a great job with central but are you sure you want to rely on something not under your control? So people usually declare Nexus as a mirror of everything (check the section 4.2. Configuring Maven to Use a Single Nexus Group) in the settings.xml.

And if you don't want every user to add the required snippet in their ~/.m2/settings.xml, the best option is to distribute and use a corporate version of the Maven client and to preconfigure it as required using the conf/settings.xml file.

References

  • Nexus User Guide
    • Chapter 4. Configuring Maven to Use Nexus
like image 94
Pascal Thivent Avatar answered Oct 11 '22 13:10

Pascal Thivent