bintray / gradle-bintray-plugin

Apache License 2.0
1.28k stars 197 forks source link

Make BintrayPublishTask more friendly (have to use reflection) #326

Open natario1 opened 4 years ago

natario1 commented 4 years ago

Hi, In order to support publishing multiple packages from the same Gradle subproject, I have to use BintrayUploadTask directly instead of configuring the extension.

https://github.com/natario1/MavenPublisher/blob/81f3f070d9e4f2cd6a211b13b4e525172c71d144/publisher/src/main/kotlin/com/otaliastudios/tools/publisher/bintray/BintrayPublicationHandler.kt#L53-L76

It works fine, but the artifact is not really published in the Bintray website - you have to manually go there and approve it. This is because we also need to run a BintrayPublishTask.

But currently there is no way to run BintrayPublishTask with our own BintrayUploadTask, so I have to use reflection on the publishVersion() method like so:

https://github.com/natario1/MavenPublisher/blob/81f3f070d9e4f2cd6a211b13b4e525172c71d144/publisher/src/main/kotlin/com/otaliastudios/tools/publisher/bintray/BintrayPublicationHandler.kt#L78-L86

This is really dirty and I would like to avoid it in the long run. Can BintrayPublishTask be rewritten in such a way that it can be run on user provided BintrayUploadTask ? It could be as simple as having it accept a list of input upload tasks. If list is empty, it could fallback to the default behavior of finding tasks by name.

Without this small fix, the Bintray Gradle Plugin can literally only be used from the extension, which means one package per subproject.

dubinsky commented 4 years ago

@natario1 it's actually one package per subproject: you can have multiple subprojects in the same Gradle project, each (or at least more than one) of them publishing to Bintray (see here for some caveats and tricks)

natario1 commented 4 years ago

Thanks - edited my request.

dubinsky commented 4 years ago

@natario1 I do not work for Bintray, so editing your request won't help :) I merely meant to suggest that to avoid contortion you describe, you may want to try splitting your project into subprojects in such a way that each subproject publishes no more than one package, and then you can configure the plugin normally, using the extension...

natario1 commented 4 years ago

My edit makes it clear that I want to publish multiple packages from the same subproject. Which right now is possible (see links in original post), but only with a reflection call. By changing just a few lines in BintrayPublishTask, this behavior could be allowed in a more elegant way.

The design of this plugin does not cover many use-cases in the public API (the extension), but at least the plugin internals (like BintrayPublishTask) could be made open enough for advanced usages (like mine) to happen without weird tricks.