【发布时间】:2016-08-01 15:09:00
【问题描述】:
我在 IntelliJ 中建立了一个多模块项目。我的模块结构如下所示:
Project (no pom.xml file)
|
|--moduleA
| |
|
|--moduleB
| |-Log4J
| |-Jackson
|
|--moduleC
| |-moduleA
| |-moduleB
| |-Log4J
|
|--moduleD
| |-moduleC
| |-moduleA
| |-moduleB
| |-Log4J
|
|--moduleE
| |-moduleA
| |-moduleB
| |-moduleC
| |-Log4J
moduleC 依赖于moduleA 和moduleB,而moduleD 依赖于moduleA、moduleB 和moduleC。 moduleE 也是如此。
我想创建两个 Uber 罐子。一个用于moduleD,一个用于moduleE,每个都包含模块的依赖关系,包括模块A、B和C。
我正在使用 Maven 3 来管理我的依赖项,并使用 maven-shade-plugin 来创建 Uber jar。
我在pom.xml 文件中添加了必要的依赖项,如下所示:
<dependency>
<groupId>com.modules</groupId>
<artifactId>moduleA</artifactId>
<version>1.0</version>
</dependency>
我已将maven-shade-plugin 添加到每个模块的pom.xml 文件中。到目前为止,我能够为moduleA 和moduleB 构建一个超级jar,但是当我尝试moduleC 时,我收到以下错误:
[WARNING] The POM for com.modules:moduleA:jar:1.0 is missing, no dependency information available
[WARNING] The POM for com.modules:moduleB:jar:1.0 is missing, no dependency information available
我该如何解决这个问题?
如果我通过 IntelliJ 构建和运行模块,一切正常。我还能够通过配置 IntellJ 工件来构建一个 uber jar。
如何配置 Maven 来执行此操作?我需要它,因为我想使用 uber jar 进行生产,并且我正在尝试设置 Jenkins 以在提交后构建解决方案。
我将以下帖子设为红色:How to create self-containing (standalone) jar of each modules of a multi-module maven project 但我无法使其正常工作。
编辑:
这是moduleA 和moduleB 中的maven-shade-plugin 设置
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
这是moduleC中的maven-shade-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
如您所见,我使用的是默认配置。
【问题讨论】:
-
你是如何定义 maven-shade-plugin 设置的?没有看到你的设置很难诊断。
-
@MichaelDibbets 请参阅配置的编辑部分。
-
maven.apache.org/plugins/maven-shade-plugin/examples/… 你没有定义
有什么原因吗? -
目前还不清楚你想做什么,但我猜你想在
moduleD和moduleE下创建一个专用模块,负责创建 uberjar。所以你将在moduleD下拥有一个模块moduleD-uber,它依赖于moduleA、moduleB、moduleC。 -
@IvanStoyanov,参见 logback-android 的 pom-uber.xml,它创建了一个包含其子模块项目的 uber jar。
标签: java maven intellij-idea jenkins jar