受け入れられた回答に関する注意:強力な状況証拠があるため、回答を受け入れました。とはいえ、これは状況証拠ですので、慎重に考えてください。
ユーザーがライフサイクル フェーズではなく、プラグインの目標を実行したときにプラグインをトリガーするにはどうすればよいですか? (これは以前にも尋ねられましたが、答えはライフサイクル フェーズを使用することでした。)
適切な例: -SNAPSHOT サフィックスを除いた名前から現在のバージョンのブランチを生成するrelease:branch
ために呼び出す必要があります。これは私が持っているもので、開発者はプロファイルをアクティブにしてフェーズを呼び出す必要があります。開発者は単に を呼び出す必要があり、これにより実行が開始されます。Gitflow との結婚のようなものです。regex-plugin
verify
release:branch
regex-plugin
<profile>
<id>Release Branch</id>
<build>
<plugins>
<!-- On validate, compute the current version without -SNAPSHOT. -->
<!-- Put the result in a property. -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<value>${project.version}</value>
<regex>^(.*)-SNAPSHOT$</regex>
<replacement>$1</replacement>
<name>project.unqualifiedVersion</name>
</configuration>
</execution>
</executions>
</plugin>
<!-- Also on validate, run the branch plugin, and use -->
<!-- the non-SNAPSHOT version thus computed in the branch name. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>branch</goal>
</goals>
<configuration>
<branchName>release/${project.unqualifiedVersion}</branchName>
<updateWorkingCopyVersions>true</updateWorkingCopyVersions>
<updateBranchVersions>false</updateBranchVersions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
その意図はrelease:branch
、現在のスナップショット バージョン (たとえば、1.0.5-SNAPSHOT
) を新しいブランチに移動することです。新しいブランチには、バージョンにちなんだ名前を付ける必要がありますが、余分な-SNAPSHOT
サフィックスは付けません ( 1.0.5
)。次に、現在のブランチは新しいスナップショット バージョンを取得する必要があります (1.1.0-SNAPSHOT
ではなく1.0.6-SNAPSHOT
、リリース1.0.x
にホットフィックスの余地が必要なため、ブランチ用に予約します) (次のスナップショット バージョンの自動計算はまだ把握していません)したがって、上記の Maven 構成を で実行する場合validate
は、プロンプトで入力する必要があります)。