我有一个多模块项目。

parent POM (1.0-SNAPSHOT)
|-- module1 (1.0-SNAPSHOT)
|-- module2 (1.0-SNAPSHOT)
`-- module3 (1.0-SNAPSHOT)

当我执行 mvn release:prepare 时,它​​会验证父 POM 是否具有 SNAPSHOT 版本,并且所有依赖模块都没有 SNAPSHOT 版本。如何自动将所有子模块从 SNAPSHOT 更新到下一个发布版本?

我想自动增加所有模块的版本。

有帮助吗?

解决方案

在释放插件可以处理这个问题。你检查更新POM版本的?但... 我不明白的东西。 更改在从X-快照多金属氧酸盐的版本到新版本撞击在多金属氧酸盐的版本到一个新的值y-SNAPSHOT 应由release:prepare进行如说明的准备发行。什么是使用这个目标时走错了?

<强>更新借助 autoVersionSubmodules 参数可能是你在找什么。从准备一个推出示例:

  

多模块的项目

     

您会被提示版本   该项目的每个模块数量。   如果你喜欢,每一个模块得到   相同版本的父POM,   您可以设置选项   autoVersionSubmodulestrue。轮到你了   将被要求只有一次的   发行版本和下一   开发版本。

亲的代码段的pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>x.y.z</version>
            <configuration>
                <goals>deploy</goals>
                <autoversionsubmodules>true</autoversionsubmodules>
            </configuration>
        </plugin>
    </plugins>
</build>

其他提示

要组POMS版本一种灵活的方式,多模块的项目包括,是版本Maven插件

mvn versions:set -DnewVersion=your_new_version

这将调整所有POM版本,父版本和儿童版本,在多模块项目。

然后

mvn versions:commit

mvn versions:revert
  1. 使所有子项目的版本都定义在其父pom.xml中。
  2. 确保所有子项目版本与其父项目版本相同。

    <groupId>com.xyz</groupId>
    <artifactId>module-1</artifactId>
    <packaging>jar</packaging>
    
    <parent>
      <groupId>com.xyz</groupId>
      <artifactId>xyz-parent</artifactId>
      <version>1.0.123-SNAPSHOT</version>
    </parent>
    

     

    <?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/maven-v4_0_0.xsd">
    
      <modelVersion>4.0.0</modelVersion>
      <artifactId>xyz-parent</artifactId>
      <groupId>com.xyz</groupId>
      <version>1.0.123-SNAPSHOT</version>
      <packaging>pom</packaging>
      <name>xyz-parent</name>
    
      <dependencyManagement>
        <dependencies>
    
        <!-- Message -->
        <dependency>
          <groupId>com.xyz</groupId>
          <artifactId>module-1</artifactId>
          <version>${project.version}</version>
        </dependency>
    
        <dependency>
          <groupId>com.xyz</groupId>
          <artifactId>module-2</artifactId>
          <version>${project.version}</version>
        </dependency>
    
      </dependencyManagement>
    </project>
    
  3. 创建另一个 pom.xml 将这些项目组合在一起。

    <modules>   
      <module>../xyz-parent</module>
      <module>../module-1</module>
      <module>../module-2</module>      
    </modules>
    
  4. 然后更新父项目的版本,然后通过以下命令构建它。

    mvn versions:set -DnewVersion=1.0.1004-SNAPSHOT
    mvn clean install
    
  5. 然后将这些子项目中定义的父版本更新为 latset 版本

    mvn -N versions:update-child-modules
    
  6. 然后将它们构建在一起。

    @echo on
    cd   .\xyz-parent
    call mvn versions:set -DnewVersion=1.0.1004-SNAPSHOT -o
    call mvn versions:commit -o
    call mvn clean install -o
    :::http://www.mojohaus.org/versions-maven-plugin/examples/update-child-modules.html
    cd ..\xyz-buildaggregate-ide
    call mvn -N versions:update-child-modules -o
    call mvn clean install -o
    

有一个可能更好的选择 https://issues.apache.org/jira/browse/MNG-624?focusedCommentId=14415968&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14415968

这是一个解决方法,用于解决以下问题:如果没有列出显式版本,则无法引用子模块 poms 中的顶级 pom。(这是Bug MNG-624的意思)它说明了如何拥有该版本的单个位置(在顶级profiles.xml文件中),并且只需在所有pom.xml文件(即${当前版本})

但是,在此方案中release:prepare可能不会为您更新profiles.xml。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top