Hi, I am new to Gradle, and am running into issues while trying to share sub-projects among many other projects. My project structure looks as follows:
Project A
|
|--------------Project B
|--------------Project C
|--------------Project D
Project E
|
|--------------Project C
|--------------Project D
where:
Project D
|
|---------------Project C
Project C
and Project D
will be used in other projects very frequently, as they act as libraries for data classes and database utilities.
Project A
settings.gradle
file:
rootProject.name = 'ProjectA'
include ":ProjectB"
project(":ProjectB").projectDir = file("/home/myFolder/NetBeansProject/ProjectB")
include ":ProjectC"
project(":ProjectC").projectDir = file("/home/myFolder/NetBeansProject/ProjectC")
include ":ProjectD"
project(":ProjectD").projectDir = file("/home/myFolder/NetBeansProject/ProjectD")
Project A
build.gradle
file:
apply plugin: 'java'
apply plugin: 'application'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}
repositories {
mavenCentral()
}
dependencies {
compile project (':ProjectB')
compile project (':ProjectC')
compile project (':ProjectD')
}
Likewise, all other projects have similar settings and build files, containing their respective sub-projects they are dependent on.
Unfortunately, it would seem that Gradle gets confused when multiple projects are dependent on the same sub-projects.
For example, Project E
runs just fine, while Project A
is unable to import any classes from any of its sub-projects.
Error Log:
Exception 1:
org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':compileClasspath'.
Caused by: org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve project :ProjectC.
Caused by: org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.internal.component.NoMatchingConfigurationSelectionException: Unable to find a matching configuration of project :ProjectC: None of the consumable configurations have attributes.
at org.gradle.internal.component.model.LocalComponentDependencyMetadata.selectConfigurations(LocalComponentDependencyMetadata.java:122)
Exception 2:
org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':runtimeClasspath'.
Caused by: org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve project :ProjectC.
Caused by: org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.internal.component.NoMatchingConfigurationSelectionException: Unable to find a matching configuration of project :ProjectC: None of the consumable configurations have attributes.
Exception 3:
org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':testCompileClasspath'.
Caused by: org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve project :ProjectC.
Caused by: org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.internal.component.NoMatchingConfigurationSelectionException: Unable to find a matching configuration of project :ProjectC: None of the consumable configurations have attributes.
Exception 4:
org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':testRuntimeClasspath'.
Caused by: org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve project :ProjectC.
Caused by: org.netbeans.gradle.model.util.TransferableExceptionWrapper: org.gradle.internal.component.NoMatchingConfigurationSelectionException: Unable to find a matching configuration of project :ProjectC: None of the consumable configurations have attributes.
Project C
and Project D
both generate a Root Project
folder that points to the settings and build files for Project E
, but not for Project A
.
Why is this happening? What shall I do in order to get Project A
to work with its sub-projects?
Thank you all in advance for taking the time to help me with my Gradle issues!