shadow icon indicating copy to clipboard operation
shadow copied to clipboard

Prevent shadow jar from automatically being added as publish artifact

Open mgroth0 opened this issue 3 years ago • 4 comments

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.

mgroth0 avatar Jul 22 '22 17:07 mgroth0

I have my publication configured like so:

 the<PublishingExtension>().publications.register("mavenJava", MavenPublication::class.java) {
		it.from(components.asMap["java"])
}

mgroth0 avatar Jul 22 '22 17:07 mgroth0

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 avatar Jul 24 '22 20:07 mgroth0

@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.

rjrudin avatar Apr 26 '24 19:04 rjrudin

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 avatar Apr 26 '24 20:04 rjrudin

@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!

mgroth0 avatar May 05 '24 06:05 mgroth0