上项目结构图:

idea里面一个project其实相当于eclipse的一个workspace,这样一来就很好理解了,我们新建了两个module,相当于eclipse的两个项目工程
主要看配置:build.gradle和根项目settings.gradley以及class
action:
group 'cn.sawshaw'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile project(":service")
testCompile group: 'junit', name: 'junit', version: '4.12'
}
package action;
import service.SayHello;
public class HelloAction {
public String helloAction(String name){
return new SayHello().sayHello(name);
}
public static void main(String[] args){
String result=new SayHello().sayHello("小明");
System.out.println(result);
}
}
Service:
group 'cn.sawshaw'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
package service;
public class SayHello {
public String sayHello(String name){
System.out.print("service sayHello start .");
return "Hello:"+name;
}
}
根项目User:
group 'cn.sawshaw'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile project(":action")
testCompile group: 'junit', name: 'junit', version: '4.12'
}
rootProject.name = 'user' include 'action' include 'service'
package test;
import action.HelloAction;
public class Test1 {
public static void main( String[] args ){
String result= new HelloAction().helloAction("lily");
System.out.println(result);
}
}
可以看出Action依赖Service,User依赖Action
eclipse自带了可以构建父子项目工具Gradle STS Project

gradle falt-java-mutiple project