Maven プロジェクトで、すべての子モジュールと親モジュールのバージョンを自動的に更新するにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/2341906

質問

マルチモジュールプロジェクトがあります。

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バージョン?が---得られません。 変化するバージョンをPOMsからx-スナップショットに新しいバージョンぶつのバージョンのPOMsに新しい価値y-スナップショット なければならない 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

これは、マルチモジュールプロジェクト内のすべてのポンポンのバージョン、親バージョンと子バージョンを調整します。

そして

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が約です)バージョンの単一の場所を(トップレベルPROPELISE.XMLファイル)にする方法を説明し、すべてのpom.xmlファイル(つまり、単にプロパティ参照があります(すなわち${現在のバージョン})

ただし、このスキームでは release:prepare はおそらく profiles.xml を更新しません。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top