Skip to content

Commit 68909dd

Browse files
committed
udpate versions (pom and property) in the same run
If versions:set and versions:set-property are launched in separate maven commands, versions:set-property can fail as poms are in an inconsistent state. Attached test case shows a practical use-case where a property is used in dependencyManagement declaration in a multi-module project. If project is not installed, versions:set-property 1.0.1-SNAPSHOT -> 1.0.1 fails as maven tries to resolve dependency 1.0.1-SNAPSHOT in a project already versionned in 1.0.1.
1 parent dd0468b commit 68909dd

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,15 +1017,26 @@ protected void mvnSetVersions(final String version) throws MojoFailureException,
10171017

10181018
executeMvnCommand(TYCHO_VERSIONS_PLUGIN_SET_GOAL, prop, newVersion, "-Dtycho.mode=maven");
10191019
} else {
1020+
boolean runCommand = false;
1021+
List<String> args = new ArrayList<>();
1022+
args.add("-DgenerateBackupPoms=false");
1023+
args.add(newVersion);
10201024
if (!skipUpdateVersion) {
1021-
executeMvnCommand(VERSIONS_MAVEN_PLUGIN_SET_GOAL, grp, art, newVersion, "-DgenerateBackupPoms=false");
1025+
runCommand = true;
1026+
args.add(VERSIONS_MAVEN_PLUGIN_SET_GOAL);
1027+
args.add(grp);
1028+
args.add(art);
10221029
}
10231030

10241031
if (StringUtils.isNotBlank(versionProperty)) {
1032+
runCommand = true;
10251033
getLog().info("Updating property '" + versionProperty + "' to '" + version + "'.");
10261034

1027-
executeMvnCommand(VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL, newVersion, "-Dproperty=" + versionProperty,
1028-
"-DgenerateBackupPoms=false");
1035+
args.add(VERSIONS_MAVEN_PLUGIN_SET_PROPERTY_GOAL);
1036+
args.add("-Dproperty=" + versionProperty);
1037+
}
1038+
if (runCommand) {
1039+
executeMvnCommand(args.toArray(new String[0]));
10291040
}
10301041
}
10311042
}

0 commit comments

Comments
 (0)