I am working on an Android project which uses a Gradle task with command line parameters. The task should be called from command line like that:
gradlew myTask -Parg1=aaa
Instead of calling it from command line I want to call this task from a Gradle file where I have all the arguments in a list. I need to create another task which runs myTask
in a loop with all the arguments. By following this example I created the following code:
def data=['1', '2', '3']
project.task('runAll') {
data.collect { count ->
project.task('run_' + count, type: GradleBuild) {
startParameter.projectProperties = ['arg1': count]
tasks = ['myTask']
}.name
}.forEach { name ->
dependsOn name
}
}
When running individual tasks run_1
, run_2
, and run_3
everything works fine. If I run runAll
, run_1
finishes successfully, but run_2
and run_3
crashes with the following error:
Included build C:\Projects\MyAwesomeApp\app has build path :app which is the same as included build C:\Projects\MyAwesomeApp\app
Can you help me solve this error?
buildName
help? – TacodependsOn name
which may depends on itself. Maybe you should debug this and share more info ? Or I suggest you to create your tasks and then create arunAll
task with GradleBuild API that call an array of your tasks... not a dependency... – Mcdowell