Could not resolve project

Hey.
My project structure is something like.

/A
/B/C
/B/D

Project A depends on C and D and D depends on C.
In settings.gradle of project A I have declared

rootProject.name = 'A'
include ':C', ':D'
project(':C').projectDir = new File(settingsDir, '../B/C')
project(':D').projectDir = new File(settingsDir, '../B/D')

and in the build.gradle of project A

implementation project(':C')
implementation project(':D')

It seems ok for project C, while for project D I get

Could not resolve project :D.
     Required by:
         project :
      > Unable to find a matching configuration of project :D:
          - None of the consumable configurations have attributes.

Project A build.gradle

plugins {
    id 'java'
    id "io.freefair.lombok" version "5.0.0-rc6"
    id 'eclipse'
}

apply plugin: 'java'
apply plugin: 'eclipse'

repositories {
    mavenCentral()
}

sourceSets {
    main {
        java {
            srcDirs = [ 'src/main', 'generated-sources/rpc-java' ]
        }
    }

	test {
        java {
            srcDirs = [ 'src/test' ]
        }
    }
}

dependencies {
	implementation project(':C')
	implementation project(':D')
	compileOnly "com.google.code.findbugs:jsr305:3.0.2"
	compileOnly "org.eclipse.jdt:org.eclipse.jdt.annotation:2.2.100"
	testCompileOnly	"org.eclipse.jdt:org.eclipse.jdt.annotation:2.2.0"
}

compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

Project C build.gradle

plugins {
    id 'java'
}

apply plugin: 'java'
apply plugin: 'eclipse'
repositories {
    mavenCentral()
}

ext {
    nettyVersion = '4.1.21.Final'
}

dependencies {
	implementation"io.netty:netty-buffer:${nettyVersion}"
	implementation"io.netty:netty-codec:${nettyVersion}"
	implementation"io.netty:netty-common:${nettyVersion}"
	implementation"io.netty:netty-handler:${nettyVersion}"
	implementation"io.netty:netty-resolver:${nettyVersion}"
	implementation"io.netty:netty-transport:${nettyVersion}"
	compileOnly "javax.servlet:javax.servlet-api:3.1.0"
	testImplementation "junit:junit:4.13"
	implementation"org.msgpack:msgpack-core:0.8.19"
	testCompileOnly "org.hamcrest:hamcrest-core:1.3"


	compileOnly "org.eclipse.jdt:org.eclipse.jdt.annotation:2.2.100"
	testCompileOnly	"org.eclipse.jdt:org.eclipse.jdt.annotation:2.2.0"
	testImplementation "org.apache.commons:commons-lang3:3.9"
}

compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

jar {
  from {
    configurations.runtimeClasspath.findAll { it.name.endsWith('jar')}.collect { zipTree(it) }
  }
  from sourceSets.test.output
}

Project D build.gradle

plugins {
    id 'java'
}
repositories {
    mavenCentral()
}
apply plugin: 'java'
apply plugin: 'eclipse'

dependencies {
	
    implementation project(':C')
    testImplementation "junit:junit:4.13"
	testCompileOnly "org.hamcrest:hamcrest-core:1.3"
        compileOnly "org.eclipse.jdt:org.eclipse.jdt.annotation:2.2.100"
	testCompileOnly	"org.eclipse.jdt:org.eclipse.jdt.annotation:2.2.0"
	testImplementation  "io.reactivex.rxjava2:rxjava:2.2.7"
	testImplementation  "org.slf4j:slf4j-api:1.7.30"
	testImplementation  "org.slf4j:slf4j-log4j12:1.7.30"
}


compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

Project D settings.gradle

rootProject.name = 'D'
include ':C''
project(':C').projectDir = new File(settingsDir, '../C')

Each of the projects have their own settings.gradle file.
Anything I should do in the settings or build file of any of those projects?
Using gradle 6.3 and AdoptOpenJDK 8.0.242

It doesn’t seem like you’ve provided exact code as you should have a different error if the line

include ':C', ':D',

actually has that comma at the end of it.

You also haven’t shown the application of any plugins, but for implementation to be working, you’re likely using the java plugin in A. If the C dependency is first as shown, C also likely applies the java plugin, but D does not.

:roll_eyes: @jjustinic please see edited question. I have now included the scripts you’ve mentioned, maybe that will clarify a little :slight_smile:

Well, it turned out that the issue was with the typo in path of D project in settings.gradle.
Even if so, could the output be a little more verbose if build.gradle file was not found in the desired location? The error I was presented with told me nothing about the issue.

Not really, because there is no requirement that a specific project has a build.gradle file. You could be doing all your needed configuration through another project’s build.gradle, the allprojects or subprojects blocks, or through a plugin that affects more projects, to name a few.

Your D project was valid, but didn’t have the expected configurations since your intended build.gradle wasn’t there applying the java plugin. Unfortunately, there’s no way to know your intent if the configuration is otherwise valid, so the error can only tell you the part that’s actually invalid.