Skip to content

Commit

Permalink
Prefer version properties for generated plugin configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
aloubyansky committed Sep 20, 2024
1 parent f76c20e commit 0f84877
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1685,15 +1685,27 @@ private Profile copyReleasePlugins(Profile parentReleaseProfile) {
private Plugin clonePluginConfig(Plugin plugin) {
if (plugin.getVersion() == null) {
final Plugin managedPlugin = project.getPluginManagement().getPluginsAsMap().get(plugin.getKey());
if (managedPlugin == null) {
if (managedPlugin == null || managedPlugin.getVersion() == null) {
getLog().warn("Failed to determine the version for " + plugin.getKey());
} else {
var version = managedPlugin.getVersion();
if (!version.startsWith("$")) {
version = toPropertyOrSelf(version);
}
plugin = plugin.clone();
plugin.setVersion(version);
}
plugin = plugin.clone();
plugin.setVersion(managedPlugin.getVersion());
} else if (!plugin.getVersion().startsWith("$")) {
plugin.setVersion(toPropertyOrSelf(plugin.getVersion()));
}
return plugin;
}

private String toPropertyOrSelf(String version) {
var prop = pomPropsByValues.get(version);
return prop == null ? version : "${" + prop + "}";
}

private static ArtifactCoords toCoords(final Artifact a) {
return ArtifactCoords.of(a.getGroupId(), a.getArtifactId(), a.getClassifier(), a.getExtension(), a.getVersion());
}
Expand Down

0 comments on commit 0f84877

Please sign in to comment.