GradleBuild changes path for invoked tasks

In my root build.gradle, I’ve defined a GradleBuild task like this:

project.task('distribute', type : GradleBuild) {

    startParameter = gradle.startParameter.newInstance()
    tasks = [":subprojectA:displayInfo"]

Given that my root project directory called root,
when I run the distribute task, the task that is executed is


How is it that root becomes what looks like a subproject and why does the gradle build task not execute the correct task like this:


Just me somethings somethings from previous experience when using GradleBuild

  • I always explicitly set the projectDir. (In your case set it to where subprojectA is located).
  • I don’t override startParameter in the way you do. It has never worked for me in the past.

Here’s an example of a more complex GradleBuild invocation if it is on any help: