I have needed to shade my Gradle plugin so that the final artifact is being created by my ShadowJar task instead of the jar task. (My plugin is not a “fat jar”. I went to considerable effort to ensure that only a particular dependency was being shaded, and that the rest - including gradleApi and localGroovy are still transitive dependencies.)
My next task is to publish this plugin to the Gradle Plugin Portal using com.gradle.plugin-publish. However, I can’t see any way of telling the publish-plugin which jar it should be publishing. Does it publish the output from all jar tasks, please? Or just the artifact without a classifier? Or is there an extension to configure all this behaviour somewhere?
The plugin will publish a jar found in the archives configuration. By default this is the jar produced by the default jar task, but can be changed by clearing out the archives artifacts and adding back in what you would like to publish.
I’ve been testing this, and it has indeed published my plugin and its sources into the Portal. However, the POM it has created isn’t the same as the one created by the maven-publish plugin. The Portal’s one also contains a runtime dependency on the jar that I have shaded, and so causes resolution errors when I try to use the plugin in projects.
However, the publish-plugin seems to have ignored all of this and used the full set of the implementation dependencies instead, including the unwanted internal-jar-project.jar.
Can you help me fix the published POM dependencies please?
Thanks,
Chris
Edit: FWIW, I’ve now modified my project better to leverage the shadow plugin functionality, where shadow here is an extension object: