I have 3 Java projects located next to each other in the folder structure: Proj1
, Proj2
and Proj3
. Proj1
depends on Proj2
and it depends on Proj3
.
Here are their settings.gradle
files:
rootProject.name = 'Proj3'
rootProject.name = 'Proj2'
include ':Proj3'
project(':Proj3').projectDir = new File(settingsDir, '../Proj3')
rootProject.name = 'Proj1'
include ':Proj2'
project(':Proj2').projectDir = new File(settingsDir, '../Proj2')
and their gradle.build
files:
For 2
apply plugin: 'java'
dependencies {
compile project(':Proj3')
}
For 1
apply plugin: 'java'
dependencies {
compile project(':Proj2')
}
The 2nd and 3rd projects are built fine by Gradle but when I try to build the 1st it complains that
A problem occurred evaluating project ':Proj2:'. Project with path ':Proj3' could not be found in project ':Proj2'.
and points to the line compile project(':Proj3')
(in the build of Proj2
). Stack trace starts with
org.gradle.tooling.BuildException: Could not fetch model of type 'EclipseProject' using Gradle distribution 'https://services.gradle.org/distributions/gradle-3.1-bin.zip'.
Don't know why the 2nd project can find the 3rd fine when it's built and suddenly not when the 1st is built. Why would the 1st care about how the 2nd searches for the 3rd after its already included in the "Project and External Dependencies" folder.
How do I make it work?
I think, you've maid a wrong project configuration. You can have only one
settings.gradle
file for one multimodule project and this single file should include all modules.So the structure might be something like this:
And
settings.gradle
should contains atleast follows:In that case, it seems, you don't need to have some extra settings to change module name or it's directory. You can read about it in the official user guide.