We have a set up with 2 project, 1 main and 1 subproject, they are Java projects. They are all under the same directory.
Here is how the directory structure looks like :
Based on the Java Quckstart: Multi-project Java build:
1) your settings.gradle
file needs to be in dev/
, not dev/project_A
and it should contain something like this:
include 'Project_A', 'Project_B'
2) Then your dev/Project_A/build.gradle
file should contain
dependencies {
compile project(':Project_B')
}
Edit:
I have created a toy example following the project layout you've described in your question. However, I haven't been able to reproduce the problem. Perhaps you'll be able to spot some difference that is causing your particular error:
Directory Tree
├── Project_A │ ├── build.gradle │ ├── settings.gradle │ └── src │ └── main │ └── java │ └── a │ └── A.java └── Project_B ├── build.gradle └── src └── main └── java └── b └── B.java
Project_A/build.gradle
apply plugin: 'java'
apply plugin: 'application'
mainClassName = 'a.A'
dependencies {
compile project(':Project_B')
}
Project_A/settings.gradle
includeFlat 'Project_B'
A.java
package a;
import b.B;
public class A {
public static void main(String[] args) {
System.out.println("From A.main...");
B.call();
}
}
Project_B/build.gradle
apply plugin: 'java'
B.java
package b;
public class B {
public static void call() {
System.out.println("Calling B");
}
}
When running Gradle from Project_A
, the output is:
$ gradle clean build run :clean UP-TO-DATE :Project_B:clean UP-TO-DATE :Project_B:compileJava :Project_B:processResources UP-TO-DATE :Project_B:classes :Project_B:jar :compileJava :processResources UP-TO-DATE :classes :jar :assemble :compileTestJava UP-TO-DATE :processTestResources UP-TO-DATE :testClasses UP-TO-DATE :test UP-TO-DATE :check UP-TO-DATE :build :Project_B:assemble :Project_B:compileTestJava UP-TO-DATE :Project_B:processTestResources UP-TO-DATE :Project_B:testClasses UP-TO-DATE :Project_B:test UP-TO-DATE :Project_B:check UP-TO-DATE :Project_B:build :run From A.main... Calling B BUILD SUCCESSFUL