Skip to content

Commit

Permalink
Set versions of used plugins in the code and allow to modify it with …
Browse files Browse the repository at this point in the history
…properties - closes #330

This solves source code incompatibility issues between this plugin and used versions-maven-plugin and tycho-versions-plugin.
  • Loading branch information
aleksandr-m committed Feb 18, 2022
1 parent 6e03e4c commit 4adbb9a
Showing 1 changed file with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@
*
*/
public abstract class AbstractGitFlowMojo extends AbstractMojo {
/** A full name of the versions-maven-plugin set goal. */
private static final String VERSIONS_MAVEN_PLUGIN_SET_GOAL = "org.codehaus.mojo:versions-maven-plugin:set";
/** A full name of the versions-maven-plugin set-property goal. */
private static final String VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL = "org.codehaus.mojo:versions-maven-plugin:set-property";
/** Name of the tycho-versions-plugin set-version goal. */
private static final String TYCHO_VERSIONS_PLUGIN_SET_GOAL = "org.eclipse.tycho:tycho-versions-plugin:set-version";
/** Group and artifact id of the versions-maven-plugin. */
private static final String VERSIONS_MAVEN_PLUGIN = "org.codehaus.mojo:versions-maven-plugin";
/** The versions-maven-plugin set goal. */
private static final String VERSIONS_MAVEN_PLUGIN_SET_GOAL = "set";
/** The versions-maven-plugin set-property goal. */
private static final String VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL = "set-property";

/** Group and artifact id of the tycho-versions-plugin. */
private static final String TYCHO_VERSIONS_PLUGIN = "org.eclipse.tycho:tycho-versions-plugin";
/** The tycho-versions-plugin set-version goal. */
private static final String TYCHO_VERSIONS_PLUGIN_SET_GOAL = "set-version";

/** Name of the property needed to have reproducible builds. */
private static final String REPRODUCIBLE_BUILDS_PROPERTY = "project.build.outputTimestamp";

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

/**
* Version of versions-maven-plugin to use.
*/
@Parameter(property = "versionsMavenPluginVersion", defaultValue = "2.8.1")
private String versionsMavenPluginVersion = "2.8.1";

/**
* Version of tycho-versions-plugin to use.
*/
@Parameter(property = "tychoVersionsPluginVersion", defaultValue = "0.24.0")
private String tychoVersionsPluginVersion = "0.24.0";

/**
* Options to pass to Git push command using <code>--push-option</code>.
* Multiple options can be added separated with a space e.g.
Expand Down Expand Up @@ -1140,15 +1158,16 @@ protected void mvnSetVersions(final String version) throws MojoFailureException,
getLog().info("Updating property '" + versionProperty + "' to '" + version + "'.");
}

executeMvnCommand(TYCHO_VERSIONS_PLUGIN_SET_GOAL, prop, newVersion, "-Dtycho.mode=maven");
executeMvnCommand(TYCHO_VERSIONS_PLUGIN + ":" + tychoVersionsPluginVersion + ":" + TYCHO_VERSIONS_PLUGIN_SET_GOAL, prop,
newVersion, "-Dtycho.mode=maven");
} else {
boolean runCommand = false;
List<String> args = new ArrayList<>();
args.add("-DgenerateBackupPoms=false");
args.add(newVersion);
if (!skipUpdateVersion) {
runCommand = true;
args.add(VERSIONS_MAVEN_PLUGIN_SET_GOAL);
args.add(VERSIONS_MAVEN_PLUGIN + ":" + versionsMavenPluginVersion + ":" + VERSIONS_MAVEN_PLUGIN_SET_GOAL);
args.add(grp);
args.add(art);
}
Expand All @@ -1157,7 +1176,7 @@ protected void mvnSetVersions(final String version) throws MojoFailureException,
runCommand = true;
getLog().info("Updating property '" + versionProperty + "' to '" + version + "'.");

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

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

executeMvnCommand(VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL, "-DgenerateBackupPoms=false",
executeMvnCommand(
VERSIONS_MAVEN_PLUGIN + ":" + versionsMavenPluginVersion + ":" + VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL,
"-DgenerateBackupPoms=false",
"-Dproperty=" + REPRODUCIBLE_BUILDS_PROPERTY, "-DnewVersion=" + timestamp);
}
}
Expand Down

0 comments on commit 4adbb9a

Please sign in to comment.