【发布时间】:2019-05-17 05:11:38
【问题描述】:
假设有一个父项目 A,它的 pom.xml 中有模块 B 和 C。
Project A
|-pom.xml
|----------->ModuleB
| |->pom.xml
|----------->ModuleC
| |->pom.xml
<modules>
<module>B</module>
<module>C</module>
</modules>
模块 C 本身具有一些仅属于该子模块的依赖项。这个依赖应该在模块 C 之前构建,所以我想在为 C 调用“mvn install”时调用“-am”(--also-make)选项。
Maven 正在远程执行,我只有 pom 文件。构建作业在远程 Jenkins 上运行,它使用项目 A 父 pom 中的当前配置文件,必须使用此配置文件。
我虽然可以在模块 C 的 pom 中完成,例如在 maven-compiler-plugin 的配置中?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.source}</source>
<target>${jdk.target}</target>
**<arguments>-am</arguments>** <!--smth like this maybe?-->
</configuration>
</plugin>
我还考虑创建另一个 pom.xml 以仅以正确的顺序包含子模块 C 及其依赖项,并在父 pom 中代替当前子模块 C 使用,但想先尝试 -am 选项。此外,我现在不太明白该把这个新 pom 放在哪里,因为我们已经处于父级 A 级了。
可能整个项目结构应该重构,但这是我现在所拥有的。
更新:下面是不太简化的当前项目结构。
Project A (maven parent for B, C, D)
|-pom.xml
|----------->ModuleB
| |->pom.xml
|----------->folder
|----------->folder
|----------->ModuleC
| |->pom.xml
|----------->ModuleD
| |->pom.xml
<modules>
<module>B</module>
<!-- <module>D</module> | initially was here, now needs to be only C's dependency -->
<module>C</module>
</modules>
【问题讨论】: