Publish a runtime variant that supports Java 22
In order to support Java 22, we must use spring-core 6.1.x. spring-core 6.1.x is a multi-release jar so, in order to support Java 22, a version of Gradle that supports multi-release jars must be used. This commit adds a new variant to spring-boot-gradle-plugin for modern versions of Gradle. When Gradle's plugin API version is 8.7 or later, we use spring-core 6.1.x. spring-core 6.0.x is used at all other times. Closes gh-40074
This commit is contained in:
@@ -15,7 +15,34 @@ configurations {
|
||||
// Downgrade SLF4J is required for tests to run in Eclipse
|
||||
resolutionStrategy.force("org.slf4j:slf4j-api:1.7.36")
|
||||
}
|
||||
all {
|
||||
modernGradleRuntimeClasspath {
|
||||
extendsFrom runtimeClasspath
|
||||
canBeConsumed = false
|
||||
canBeResolved = true
|
||||
}
|
||||
modernGradleRuntimeElements {
|
||||
extendsFrom configurations.implementation, configurations.runtimeOnly
|
||||
canBeConsumed = true
|
||||
canBeResolved = false
|
||||
attributes {
|
||||
attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category, Category.LIBRARY))
|
||||
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling, Bundling.EXTERNAL))
|
||||
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
|
||||
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, LibraryElements.JAR))
|
||||
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage, Usage.JAVA_RUNTIME))
|
||||
attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, project.objects.named(GradlePluginApiVersion, "8.7"))
|
||||
}
|
||||
outgoing.artifacts.addAll(configurations.runtimeElements.outgoing.artifacts)
|
||||
}
|
||||
runtimeElements {
|
||||
attributes {
|
||||
attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, project.objects.named(GradlePluginApiVersion, "7.5"))
|
||||
}
|
||||
}
|
||||
all { configuration ->
|
||||
if (configuration.name == 'modernGradleRuntimeClasspath') {
|
||||
return
|
||||
}
|
||||
resolutionStrategy {
|
||||
eachDependency { dependency ->
|
||||
// Downgrade Jackson as Gradle cannot cope with 2.15.0's multi-version
|
||||
@@ -44,6 +71,10 @@ configurations {
|
||||
}
|
||||
}
|
||||
|
||||
components.java.addVariantsFromConfiguration(configurations.modernGradleRuntimeElements) {
|
||||
mapToMavenScope("runtime")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
asciidoctorExtensions("io.spring.asciidoctor:spring-asciidoctor-extensions-section-ids")
|
||||
|
||||
@@ -166,3 +197,18 @@ artifacts {
|
||||
toolchain {
|
||||
maximumCompatibleJavaVersion = JavaLanguageVersion.of(20)
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications.matching { it.name == 'pluginMaven' }.configureEach {
|
||||
versionMapping {
|
||||
allVariants {
|
||||
fromResolutionOf(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME)
|
||||
}
|
||||
}
|
||||
versionMapping {
|
||||
variant(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, project.objects.named(GradlePluginApiVersion, "8.7")) {
|
||||
fromResolutionOf("modernGradleRuntimeClasspath")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user