Maven使用${revision}实现多模块版本统一管理

父pom: 

<?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">

    <parent>
        <artifactId>parent</artifactId>
        <groupId>com.test</groupId>
        <version>1.2.5</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>assets-admin</artifactId>
    <version>${revision}</version>
    <packaging>pom</packaging>

    <modules>
        <module>admin-interface</module>
        <module>admin-service</module>
    </modules>

    <properties>
        <revision>1.1.10</revision>
    </properties>

    <dependencyManagement>
        <dependencies>
            
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
          
            <!-- 添加flatten-maven-plugin插件 -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>flatten-maven-plugin</artifactId>
                <version>1.5.0</version>
                <executions>
                    <execution>
                        <id>flatten</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>flatten</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>flatten.clean</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                </executions>
                <inherited>true</inherited>
                <configuration>
                    <!-- 避免IDE将 .flattened-pom.xml 自动识别为功能模块 -->
                    <updatePomFile>true</updatePomFile>
                    <flattenMode>resolveCiFriendliesOnly</flattenMode>
                </configuration>
            </plugin>


        </plugins>
    </build>
</project>

 

 

子模块pom

<?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">
    <parent>
        <groupId>com.test</groupId>
        <artifactId>assets-admin</artifactId>
        <version>${revision}</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>assets-admin-interface</artifactId>
    <packaging>jar</packaging>
    <dependencies>
        
    </dependencies>
</project>

 

最后在.gitignore文件内添加   一行 .flattened-pom.xml

 

posted @ 2024-01-18 10:34  来自China的神秘人  阅读(916)  评论(0)    收藏  举报