欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

maven父子工程多模塊統(tǒng)一管理版本號的解決方法

 更新時間:2024年09月12日 08:41:50   作者:HBLOG  
maven父子工程多模塊,每個模塊還都可以獨立存在,子模塊往往通常希望和父工程保持一樣的版本,如果每個工程單獨定義版本號,后期變更打包也非常麻煩,,所以本文給大家介紹了maven父子工程多模塊如何管理統(tǒng)一的版本號,需要的朋友可以參考下

1.為什么要統(tǒng)一管理版本?

maven父子工程多模塊,每個模塊還都可以獨立存在,子模塊往往通常希望和父工程保持一樣的版本,如果每個工程單獨定義版本號,后期變更打包也非常麻煩,如何維護(hù)一個全局的版本號呢?

2.如何解決呢?

Maven官方文檔說:自 Maven 3.5.0-beta-1 開始,可以使用 ${revision}, ${sha1} and/or ${changelist} 這樣的變量作為版本占位符。

即在maven多模塊項目中,可配合插件flatten-maven-plugin${revision}屬性來實現(xiàn)全局版本統(tǒng)一管理。

父工程

<?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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-parent</artifactId>
        <version>2.7.18</version>
    </parent>
    <groupId>com.xxx.project</groupId>
    <artifactId>xxx-parent</artifactId>
    <packaging>pom</packaging>
    <version>${revision}</version>
    <modules>
        <module>module1</module>
        <module>module2</module>
        <module>module3</module>
    </modules>

    <properties>
        <!-- globe version,if you can update the version for all project -->
        <revision>1.1.1</revision>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <build>
        <plugins>
            <!-- 添加flatten-maven-plugin插件 -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>flatten-maven-plugin</artifactId>
                <version>1.3.0</version>
                <inherited>true</inherited>
                <executions>
                    <execution>
                        <id>flatten</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>flatten</goal>
                        </goals>
                        <configuration>
                            <updatePomFile>true</updatePomFile>
                            <flattenMode>resolveCiFriendliesOnly</flattenMode>
                            <pomElements>
                                <parent>expand</parent>
                                <distributionManagement>remove</distributionManagement>
                                <repositories>remove</repositories>
                            </pomElements>
                        </configuration>
                    </execution>
                    <execution>
                        <id>flatten.clean</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

子模塊

<?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>xxx-parent</artifactId>
        <groupId>com.xxx.project</groupId>
        <version>${revision}</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>module3</artifactId>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <dependencies>

        <dependency>
            <groupId>com.xxx.project</groupId>
            <artifactId>module1</artifactId>
            <version>${revision}</version>
        </dependency>
    </dependencies>


</project>

編譯

mvn clean package

基于以上操作,每次版本號變更,只需要修改父模塊POM文件中的revision即可

3.引用

https://maven.apache.org/maven-ci-friendly.html

到此這篇關(guān)于maven父子工程多模塊統(tǒng)一管理版本號的解決方法的文章就介紹到這了,更多相關(guān)maven一管理版本號內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • SpringBoot自定義注解使用讀寫分離Mysql數(shù)據(jù)庫的實例教程

    SpringBoot自定義注解使用讀寫分離Mysql數(shù)據(jù)庫的實例教程

    這篇文章主要給大家介紹了關(guān)于SpringBoot自定義注解使用讀寫分離Mysql數(shù)據(jù)庫的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • Mybatis-Plus最優(yōu)化持久層開發(fā)過程

    Mybatis-Plus最優(yōu)化持久層開發(fā)過程

    Mybatis-plus(簡稱MP)是一個Mybatis的增強(qiáng)工具,在mybatis的基礎(chǔ)上只做增強(qiáng)不做改變,提高效率,自動生成單表的CRUD功能,這篇文章主要介紹了Mybatis-Plus最優(yōu)化持久層開發(fā),需要的朋友可以參考下
    2024-07-07
  • java計算給定字符串中出現(xiàn)次數(shù)最多的字母和該字母出現(xiàn)次數(shù)的方法

    java計算給定字符串中出現(xiàn)次數(shù)最多的字母和該字母出現(xiàn)次數(shù)的方法

    這篇文章主要介紹了java計算給定字符串中出現(xiàn)次數(shù)最多的字母和該字母出現(xiàn)次數(shù)的方法,涉及java字符串的遍歷、轉(zhuǎn)換及運(yùn)算相關(guān)操作技巧,需要的朋友可以參考下
    2017-02-02
  • idea自帶Jacoco/idea自動測試語句覆蓋率方法(使用詳解)

    idea自帶Jacoco/idea自動測試語句覆蓋率方法(使用詳解)

    這篇文章主要介紹了idea自帶Jacoco/idea自動測試語句覆蓋率方法,本文給大家分享使用方法,通過圖文實例相結(jié)合給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-04-04
  • Springboot 1.5.7整合Kafka-client代碼示例

    Springboot 1.5.7整合Kafka-client代碼示例

    這篇文章主要介紹了Springboot 1.5.7整合Kafka-client代碼示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-10-10
  • Java多邊形重心計算

    Java多邊形重心計算

    今天小編就為大家分享一篇關(guān)于Java多邊形重心計算,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2019-01-01
  • springboot整合shardingsphere和seata實現(xiàn)分布式事務(wù)的實踐

    springboot整合shardingsphere和seata實現(xiàn)分布式事務(wù)的實踐

    本文主要介紹了springboot整合shardingsphere和seata實現(xiàn)分布式事務(wù)的實踐,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-07-07
  • Spring boot使用spring retry重試機(jī)制的方法示例

    Spring boot使用spring retry重試機(jī)制的方法示例

    這篇文章主要介紹了Spring boot使用spring retry重試機(jī)制的方法示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01
  • 最新評論