I'm looking for some automatic/simple way to exclude all dependencies from the final jar if they are already contained in any of compile-only depenceny which isn't present in the final jar but is loaded externally. I'm using kotlin DSL for gradle configuration.
my current jar configuration:
withType<Jar> { duplicatesStrategy = DuplicatesStrategy.EXCLUDE archiveClassifier.set("core") from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) }) exclude( "kotlin/**" ) } For example I implement jackson yaml format which uses snake YAML as a dependency. However snake YAML is also present in one compileOnly dependency and shouldn't be contained in the final JAR.
If I understand it correctly runtimeClasspath contains only implementation dependencies, but also all of their dependencies, which is the problem