Skip to content

Commit 4adbb9a

Browse files
committed
Set versions of used plugins in the code and allow to modify it with properties - closes #330
This solves source code incompatibility issues between this plugin and used versions-maven-plugin and tycho-versions-plugin.
1 parent 6e03e4c commit 4adbb9a

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,18 @@
5353
*
5454
*/
5555
public abstract class AbstractGitFlowMojo extends AbstractMojo {
56-
/** A full name of the versions-maven-plugin set goal. */
57-
private static final String VERSIONS_MAVEN_PLUGIN_SET_GOAL = "org.codehaus.mojo:versions-maven-plugin:set";
58-
/** A full name of the versions-maven-plugin set-property goal. */
59-
private static final String VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL = "org.codehaus.mojo:versions-maven-plugin:set-property";
60-
/** Name of the tycho-versions-plugin set-version goal. */
61-
private static final String TYCHO_VERSIONS_PLUGIN_SET_GOAL = "org.eclipse.tycho:tycho-versions-plugin:set-version";
56+
/** Group and artifact id of the versions-maven-plugin. */
57+
private static final String VERSIONS_MAVEN_PLUGIN = "org.codehaus.mojo:versions-maven-plugin";
58+
/** The versions-maven-plugin set goal. */
59+
private static final String VERSIONS_MAVEN_PLUGIN_SET_GOAL = "set";
60+
/** The versions-maven-plugin set-property goal. */
61+
private static final String VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL = "set-property";
62+
63+
/** Group and artifact id of the tycho-versions-plugin. */
64+
private static final String TYCHO_VERSIONS_PLUGIN = "org.eclipse.tycho:tycho-versions-plugin";
65+
/** The tycho-versions-plugin set-version goal. */
66+
private static final String TYCHO_VERSIONS_PLUGIN_SET_GOAL = "set-version";
67+
6268
/** Name of the property needed to have reproducible builds. */
6369
private static final String REPRODUCIBLE_BUILDS_PROPERTY = "project.build.outputTimestamp";
6470

@@ -180,6 +186,18 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
180186
@Parameter(property = "updateOutputTimestamp", defaultValue = "true")
181187
private boolean updateOutputTimestamp = true;
182188

189+
/**
190+
* Version of versions-maven-plugin to use.
191+
*/
192+
@Parameter(property = "versionsMavenPluginVersion", defaultValue = "2.8.1")
193+
private String versionsMavenPluginVersion = "2.8.1";
194+
195+
/**
196+
* Version of tycho-versions-plugin to use.
197+
*/
198+
@Parameter(property = "tychoVersionsPluginVersion", defaultValue = "0.24.0")
199+
private String tychoVersionsPluginVersion = "0.24.0";
200+
183201
/**
184202
* Options to pass to Git push command using <code>--push-option</code>.
185203
* Multiple options can be added separated with a space e.g.
@@ -1140,15 +1158,16 @@ protected void mvnSetVersions(final String version) throws MojoFailureException,
11401158
getLog().info("Updating property '" + versionProperty + "' to '" + version + "'.");
11411159
}
11421160

1143-
executeMvnCommand(TYCHO_VERSIONS_PLUGIN_SET_GOAL, prop, newVersion, "-Dtycho.mode=maven");
1161+
executeMvnCommand(TYCHO_VERSIONS_PLUGIN + ":" + tychoVersionsPluginVersion + ":" + TYCHO_VERSIONS_PLUGIN_SET_GOAL, prop,
1162+
newVersion, "-Dtycho.mode=maven");
11441163
} else {
11451164
boolean runCommand = false;
11461165
List<String> args = new ArrayList<>();
11471166
args.add("-DgenerateBackupPoms=false");
11481167
args.add(newVersion);
11491168
if (!skipUpdateVersion) {
11501169
runCommand = true;
1151-
args.add(VERSIONS_MAVEN_PLUGIN_SET_GOAL);
1170+
args.add(VERSIONS_MAVEN_PLUGIN + ":" + versionsMavenPluginVersion + ":" + VERSIONS_MAVEN_PLUGIN_SET_GOAL);
11521171
args.add(grp);
11531172
args.add(art);
11541173
}
@@ -1157,7 +1176,7 @@ protected void mvnSetVersions(final String version) throws MojoFailureException,
11571176
runCommand = true;
11581177
getLog().info("Updating property '" + versionProperty + "' to '" + version + "'.");
11591178

1160-
args.add(VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL);
1179+
args.add(VERSIONS_MAVEN_PLUGIN + ":" + versionsMavenPluginVersion + ":" + VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL);
11611180
args.add("-Dproperty=" + versionProperty);
11621181
}
11631182
if (runCommand) {
@@ -1178,7 +1197,9 @@ protected void mvnSetVersions(final String version) throws MojoFailureException,
11781197

11791198
getLog().info("Updating property '" + REPRODUCIBLE_BUILDS_PROPERTY + "' to '" + timestamp + "'.");
11801199

1181-
executeMvnCommand(VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL, "-DgenerateBackupPoms=false",
1200+
executeMvnCommand(
1201+
VERSIONS_MAVEN_PLUGIN + ":" + versionsMavenPluginVersion + ":" + VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL,
1202+
"-DgenerateBackupPoms=false",
11821203
"-Dproperty=" + REPRODUCIBLE_BUILDS_PROPERTY, "-DnewVersion=" + timestamp);
11831204
}
11841205
}

0 commit comments

Comments
 (0)