Build failed after adding specific behavior to a nested subproject

Hello, I’m working with a nested sub projects project and I have an issue:

I have the following files structure:

projectRoot/ |-- build.gradle |-- compA |

|-- build.gradle |

|-- settings.gradle |

'-- subCompB |-- settings.gradle


project(':subCompB') {
  task myTask << {
    println "hello"


include 'compA', 'compA:subCompB'


include 'subCompB'

I’m adding specific behavior to subCompB (as stated in section 56.2.2 from the user guide), creating a task.

But I get this error: FAILURE: Build failed with an exception.

  • Where: Build file ‘/scratch/sandbox/projectRoot/compA/build.gradle’ line: 3

  • What went wrong: A problem occurred evaluating project ‘:compA’. > Project with path ‘:subCompB’ could not be found in project ‘:compA’.

The weird thing is that everything seems to work if I remove the colon ‘:’ in compA/build.gradle to:

project('subCompB') {

Other tasks '----------- compA:subCompB:myTask


Root project '------------------------

Root project ‘projectRoot’ '— Project ‘:compA’ ’

— Project ‘:compA:subCompB’

What am I doing wrong?


You can only have one settings file for a build.