Slackbot
11/03/2022, 9:23 AMmelix
11/03/2022, 9:29 AMthis.capability.group == "org.codehaus.groovy" || this.capability.group == "org.codehaus.groovy"
second test should be org.apache.groovy
Dave562
11/03/2022, 9:33 AMVampire
11/03/2022, 9:50 AMresolutionStrategy
due to same capability. Then the resolutionStrategy
should resolve that conflict and you only need to check for the org.apache.group
capability that should then be on both variants in your resolutionStrategy
.Dave562
11/03/2022, 11:29 AM> Could not resolve all files for configuration ':lib:testCompileClasspath'.
> Could not find org.codehaus.groovy:groovy:.
Required by:
project :lib > org.gebish:geb-core:6.0
project :lib > org.gebish:geb-core:6.0 > org.gebish:geb-ast:6.0
project :lib > org.gebish:geb-core:6.0 > org.gebish:geb-waiting:6.0
project :lib > org.gebish:geb-core:6.0 > org.gebish:geb-waiting:6.0 > org.gebish:geb-implicit-assertions:6.0
project :lib > org.gebish:geb-core:6.0 > org.gebish:geb-waiting:6.0 > org.gebish:geb-exceptions:6.0
> Could not find org.codehaus.groovy:groovy-templates:.
Required by:
project :lib > org.gebish:geb-core:6.0
project :lib > org.gebish:geb-core:6.0 > org.gebish:geb-ast:6.0
project :lib > org.gebish:geb-core:6.0 > org.gebish:geb-waiting:6.0
project :lib > org.gebish:geb-core:6.0 > org.gebish:geb-waiting:6.0 > org.gebish:geb-implicit-assertions:6.0
project :lib > org.gebish:geb-core:6.0 > org.gebish:geb-waiting:6.0 > org.gebish:geb-exceptions:6.0
> Could not find org.codehaus.groovy:groovy-macro:.
Required by:
project :lib > org.gebish:geb-core:6.0 > org.gebish:geb-ast:6.0
my configuration:
configurations.configureEach {
resolutionStrategy {
capabilitiesResolution.all {
if (this.capability.group == "org.apache.groovy") {
this.selectHighestVersion()
}
}
}
}
dependencies {
components.all(GroovyVersionAlign::class.java)
testImplementation("org.apache.groovy:groovy-all:4.0.6")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
testImplementation("org.gebish:geb-core:6.0")
}
class GroovyVersionAlign : ComponentMetadataRule {
override fun execute(context: ComponentMetadataContext) = context.details.run {
if (id.group.equals("org.codehaus.groovy")) {
allVariants {
withCapabilities {
addCapability("org.apache.groovy", id.name, id.version)
}
}
}
}
}
Also maybe I oversimplified the question, I need align version of all groovy libraries to same version so if in some project I have only plain groovy library and in some transitive dependency there is groovy-xml I need also groovy-xml to be on the same version. On the simple project I was simply able to make it work by depending on groovy-all without any custom ComponentMetadataRules since new groovy libraries have also capability with codehaus group and thus conflicting during resolution. But if I have only groovy in that module then it failed since there is groovy 4.0.6 and groovy-macro 3.0.12 on the compile classpathVampire
11/03/2022, 1:39 PMaddCapability
, just the resolutionStrategy
. And as they also define the version alignment properly in Groovy 4, you also not need the manual version alignment. If you do the version alignment you should use the non-virtual groovy-bom
though.
So if you know Groovy 4 will be present, this is enough (just tested):
configurations.all {
resolutionStrategy {
capabilitiesResolution.all {
if (capability.group == "org.codehaus.groovy") {
selectHighestVersion()
}
}
}
}
dependencies {
testImplementation("org.apache.groovy:groovy-all:4.0.6")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
testImplementation("org.gebish:geb-core:6.0")
}
If you know for sure you only have Groovy 3, this would be enough:
dependencies {
components.all<GroovyVersionAlign>()
testImplementation("org.apache.groovy:groovy-all:4.0.6")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
testImplementation("org.gebish:geb-core:6.0")
}
class GroovyVersionAlign : ComponentMetadataRule {
override fun execute(context: ComponentMetadataContext) = context.details.run {
if (id.group.equals("org.codehaus.groovy")) {
belongsTo("org.codehaus.groovy:groovy-bom:${id.version}", false)
}
}
}
And if you might have Groovy 3 and 4 or maybe not, then this works:
configurations.all {
resolutionStrategy {
capabilitiesResolution.all {
if (capability.group == "org.codehaus.groovy") {
selectHighestVersion()
}
}
}
}
dependencies {
components.all<GroovyVersionAlign>()
testImplementation("org.apache.groovy:groovy-all:4.0.6")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
testImplementation("org.gebish:geb-core:6.0")
}
class GroovyVersionAlign : ComponentMetadataRule {
override fun execute(context: ComponentMetadataContext) = context.details.run {
if (id.group.equals("org.codehaus.groovy")) {
belongsTo("org.codehaus.groovy:groovy-bom:${id.version}", false)
}
}
}
Dave562
11/03/2022, 2:24 PMtasks.named<GroovyCompile>("compileTestGroovy") {
doFirst {
println(classpath.files.filter {it.name.contains("groovy")}.joinToString("\n") { it.parentFile.parentFile.parentFile.parentFile.name + ":" + it.name })
}
}
then if I have groovy-all:4 then the classpath is like:
org.apache.groovy:groovy-ant-4.0.6.jar
org.apache.groovy:groovy-cli-picocli-4.0.6.jar
org.apache.groovy:groovy-console-4.0.6.jar
org.apache.groovy:groovy-datetime-4.0.6.jar
org.apache.groovy:groovy-docgenerator-4.0.6.jar
org.apache.groovy:groovy-groovydoc-4.0.6.jar
org.apache.groovy:groovy-groovysh-4.0.6.jar
org.apache.groovy:groovy-jmx-4.0.6.jar
org.apache.groovy:groovy-json-4.0.6.jar
org.apache.groovy:groovy-jsr223-4.0.6.jar
org.apache.groovy:groovy-macro-4.0.6.jar
org.apache.groovy:groovy-nio-4.0.6.jar
org.apache.groovy:groovy-servlet-4.0.6.jar
org.apache.groovy:groovy-sql-4.0.6.jar
org.apache.groovy:groovy-swing-4.0.6.jar
org.apache.groovy:groovy-templates-4.0.6.jar
org.apache.groovy:groovy-test-junit5-4.0.6.jar
org.apache.groovy:groovy-test-4.0.6.jar
org.apache.groovy:groovy-xml-4.0.6.jar
org.apache.groovy:groovy-yaml-4.0.6.jar
org.apache.groovy:groovy-4.0.6.jar
org.codehaus.groovy:groovy-3.0.12.jar
if I have only groovy:4 then:
org.apache.groovy:groovy-4.0.6.jar
org.codehaus.groovy:groovy-macro-3.0.12.jar
org.codehaus.groovy:groovy-templates-3.0.12.jar
org.codehaus.groovy:groovy-3.0.12.jar
and just for fun if I have both groovy-all:4 and groovy:4 (compilation fails like with the original message) and classpath is like:
org.apache.groovy:groovy-ant-4.0.6.jar
org.apache.groovy:groovy-cli-picocli-4.0.6.jar
org.apache.groovy:groovy-console-4.0.6.jar
org.apache.groovy:groovy-datetime-4.0.6.jar
org.apache.groovy:groovy-docgenerator-4.0.6.jar
org.apache.groovy:groovy-groovydoc-4.0.6.jar
org.apache.groovy:groovy-groovysh-4.0.6.jar
org.apache.groovy:groovy-jmx-4.0.6.jar
org.apache.groovy:groovy-json-4.0.6.jar
org.apache.groovy:groovy-jsr223-4.0.6.jar
org.apache.groovy:groovy-macro-4.0.6.jar
org.apache.groovy:groovy-nio-4.0.6.jar
org.apache.groovy:groovy-servlet-4.0.6.jar
org.apache.groovy:groovy-sql-4.0.6.jar
org.apache.groovy:groovy-swing-4.0.6.jar
org.apache.groovy:groovy-templates-4.0.6.jar
org.apache.groovy:groovy-test-junit5-4.0.6.jar
org.apache.groovy:groovy-test-4.0.6.jar
org.apache.groovy:groovy-xml-4.0.6.jar
org.apache.groovy:groovy-yaml-4.0.6.jar
org.apache.groovy:groovy-4.0.6.jar
org.codehaus.groovy:groovy-macro-3.0.12.jar
org.codehaus.groovy:groovy-templates-3.0.12.jar
org.codehaus.groovy:groovy-3.0.12.jar
I really don't have idea how this could happen since the capabilities seems to be set correctly but it behaves like there is conflict only for some libraries or even no conflict in the last case...Vampire
11/03/2022, 4:05 PMtestImplementation("org.apache.groovy:groovy-all:4.0.6")
testImplementation("org.codehaus.groovy:groovy:3.0.12")
it works perfectly as expected, but with
testImplementation("org.apache.groovy:groovy-all:4.0.6")
testImplementation("org.gebish:geb-core:6.0")
it does not work properly.
Unless there is some detail I don't see why it works differently there.Vampire
11/03/2022, 4:06 PMcapabilitiesResolution
is only called for org.codehaus.groovy:groovy-macro
and org.codehaus.groovy:groovy-templates
, but not for org.codehaus.groovy:groovy
.Dave562
11/04/2022, 7:14 AMVampire
11/04/2022, 7:47 AMDave562
11/04/2022, 9:53 AMVampire
11/04/2022, 10:13 AM