Calling multiple nested tasks of type:GradleBuild

I am updating from Gradle 2 to Gradle 6. For the most part, my builds work fine, after some syntax changes. However, I am running into an issue when my build.gradle file has multiple nested task of the type GradleBuild.

A Simplified example:

   
#SessionBeanJar is a task of type Jar
#ServletWar is a task or type War

task backendBeans(type: GradleBuild) {
    startParameter.projectProperties = gradle.startParameter.projectProperties
    tasks = [ 'SessionBeanJar1',  'SessionBeanJar2' ]
}

task backendServlets(type: GradleBuild) {
    startParameter.projectProperties = gradle.startParameter.projectProperties
    tasks = [ 'ServletWar1', 'ServletWar2' ]
}

task backendBuildError(type: GradleBuild) {
    startParameter.projectProperties = gradle.startParameter.projectProperties
    tasks = ['backendBeans', 'backendServlets', 'tarGF', 'publishGF']
}

task backendBuildFine(type: GradleBuild) {
    startParameter.projectProperties = gradle.startParameter.projectProperties
    tasks = ['backendBeans', 'ServletWar1', 'ServletWar2', 'tarGF', 'publishGF']
}

If I run the task backendBuildError I receive the following error

Included build /Users/db/Docs/workspace/backendsubsystems has build path :backendsubsystems:backendsubsystems which is the same as included build /Users/db/Docs/workspace/backendsubsystems

However, if I run the task backendBuildFine everything runs and completes without any issues.

It seems that only one task of type GradleBuild is allowed to do any work. Any subsequent task to type GradleBuild cause the above error. Is there a way to do what the backendBuildError task is doing? Or, Do i have to define all the work tasks in a single GradleBuild task?

I’m a little confused since none of your GradleBuild tasks are setting the buildFile property. The GradleBuild task is usually used to invoke tasks in another separate build rather than the current build. But in your case it seems that all the referenced tasks are within the current build?

Am I correct that the following:

task backendBeans(type: GradleBuild) {
    startParameter.projectProperties = gradle.startParameter.projectProperties
    tasks = [ 'SessionBeanJar1',  'SessionBeanJar2' ]
}

Could be rewritten as

task backendBeans {
    dependsOn [ 'SessionBeanJar1',  'SessionBeanJar2' ]
}

Perhaps I’m missing something

You are absolutely correct. It seems what I really needed was a generic Task to “group” a collection of other tasks. It did not occur to use the DepensOn method

I did not believe that having a bunch of GradleBuild tasks was correct. Under Gradle 2 it seems it wasn’t much of a concern.

Thank you

what I really needed was a generic Task to “group”

These are known as lifecycle tasks

Under Gradle 2 it seems it wasn’t much of a concern.

The change in behavior was possibly caused by the composite build feature