Prevent shadow jar from automatically being added as publish artifact
I've noticed that if a Project applies the ShadowJar plugin, that shadow jars are automatically added to the maven publication. I do not want this. I read the docs on maven publishing but it was confusing and didn't seem to explain how to disable shadow jars from automatically being added as artifacts in publications.
I have my publication configured like so:
the<PublishingExtension>().publications.register("mavenJava", MavenPublication::class.java) {
it.from(components.asMap["java"])
}
I've been able to successfully remove the shadow jars from the maven publications by manually removing them from the artifacts of the publication. But I cannot remove the task dependency. publishMavenJavaPublicationToMavenLocal and generateMetadataFileForMavenJavaPublication continue to depend on the shadowJar task, forcing it to execute even when not needed.
@mgroth0 Did you find any solution for this? Ran into the same thing today, would like to prevent the shadow jar from being published but cannot find a mechanism for doing so.
Looks like this incantation does the trick - https://github.com/johnrengelman/shadow/issues/586#issuecomment-708375599 .
This ticket can likely be closed as a duplicate of #586, which is still requesting that the publication of the shadow jar not be enabled by default.
@rjrudin Thanks for following up on this.
I no longer apply the shadow plugin in any of my modules that are publishing to a maven repo. This has been my workaround all this time, which is not ideal.
Looking at my old comment, I think the main problem for me ended up being the task dependency. shadowJar is an expensive task and I am publishing to mavenLocal very often so I can't always be running shadowJar.
I will close this in favor of #586. Thanks!