My project is using maven 1.1, and I want to add a dependency for another JAR that I build which is located locally. How can I do this?
You can add an entry in the pom.xml
for that JAR
and when you build the project using maven
, just add the -o
to the commmand. Make sure the JAR
is present in the local m2
repository.
-o
stands for offline, which means it'll look up for the dependencies in the local m2
only.
将罐子安装到本地仓库
mvn install:install-file -Dfile=<path to your jar> -DgroupId=<groupID you want to give> -DartifactId=<artifactID you want to give> -Dversion=<version you want to give> -Dpackaging=jar
In my case I used the following strategy: install the file to your local repository and then add its dependency to your pom.xml.
Installation could be done like follows:
mvn install:install-file \
-DgroupId=my.local.jar \
-DartifactId=localName \
-Dpackaging=jar \
-Dversion=1.0-MYVERSION \
-Dfile=localFile.jar
for the installed file you would need the following dependency to your pom.xml
<dependency>
<groupId>my.local.jar</groupId>
<artifactId>localName</artifactId>
<version>1.0-MYVERSION</version>
</dependency>
From maven-1.1 FAQ:
How do I add a JAR from a non-Maven project to my local repository?
If it is a JAR that cannot be uploaded to Maven's central repository because of a license, or it is private, you must manually copy it to your local repository. After picking a sensible group ID, and making sure the filename is in the format artifactId-version.jar, copy it to ${maven.repo.local}/groupId/jars/artifactId-version.jar.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.