I am trying to automate a release process for a large composite build project. Currently I store the builds that I want to release in a properties file and I want to call a task for every line that I read.
What I have so far
task readFile {
doLast{
for each line in the property file
call another task
}
}
Is there any way to do this? I tried to run the task from this task but it doesn’t work
You can’t “execute” a Task directly.
Gradle Tasks based on the dependsOn schema.
Because of that you need multiple Tasks to archive your goal.
The first one will just read the properties file and create tasks for each of them.
The second one will just run and depends on all generated tasks (which means they will be executed).
The task which reads the properties and create the tasks can be look like this:
This will create a Task for each line inside the properties and prefix them with generatedTask.
This Task can be modified like you want. Maybe you can say that this depends on some other task.
To finally run all the generated Tasks create another task: