gradle-resolution-rules-plugin
gradle-resolution-rules-plugin copied to clipboard
Conflict with Gradle kotlin-dsl plugin
When writing Gradle plugins that use Kotlin DSL there is a conflict w/ resolution-rules, resulting in this error:
Cannot change attributes of dependency configuration ':apiElements-published' after it has been resolved
The issue is related to the order of the plugins - changing kotlin-dsl to be following resolution-rules works. Considering this a workaround (at best) as it may not always be an option and indicates some underlying fragility.
This minimal build script reproduces the issue (build.gradle.kts)
plugins {
// if kotlin-dsl plugin is loaded first that results in this error:
// Cannot change attributes of dependency configuration ':apiElements-published' after it has been resolved
// flipping the order is works as expected
`kotlin-dsl`
id("nebula.resolution-rules") version "9.0.0"
}
repositories {
mavenCentral()
}
dependencies {
resolutionRules("com.netflix.nebula:gradle-resolution-rules:latest.release")
}
Reproducible on Gradle 7.1.1 thru 7.3.2 (earlier versions were not tested). Reproducible on resolution-rules v9.0.0 (v8.0.0 works)