Ruth
07/29/2024, 10:09 AMdependencies {
constraints {
api("net.logstash.logback:logstash-logback-encoder") {
version {
strictly("[7,9)")
prefer("7.4")
}
}
}
api("net.logstash.logback:logstash-logback-encoder")
}
In my app I am then declaring:
dependencies{
runtimeOnly("net.logstash.logback:logstash-logback-encoder:8.0")
}
I also enabled the failOnVersionConflict() and my gradle version is 8.9
My expectation is, that the dependency gets resolved to 8.0 as the library restricts the version between 7 (inclusive) and 9 (exclusive), and only if no other versions are specified it should take version 7.4,
Instead I get a dependency conflict:
Dependency resolution failed because of conflict on the following module:
- net.logstash.logback:logstash-logback-encoder between versions 8.0 and 7.4
net.logstash.logback:logstash-logback-encoder:8.0
Variant runtime:
| Attribute Name | Provided | Requested |
|------------------------------------|--------------|--------------|
| org.gradle.status | release | |
| org.gradle.category | library | library |
| org.gradle.libraryelements | jar | jar |
| org.gradle.usage | java-runtime | java-runtime |
| org.gradle.dependency.bundling | | external |
| org.gradle.jvm.environment | | standard-jvm |
| org.gradle.jvm.version | | 21 |
| org.jetbrains.kotlin.platform.type | | jvm |
Selection reasons:
- By constraint
- By conflict resolution: between versions 8.0 and 7.4
net.logstash.logback:logstash-logback-encoder:8.0
\--- runtimeClasspath
net.logstash.logback:logstash-logback-encoder -> 8.0
\--- library:2024-07-29T11-44-27
\--- runtimeClasspath (requested library:+)
net.logstash.logback:logstash-logback-encoder:{strictly [7,9); prefer 7.4} -> 8.0
\--- library:2024-07-29T11-44-27
\--- runtimeClasspath (requested library:+)Vampire
07/29/2024, 5:57 PMrequire means X or higher
prefer means X or higher or lower, I don't care, but use X if not otherwise defined
But you still have a conflict between 7.4 and 8.0 and configured it to fail on such a conflict.
If you think this is a bug, you should open a bug report, but I guess this is intentional and the expected behavior.Ruth
07/30/2024, 6:33 AMbut I define it otherwise, so I am very confused why this leads to a conflict. Thanks, I will open a bug ticket then 🙂means X or higher or lower, I don't care, but use X if not otherwise definedprefer
Ruth
07/30/2024, 8:01 AM