莫等闲,白了少年头,空悲切——岳飞

我们maven项目除了使用这种方式修改版本号,还有一种统一管理版本号的方式:

项目地址:https://github.com/mojohaus/flatten-maven-plugin

官方文档:http://www.mojohaus.org/flatten-maven-plugin/

引入:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<!--<version>INSERT LATEST VERSION HERE</version>-->
<executions>
<execution>
<goals>
<goal>flatten</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- See usage on maven site from link above for details -->
</configuration>
</plugin>
</plugins>
</build>

使用时将版本号改为${revision}即可,记得不要改别的名字

父模块

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<groupId>io.github.vampireachao</groupId>
<artifactId>stream-query</artifactId>
<packaging>pom</packaging>
<version>${revision}</version>
<modules>
<module>stream-core</module>
<module>stream-plugin</module>
</modules>


<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<revision>1.1.6</revision>
...
</properties>

子模块

1
2
3
4
5
6
7
8
9
<parent>
<artifactId>stream-query</artifactId>
<groupId>io.github.vampireachao</groupId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>stream-core</artifactId>

示例项目的pomhttps://gitee.com/VampireAchao/stream-query/blob/master/pom.xml