hi, I want to share a gradle task in a bunch of se...
# community-support
b
hi, I want to share a gradle task in a bunch of separate local repositories, specifically • copy various files into a zip (modifying a couple files beforehand) • push a new git tag • create and upload release zip on github • register new release through a REST API I've already achieved that by having a task that changes the files, a zip task that depends on said task and a task that pushes and uploads the release; Questions: • I'd like to have all of that together in one task; is that a good idea? How do I reuse the zip task in my own plugin • What's the best way to distribute that task locally? Is the way forward to mvn install? Missing the steps in between I guess?
1
v
Why would your want one task? A task that does one focused task is usually a good idea, also because it can be up to date or cached individually. But if you want to have I've task for whatever reason, just do it. As there is no zip helper method, you would want to subclass the task maybe, or if it is in a plugin just add
doLast
and
doFirst
actions, but make sure to also register inputs and outputs properly. Or you just use some own zip logic using standard Java API or some library to create the zip. Using Maven Local to share the task is not really a great idea, as Maven Local is broken by design in Maven already. So if you really need a to, is some dedicated directory based repo instead, or just use composite builds if the Gradle versions are compatible (optimally equal).
b
I ended up preconfiguring a zip task in the plugin class; users should be able to override/extend it by name; the other tasks remain split up but strung together using sensible parent tasks
as for local maven: got that to work for testing reasons, will probably publish to the plugin registry once it works
v
But even for testing you should use composite build if possible, it is the actual original use-case. The included build is automatically built if necessary and you get both projects opened in IDE automatically with proper navigation and so on. 😀