Remove spring-boot.version property from spring-boot-dependencies

The version of Spring Boot should not be modifiable by a property,
only being using a different version of spring-boot-dependencies or
spring-boot-starter-parent.

Fixes gh-23174
This commit is contained in:
Andy Wilkinson
2020-09-16 18:25:17 +01:00
parent d5234a9254
commit 358b9f839a
5 changed files with 43 additions and 15 deletions

View File

@@ -169,15 +169,18 @@ public class BomExtension {
private void addLibrary(Library library) {
this.libraries.add(library);
this.properties.put(library.getVersionProperty(), library.getVersion());
String versionProperty = library.getVersionProperty();
if (versionProperty != null) {
this.properties.put(versionProperty, library.getVersion());
}
for (Group group : library.getGroups()) {
for (Module module : group.getModules()) {
putArtifactVersionProperty(group.getId(), module.getName(), library.getVersionProperty());
putArtifactVersionProperty(group.getId(), module.getName(), versionProperty);
this.dependencyHandler.getConstraints().add(JavaPlatformPlugin.API_CONFIGURATION_NAME,
createDependencyNotation(group.getId(), module.getName(), library.getVersion()));
}
for (String bomImport : group.getBoms()) {
putArtifactVersionProperty(group.getId(), bomImport, library.getVersionProperty());
putArtifactVersionProperty(group.getId(), bomImport, versionProperty);
String bomDependency = createDependencyNotation(group.getId(), bomImport, library.getVersion());
this.dependencyHandler.add(JavaPlatformPlugin.API_CONFIGURATION_NAME,
this.dependencyHandler.platform(bomDependency));

View File

@@ -168,7 +168,10 @@ public class BomPlugin implements Plugin<Project> {
Node plugin = new Node(plugins, "plugin");
plugin.appendNode("groupId", group.getId());
plugin.appendNode("artifactId", pluginName);
plugin.appendNode("version", "${" + library.getVersionProperty() + "}");
String versionProperty = library.getVersionProperty();
String value = (versionProperty != null) ? "${" + versionProperty + "}"
: library.getVersion().toString();
plugin.appendNode("version", value);
}
}
}

View File

@@ -55,7 +55,8 @@ public class Library {
this.name = name;
this.version = version;
this.groups = groups;
this.versionProperty = name.toLowerCase(Locale.ENGLISH).replace(' ', '-') + ".version";
this.versionProperty = "Spring Boot".equals(name) ? null
: name.toLowerCase(Locale.ENGLISH).replace(' ', '-') + ".version";
this.prohibitedVersions = prohibitedVersions;
}

View File

@@ -103,7 +103,10 @@ public class ExtractVersionConstraints extends DefaultTask {
Object bom = getProject().project(projectPath).getExtensions().getByName("bom");
BomExtension bomExtension = (BomExtension) bom;
for (Library lib : bomExtension.getLibraries()) {
this.versionProperties.add(new VersionProperty(lib.getName(), lib.getVersionProperty()));
String versionProperty = lib.getVersionProperty();
if (versionProperty != null) {
this.versionProperties.add(new VersionProperty(lib.getName(), versionProperty));
}
}
}