Jonas Konrad
12/03/2025, 8:35 AM% ./gradlew run
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve org.lz4:lz4-java:1.8.1.
Required by:
root project :
> Module 'org.lz4:lz4-java' has been rejected:
Cannot select module with conflict on capability 'org.lz4:lz4-java:1.8.1' also provided by [at.yawk.lz4:lz4-java:1.8.1(apiElements)]
> Could not resolve at.yawk.lz4:lz4-java:1.8.1.
Required by:
root project : > org.lz4:lz4-java:1.8.1
> Module 'at.yawk.lz4:lz4-java' has been rejected:
Cannot select module with conflict on capability 'org.lz4:lz4-java:1.8.1' also provided by [org.lz4:lz4-java:1.8.1(compile)]
poc: https://github.com/yawkat/test-case-gradle-rename-capability
is this a bug or is the metadata not supposed to be used this way?Vampire
12/03/2025, 9:46 AMThomas Broyer
12/03/2025, 10:26 AMJonas Konrad
12/03/2025, 10:28 AMJonas Konrad
12/03/2025, 10:30 AMVampire
12/03/2025, 10:34 AMVampire
12/03/2025, 10:35 AMVampire
12/03/2025, 10:35 AMVampire
12/03/2025, 10:35 AMVampire
12/03/2025, 10:38 AMso that gradle properly detects the case where both org.lz4lz4 java1.7.0 and at.yawk.lz4lz4 java1.8.1 are on the classpath and only selects the latter one.This will not work automatically. In that case the will get a capability conflict and define how to resolve it. Gradle can for example now know whether the new coordinates start with v1 again and always the new coordinates are used or whether the versions continue to count and then new version should be used. So in that situation the user indeed has to define how to resolve the conflict. But by only depending on the relocated artifact, that does imho not make sense.
Thomas Broyer
12/03/2025, 10:40 AMThomas Broyer
12/03/2025, 10:49 AMJonas Konrad
12/03/2025, 11:11 AMThomas Broyer
12/03/2025, 11:14 AMJonas Konrad
12/03/2025, 11:16 AMThomas Broyer
12/03/2025, 11:19 AMVampire
12/03/2025, 11:19 AMVampire
12/03/2025, 11:20 AMVampire
12/03/2025, 11:21 AMVampire
12/03/2025, 11:22 AMi wonder what will happen if a gradle project depends on a maven project which in turn depends on org.lz4lz4 java1.8.1. i guess this issue could "poison" an entire dependency tree for gradleDoesn't matter, Maven is not in play at resolution time. At resolution time only Gradle is at work and the same like now will happen. It resolves
org.lz4:lz4-java:1.8.1, finds and follows the relocation, there finds the capability and will fail.Vampire
12/03/2025, 11:23 AMJonas Konrad
12/03/2025, 11:23 AMJonas Konrad
12/03/2025, 11:24 AMVampire
12/03/2025, 11:24 AMVampire
12/03/2025, 11:25 AMVampire
12/03/2025, 11:25 AMJonas Konrad
12/03/2025, 11:26 AMVampire
12/03/2025, 11:34 AMconfigurations.configureEach {
resolutionStrategy {
capabilitiesResolution {
withCapability("org.lz4:lz4-java") {
selectHighestVersion()
}
}
}
}
That would be in the typical situation (old version in old coords and new version in new coords).
But in that situation you can for example filter by group, this works, just tested:
configurations.configureEach {
resolutionStrategy {
capabilitiesResolution {
withCapability("org.lz4:lz4-java") {
select(candidates.first { (it.id as ModuleComponentIdentifier).group == "at.yawk.lz4" })
}
}
}
}Vampire
12/03/2025, 11:36 AMVampire
12/03/2025, 11:37 AMJonas Konrad
12/03/2025, 11:54 AMJonas Konrad
12/03/2025, 11:56 AM