3737import org .apache .maven .project .ProjectBuilder ;
3838import org .apache .maven .project .ProjectBuildingResult ;
3939import org .apache .maven .settings .Settings ;
40+ import org .apache .maven .shared .release .policy .version .VersionPolicy ;
4041import org .codehaus .plexus .components .interactivity .Prompter ;
4142import org .codehaus .plexus .util .StringUtils ;
4243import org .codehaus .plexus .util .cli .CommandLineException ;
@@ -195,6 +196,17 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
195196 @ Parameter (property = "gitExecutable" )
196197 private String gitExecutable ;
197198
199+ /**
200+ * The role-hint for the {@link org.apache.maven.shared.release.policy.version.VersionPolicy}
201+ * implementation used to calculate the project versions.
202+ * If a policy is set other parameters controlling the generation of version are ignored
203+ * (digitsOnlyDevVersion, versionDigitToIncrement).
204+ *
205+ * @since 1.18.0
206+ */
207+ @ Parameter (property ="projectVersionPolicyId" )
208+ private String projectVersionPolicyId ;
209+
198210 /** Maven session. */
199211 @ Parameter (defaultValue = "${session}" , readonly = true )
200212 protected MavenSession mavenSession ;
@@ -208,6 +220,8 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
208220 /** Maven settings. */
209221 @ Parameter (defaultValue = "${settings}" , readonly = true )
210222 protected Settings settings ;
223+ @ Component
224+ protected Map <String ,VersionPolicy > versionPolicies ;
211225
212226 /**
213227 * Initializes command line executables.
@@ -1380,4 +1394,16 @@ public String getError() {
13801394 public void setArgLine (String argLine ) {
13811395 this .argLine = argLine ;
13821396 }
1397+
1398+ protected VersionPolicy getVersionPolicy () {
1399+ if (StringUtils .isNotBlank (projectVersionPolicyId )) {
1400+ VersionPolicy versionPolicy = versionPolicies .get (projectVersionPolicyId );
1401+ if (versionPolicy == null ) {
1402+ throw new IllegalArgumentException ("No implementation found for projectVersionPolicyId: " + projectVersionPolicyId );
1403+ }
1404+ return versionPolicy ;
1405+ }
1406+ return null ;
1407+ }
1408+
13831409}
0 commit comments