Publishing plugin with other jars from a multi-project plugin

plugins

(Szczepan Faber) #1

Hey guys!

The ease of publishing plugins to the portal is amazing. Thank you!

I’m trying to restructure my plugin code and move from a single-project to a multi-project build. The multi-project build will have some subprojects that aren’t Gradle plugins, they are plain java libraries. Questions:

  1. Can I use com.gradle.plugin-publish-plugin to publish all jars from multi-project build? Some subprojects in the build are not Gradle plugins but they are dependencies of the Gradle plugin.
  2. Assuming that above is not supported (I didn’t find documentation), what is your recommendation for this use case? Should I configure publication in java subprojects and (for example) use bintray plugin to push java libraries to jcenter?

(Szczepan Faber) #2

Given that there is no reply, I’m assuming that there is no way to publish many jars to the portal. That’s ok. I also assume that it is not in the plans of the portal to support this use case.

We are developing Continuous Delivery Toolkit and we should be able to address this use case.

Thanks again for the portal, it makes it really easy to publish plugins!!!


(Tom Dunstan) #3

Hi Szczepan! Apologies for missing this the first time around.

It’s not currently possible to upload artifacts that have a different set of Group/Artifact Id/Version coordinates to the plugin.

This basically leaves you with 2 options:

  • Publish the dependencies separately as you suggested. Anywhere that ends up on JCenter will work for build scripts using the plugins {} DSL, though builds using the buildscript { dependencies { classpath } } declaration method will need to add jcenter() into their buildscript repositories.
  • Bundle them into a fat jar and upload that as the plugin jar (this is what we have done for a couple of ours)

I can provide a recipe for the latter if you need it. I personally would generally recommend the far jar approach unless you’re intending to use the classes from the subprojects in multiple plugins that could be applied together and may be used in a non-isolated way.

Regards

Tom


(Szczepan Faber) #4

Thank you for reply and the recommendations! All makes sense. Right now I think we’ll go down the path of separately publishing to JCenter, because we want Mockito Release Tools to be also usable as a library (e.g. not only as Gradle plugin).