Daniel Svensson
05/24/2024, 1:47 PMimplementation(libs.foo) {
exclude("group", "module")
}
But it's still listed in :dependencies task. It's a second in line dependency. So foo depends on bar, and bar has a dependency I want to exclude, is that perhaps the reason? The dependency doesn't reference logback in its code, yet taints the classpath with it.Vampire
05/24/2024, 1:52 PM--scan
URL, it could clarify why the exclude is not effective. Probably it comes in in some other way. The dependencyInsight
task could also help to investigate where it is coming from if you cannot create a build scan.Daniel Svensson
05/24/2024, 1:53 PMconfigurations.all {
exclude("org.slf4j", "slf4j-api")
exclude("ch.qos.logback", "logback-core")
exclude("ch.qos.logback", "logback-classic")
}
Which excludes it fully.Vampire
05/24/2024, 1:54 PMDaniel Svensson
05/24/2024, 1:54 PMVampire
05/24/2024, 1:54 PMDaniel Svensson
05/24/2024, 1:54 PMDaniel Svensson
05/24/2024, 1:54 PMVampire
05/24/2024, 1:55 PMDaniel Svensson
05/24/2024, 1:56 PMDaniel Svensson
05/24/2024, 2:07 PM// scrimage depends on open-gif which incorrectly taints the classpath
// with an old version of logback which no library should ever do as
// it's a logging backend, and in this case it doesn't even reference
// any logback related classes even so nuke it.
@CacheableRule
abstract class OpenGif : ComponentMetadataRule {
override fun execute(context: ComponentMetadataContext) = context.details.allVariants {
withDependencies {
removeAll { it.group in listOf("org.slf4j", "ch.qos.logback") }
}
}
}
dependencies {
components {
withModule<OpenGif>("com.github.zh79325:open-gif")
}
implementation(libs.scrimage.core)
implementation(libs.scrimage.filters)
}
Daniel Svensson
05/24/2024, 2:08 PMwithModule<DependencyKiller>("group:module", listOf("a", "b", "c"))
Vampire
05/24/2024, 2:14 PMHumm... so something like this is the recommended way?Yes. Alternatively you could also do it in the settings script. Or you could use the https://github.com/gradlex-org/jvm-dependency-conflict-resolution plugin which defines many helpful capability rules and provides syntactic sugar over plain component metadata rules.
Is it possible to turn that into something more reusable like:Yes, you can give parameters to metadata rules, this is also covered in the docs I linked you to. Or you just use the plugin I just referenced š
Daniel Svensson
05/24/2024, 2:31 PM