So I need some advice on constructing a gradle build / plugin. I have a huge project I need to integrate some tasks into so it can be run in a CI environment and also deploy to a live production server.
Currently I have these tasks defined in a build.gradle file with a bunch of methods to do various things but this is getting messy and there is still a lot more to add.
I have decided to solve this by making a custom plugin which will do a lot of the work but need some advice on how to construct it.
I need to have a bunch of tasks which some rely on others.
The tasks I need to set out are:
Deploy
Build
Change values in a .properties file
The tasks need to rely on each other in that order but also have the ability to be run separately. I also need a parameter passed to each task my plan is to use @Option to do this, is this recommended? (any other way?)
The full process calling Deploy should do the following…
Deploy <> Build <> Change Values
How should this be setup, should I use build.dependsOn changeValues?
Also one other quick question, how do I make a gradle plugin call the “build” task (I think this is part of the Java plugin?) when I added “taskX.dependsOn build” it said that it couldn’t find the “build” task?
Also one other quick question, how do I make a gradle plugin call the “build” task (I think this is part of the Java plugin?)
It’s being added by the JavaBasePlugin. The JavaPlugin internally applies the JavaBasePlugin. You are relying on the build task then you can apply the JavaBasePlugin in your plugin.
Generally speaking I’d recommending reading the following topical guides on plugin development: