-
Notifications
You must be signed in to change notification settings - Fork 429
Constraints result in dependencies being added instead of constraints #710
Comments
Workaround: dependencies {
constraints {
add("implementation", "com.google.collections:google-collections") {
version {
rejectAll()
}
because("Google collections is superceded by Guava")
}
}
} |
@eskatos Do you have some grand solution for this problem in general or is it just to add the API in Kotlin every time issues like this arise in the API. |
@JLLeitschuh no, no grand solution atm 😄 Ad-hoc API additions is the easy way forward. But putting some thinking on this first sounds good. If something comes to you, please share. |
Annotating the Gradle core API and doing code generation at DSL build time popped into my head. |
Just got bitten by this. The worst bit IMO is that it works but does something really different. |
I see that this issue is still open. It's a pretty serious bug, is this planned for 1.0? |
A bit more details about the situation. Let's look at different usage scenario: plugins {
`java-library`
}
// #1 - Using the API
dependencies {
constraints {
add("implementation", "com.google.collections:google-collections") {
version { rejectAll() }
because("Google collections is superceded by Guava")
}
}
}
// #2 - Using existing configuration accessors
dependencies {
constraints {
implementation("com.google.collections:google-collections") {
version { rejectAll() }
because("Google collections is superceded by Guava")
}
}
}
// #3 - Using existing configuration accessors out of the dependencies {} block
dependencies.constraints {
implementation("com.google.collections:google-collections") {
version { rejectAll() }
because("Google collections is superceded by Guava")
}
}
// #4 - Using string invoke operator
dependencies {
constraints {
"implementation"("com.google.collections:google-collections") {
version { rejectAll() }
because("Google collections is superceded by Guava")
}
}
}
// #5 - Using string invoke operator out of the dependencies {} block
dependencies.constraints {
"implementation"("com.google.collections:google-collections") {
version { rejectAll() }
because("Google collections is superceded by Guava")
}
} With Gradle 4.10.x
With #1091
|
There's nothing more we can do specifically for dependency constraints. Closing in favor of https://github.com/gradle/kotlin-dsl/issues/1119 and https://github.com/gradle/kotlin-dsl/issues/1120. |
When I write the following code:
The expectation is that what is added is a constraint. However, it turns out to be adding a dependency instead. If I use the very same file in Groovy, a constraint is added.
Expected Behavior
Extensions methods should be aware of the
constraints
block.Current Behavior
Constraints are created as hard dependencies, breaking the dependency graph.
The text was updated successfully, but these errors were encountered: