Java Maven反应器与传递依赖
我的项目具有以下结构:Java Maven反应器与传递依赖,java,maven,Java,Maven,我的项目具有以下结构: tst.parent with modules: tst.one -> has dependency to tst.two tst.two -> has dependency to tst.three tst.three 目标是有两个构建。第一个是完整构建,第二个只构建模块tst.1和tst.3。 因此,我在tst.parent的pom.xml中创建了两个概要文件: <?xml versi
tst.parent
with modules:
tst.one
-> has dependency to tst.two
tst.two
-> has dependency to tst.three
tst.three
目标是有两个构建。第一个是完整构建,第二个只构建模块tst.1和tst.3。
因此,我在tst.parent的pom.xml中创建了两个概要文件:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tst</groupId>
<artifactId>tst.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>tst.parent</name>
<packaging>pom</packaging>
<profiles>
<profile>
<id>part</id>
<modules>
<module>tst.one</module>
<module>tst.three</module>
</modules>
</profile>
<profile>
<id>full</id>
<modules>
<module>tst.one</module>
<module>tst.two</module>
<module>tst.three</module>
</modules>
</profile>
</profiles>
</project>
但是如果我运行一个部分构建,模块会像我在模块部分中列出的那样进行排序:
mvn clean install -P part
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] tst.parent
[INFO] tst.one
[INFO] tst.three
[INFO]
如果使用-project命令行选项,则buildorder计算正确:
mvn clean install -P full --projects tst.one,tst.three
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] tst.three
[INFO] tst.one
[INFO]
但这种方法有一个局限性,即模块tst.2也必须作为源代码提供
有人知道如何告诉maven在部分构建中,在计算反应堆构建顺序时,应该考虑从模块tst.1到模块tst.3的可传递依赖关系吗?
或
我如何告诉maven忽略缺失的模块tst.2作为源代码,并从存储库中为-project方法解析此模块?您希望通过此方法实现什么?除此之外,不要在关系中使用配置文件。我希望有一个可构建的系统,即使属于该父级的某些模块在特定分支中不可用作源。这样的多模块构建应该在相同的结构中,并在相同的版本控制中签入…所以我看不出有任何问题。。。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>tst.parent</artifactId>
<groupId>tst</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>tst.three</artifactId>
</project>
mvn clean install -P full
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] tst.parent
[INFO] tst.three
[INFO] tst.two
[INFO] tst.one
mvn clean install -P part
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] tst.parent
[INFO] tst.one
[INFO] tst.three
[INFO]
mvn clean install -P full --projects tst.one,tst.three
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] tst.three
[INFO] tst.one
[INFO]