Pretty new to gradle. Using 3.4. I need to allow developers to, in one step, create a new java-application project and then prepopulate the new project with some additional files. I have been working on a custom task and plug-in and I was hoping to leverage the init task (as in “gradle init”).
I have a setup.gradle file that refers to my plug-in and resides in a separate gradle project that is outside the directory where I want to create the new project. The plug-in is defined in a .groovy file under buildsrc in that other project. In the plug-in I make my custom task depend on the automatically-included init task.
When I run “gradle -b /other-dir/setup.gradle myInitTask” gradle starts but then skips the init task:
:init
The build file 'setup.gradle' already exists. Skipping build initialization.
:init SKIPPED
and adding --info to the command line reveals this:
Skipping task ':init' as task onlyIf is false.
I suspect that the init task sees that it is processing a file and therefore skips the task, perhaps assuming that the file is from the project being created.
Any suggestions for working around this or accomplishing this in an entirely different way?