From 3c2c26800601be4ce3aa6c5fff2222d6869f1e95 Mon Sep 17 00:00:00 2001 From: Ben Manes Date: Mon, 20 Feb 2023 13:27:11 -0800 Subject: [PATCH] Set JVM attribute on copied configuration (#727) --- .../benmanes/gradle/versions/updates/Resolver.kt | 10 ++++++++++ gradle.properties | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gradle-versions-plugin/src/main/kotlin/com/github/benmanes/gradle/versions/updates/Resolver.kt b/gradle-versions-plugin/src/main/kotlin/com/github/benmanes/gradle/versions/updates/Resolver.kt index e792c676..cb03b578 100644 --- a/gradle-versions-plugin/src/main/kotlin/com/github/benmanes/gradle/versions/updates/Resolver.kt +++ b/gradle-versions-plugin/src/main/kotlin/com/github/benmanes/gradle/versions/updates/Resolver.kt @@ -25,6 +25,7 @@ import org.gradle.api.artifacts.repositories.MavenArtifactRepository import org.gradle.api.artifacts.result.ResolvedArtifactResult import org.gradle.api.attributes.Attribute import org.gradle.api.attributes.HasConfigurableAttributes +import org.gradle.api.attributes.java.TargetJvmVersion; import org.gradle.api.internal.artifacts.DefaultModuleVersionIdentifier import org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependencyConstraint import org.gradle.api.specs.Specs.SATISFIES_ALL @@ -143,6 +144,8 @@ class Resolver( addRevisionFilter(copy, revision) addAttributes(copy, configuration) addCustomResolutionStrategy(copy, currentCoordinates) + + disableAutoTargetJvm(copy) return copy } @@ -192,6 +195,12 @@ class Resolver( return nonTransitiveDependency } + private fun disableAutoTargetJvm(configuration: Configuration) { + // Disable the auto target jvm for the configuration + // https://github.com/ben-manes/gradle-versions-plugin/issues/727#issuecomment-1427132589 + configuration.attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, Integer.MAX_VALUE); + } + /** Adds the attributes from the source to the target. */ private fun addAttributes( target: HasConfigurableAttributes<*>, @@ -256,6 +265,7 @@ class Resolver( val coordinates = hashMapOf() val copy = configuration.copyRecursive().setTransitive(transitive) + disableAutoTargetJvm(copy) val lenient = copy.resolvedConfiguration.lenientConfiguration val resolved = lenient.getFirstLevelModuleDependencies(SATISFIES_ALL) diff --git a/gradle.properties b/gradle.properties index dce12a0f..da0df19c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ GROUP=com.github.ben-manes -VERSION_NAME=0.45.0 +VERSION_NAME=0.46.0 POM_INCEPTION_YEAR=2012 POM_PACKAGING=jar