Add below to your settings.xml for global or user_settings.xml for personalized user id for access control.
<server>
<id>snapshots</id>
<username>user_one</username>
<password>password1</password>
</server>
<server>
<id>releases</id>
<username>user_two</username>
<password>password2</password>
</server>
Add below to your project/pom.xml
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<name>Snapshots Repository</name>
<url>http://company-private-repo.com/apache-archiva-2.2.4/repository/snapshots</url>
</snapshotRepository>
<repository>
<id>releases</id>
<name>Releases Repository</name>
<url>http://company-private-repo.com/apache-archiva-2.2.4/repository/releases/</url>
</repository>
</distributionManagement>
Eclipse Run As: Maven build, goal as deploy.
Reference:
https://maven.apache.org/repository-management.html
Alternative:
I want the jar to be in a 3rdparty lib in source control, and link to it by relative path from the pom.xml file.
If you really want this (understand, if you can't use a corporate repository), then my advice would be to use a "file repository" local to the project and to not use a system
scoped dependency. The system
scoped should be avoided, such dependencies don't work well in many situation (e.g. in assembly), they cause more troubles than benefits.
So, instead, declare a repository local to the project:
<repositories>
<repository>
<id>my-local-repo</id>
<url>file://${project.basedir}/my-repo</url>
</repository>
</repositories>
Install your third party lib in there using install:install-file
with the localRepositoryPath
parameter:
Update: It appears that install:install-file
ignores the localRepositoryPath
when using the version 2.2 of the plugin. However, it works with version 2.3 and later of the plugin. So use the fully qualified name of the plugin to specify the version:
mvn org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file \
-Dfile=<path-to-file> -DgroupId=<myGroup> \
-DartifactId=<myArtifactId> -Dversion=<myVersion> \
-Dpackaging=<myPackaging> -DlocalRepositoryPath=<path>
maven-install-plugin documentation
Finally, declare it like any other dependency (but without the system
scope):
<dependency>
<groupId>your.group.id</groupId>
<artifactId>3rdparty</artifactId>
<version>X.Y.Z</version>
</dependency>
This is IMHO a better solution than using a system
scope as your dependency will be treated like a good citizen (e.g. it will be included in an assembly and so on).
Now, I have to mention that the "right way" to deal with this situation in a corporate environment (maybe not the case here) would be to use a corporate repository.
No comments:
Post a Comment