How to create a gradle task that calls many other gradle tasks including calling the same one multiple times with different parameters

Viewed 71

I know you can create a task like:

    task 'test'(type: GradleBuild) {
            tasks = ['test1','test2','test3']
    }

to call multiple tasks from one but if I needed to call test1 twice but with different start parameters each time how would I do it?

I have tried:

task 'testA'(type: GradleBuild) {
    doLast() {
        tasks = ['test1']
        startParameter.projectProperties = gradle.startParameter.projectProperties + ['param': 'A']
    }
}

task 'testB'(type: GradleBuild) {
    doLast() {
        tasks = ['test1']
        startParameter.projectProperties = gradle.startParameter.projectProperties + ['param': 'B']
    }
}

task 'testZ'(type: GradleBuild) {
        tasks = ['testA','testB']
}

But that yields:

* What went wrong:
Execution failed for task ':src:testB'.
> Included build <buildpath> has build path :src:src which is the same as included build <buildpath>

Does anyone have a solution for this?

0 Answers
Related