I'm trying to build multi project with flat style.
Expected result is that gradle build
under baseproj
directory compile and build using libsproj
directory's libraries.
This is my directory structure.
workspace
├── baseproj
│ ├── build.gradle
│ └── settings.gradle
│ └── src/main/java/sample.java
└── libsproj
├── batch
│ ├── foo.jar
│ └── some.jar
└── web
├── hoge.jar
└── some.jar
Here is my build.gradle
:
apply plugin: "java"
apply plugin: "application"
jar.baseName = 'base'
version = ''
def mainClass = 'sample'
mainClassName = mainClass
repositories {
mavenCentral()
}
project(':libsproj') {
dependencies {
compile fileTree(dir: "${projectDir}/libs", include: '*.jar')
}
}
dependencies {
compile project ':libsproj'
testCompile 'junit:junit:4.12'
}
and here is setting.gradle
:
rootProject.name = 'baseproj'
rootProject.projectDir = new File(settingsDir, 'baseproj')
includeFlat 'libsproj'
and also this is gradle projects
output:
------------------------------------------------------------
Root project
------------------------------------------------------------
Root project 'baseproj'
\--- Project ':libsproj'
If I run gradle build
, it says just successful, but it did not build my Java file.
:buildEnvironment
------------------------------------------------------------
Root project
------------------------------------------------------------
classpath
No dependencies
BUILD SUCCESSFUL
I understand if I create settings.gradle
under the root dir (i.e. workspace
dir in this example.), but this directory structure will be like the following:
├── anotherproj
├── baseproj
├── libsproj
│ ├── batch
│ └── web
└── otherproj
otherproj
needs libsproj
, and anotherproj
needs libsproj
and baseproj
, and so on.
At this time, I can workaround with fileTree
in build.gradle
like the following:
compile fileTree(dir: "../libsproj/batch", include: '*.jar')
But, it will be stuck when some other project is added. (e.g. otherproj
on the above)
So, how can I build with multi flat directory. Do you have any ideas? Please give me a hand.
FYI: Before post this question, I checked these questions.