在Maven 1.1中为本地JAR添加依赖项

时间:2013-04-08 07:42:01

标签: java maven

我的项目正在使用maven 1.1,我想为我构建的另一个位于本地的JAR添加一个依赖项。我怎么能这样做?

4 个答案:

答案 0 :(得分:0)

您可以在pom.xml中为JAR添加条目,并在使用maven构建项目时,只需将-o添加到该命令即可。确保本地JAR存储库中存在m2

-o代表离线,这意味着它只会在本地m2中查找依赖项。

答案 1 :(得分:0)

将jar安装到本地仓库

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

答案 2 :(得分:0)

在我的情况下,我使用了以下策略:将文件安装到本地存储库,然后将其依赖项添加到pom.xml。

安装可以完成如下:

mvn install:install-file \
  -DgroupId=my.local.jar \
  -DartifactId=localName \
  -Dpackaging=jar \
  -Dversion=1.0-MYVERSION \
  -Dfile=localFile.jar

对于已安装的文件,您需要以下依赖于pom.xml

<dependency>
    <groupId>my.local.jar</groupId>
    <artifactId>localName</artifactId>
    <version>1.0-MYVERSION</version>
</dependency>

答案 3 :(得分:0)

来自maven-1.1 FAQ:

  

如何将非Maven项目中的JAR添加到本地存储库?
  如果由于许可证而无法将其上载到Maven的中央存储库,或者它是私有的,则必须手动将其复制到本地存储库。选择合理的组ID并确保文件名格式为artifactId-version.jar后,将其复制到$ {maven.repo.local} /groupId/jars/artifactId-version.jar。

相关问题