【发布时间】:2017-06-21 17:06:01
【问题描述】:
我想为我的项目设置一个发布版本。我对所有模块使用聚合 pom。每个模块父级不是前面提到的聚合pom。
我的问题与Updating version numbers of modules in a multi-module Maven project 的问题不同,聚合的 pom 也是父 pom。
聚合的 pom.xml 是:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.example</groupId>
<artifactId>aggregate</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<modules>
<module>module1</module>
</modules>
</project>
module1 pom.xml 在哪里:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.example</groupId>
<artifactId>module-1</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>com.example</groupId>
<artifactId>parent1</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../parent1/pom.xml</relativePath>
</parent>
</project>
当我执行时:
mvn versions:set -DnewVersion=0.0.1
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] module-1
[INFO] aggregate
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building aggregate 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.3:set (default-cli) @ aggregate ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: C:\Users\maxim.kirilov\workspace\maven-games\aggregate
[INFO] Processing change of com.example:aggregate:0.0.1 -> 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] module-1 ........................................... SKIPPED
[INFO] aggregate .......................................... SUCCESS [ 0.962 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
为什么会跳过 module-1?我阅读了一些建议分别为每个模块调用 maven set version 命令的文章,maven 是否支持更清洁的解决方案?
【问题讨论】:
标签: java maven multi-module