I’m writing a Gradle plugin that depends on another module in the project. However this module isn’t published to any repository, so I shade it and deploy the shaded jar (with shadow). The problem, however is that the dependency stays in the pom and module files created by the maven-publish plugin (and I presume are there behind the scenes on the Gradle Plugin Portal).
Is there an easy way out here? I managed to remove the dependencies from the pom via
withDependencies {
it.clear()
}
but that doesn’t remove them from the module file, so my error persists.
You could put the shaded dependency in a different configuration. Eg:
configurations {
shademe
}
dependencies {
shademe 'foo:shademe:1.0'
compile files({tasks.shadowJar})
}
// shadow syntax might be slightly different to this but you get the idea
task shadowJar(type: ShadowJar) {
from configurations.shademe
into "$buildDir/shaded.jar"
}
Typically you will shade a jar because you have a good reason for this jar NOT to participate in dependency resolution. So you manipulate the classes to move them to a new package then include the repackaged jars inside your own jar. This means its possible for two or more versions of the classes on the classpath (since packages are different). I’ve often seen this with ASM.
Unless you’ve got a good reason why these jar(s) should NOT be participating in dependency resolution I don’t believe you should be shading them at all