0

我们已经配置了我们的 Maven 程序集插件来创建单独的 jars 文件,这些文件通过部署插件上传到我们的本地 Maven 存储库。

但是,我们需要在其他项目中引用这些 jar 文件(由程序集插件创建的那些)作为 maven 依赖项。任何关于我们如何实现这一目标的想法都将不胜感激。

更新例如:

-client (pom.xml - groupId=com.mycompany artifactId=client)
  |-src
    |-main
      |-java
        |-authentication
        |-billing
        |-reporting

这被 maven 程序集插件分成 3 个不同的 jar 文件,并发布到我们的本地 repo:

-client-authentication.jar
-client-billing.jar
-client-reporting.jar

我们如何引用 client-authentication.jar 作为另一个项目的依赖项而没有它自己的 pom 文件?

4

2 回答 2

1

您是否尝试将 包含classifier在依赖项中(您的工件有version,对吗?):

<dependency>
  <groupId>com.mycompany</groupId>
  <artifactId>client</artifactId>
  <version>1.0-SNAPSHOT</version>
  <classifier>authentication</classifier>
  <type>jar</type>
</dependency>

但是我需要强调的是,您违反每个模块一个工件的黄金法则,您应该将代码分成三个模块。

于 2010-07-28T17:43:30.557 回答
0

您需要将该本地存储库添加到其他项目的 pom

<repositories>
  <repository>
     <id>my-local-repo</id>
     <name>My companywide local repo</name>
     <url>{the actual url of your repo}</url>
  </repository>
</repositories>

完成后,您可以将依赖项添加到那些相同的 pom 中的那些工件

  <dependency>
     <groupId>{some.group}</groupId>
     <artifactId>{my.local.repo.artifact}</artifactId>
     <version>{some.version}</version>
  </dependency>
于 2010-07-28T10:27:39.077 回答