So I have a project structure as follows
root
|-- module-1
|-- module-2
.
.
|-- module-n
The final artifact we are looking at is the combined jar of all sources from all the modules. I am not sure whether this is the right way.
Here is my build-script :
plugins {
id "com.github.johnrengelman.shadow" version "1.2.3"
}
group = 'com.root'
version = System.getenv('BUILD_NUMBER') ?:'1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
configurations { providedCompile }
repositories {
mavenLocal()
mavenCentral()
}
def sparkVersion = '2.0.0'
def scalaMajorVersion = '2.11'
sourceSets {
main {
java {
srcDirs = ['module1/src/main/java', 'module2/src/main/java']
}
}
}
dependencies {
compile group: 'org.scala-lang', name:'scala-compiler', version:'2.11.8'
compile group: 'org.apache.kafka', name: 'kafka-clients', version: '0.9.0.0'
compile group: 'org.apache.spark', name: "spark-streaming-kafka_$scalaMajorVersion", version: '1.6.2'
compile group: 'org.apache.spark', name: "spark-streaming_$scalaMajorVersion", version: "$sparkVersion"
compile group: 'org.apache.spark', name: "spark-catalyst_$scalaMajorVersion", version: "$sparkVersion"
compile group: 'com.google.code.gson', name: 'gson', version: '2.7'
compile group: 'org.apache.zookeeper', name: 'zookeeper', version: '3.4.9'
providedCompile group: 'org.apache.spark', name: "spark-core_$scalaMajorVersion", version: "$sparkVersion"
providedCompile group: 'org.apache.spark', name: "spark-sql_$scalaMajorVersion", version: "$sparkVersion"
testCompile group: 'junit', name: 'junit', version: '4.11'
}
build.dependsOn(shadowJar);
shadowJar {
zip64 true
}
sourceSets.main.compileClasspath += configurations.providedCompile
sourceSets.test.compileClasspath += configurations.providedCompile
sourceSets.test.runtimeClasspath += configurations.providedCompile
artifacts {
archives file: shadowJar.archivePath, builtBy: shadowJar
}
So we are just appending sourceSets when a new module is added.
I just wanted to confirm whether this is the right way to build a multi-module project, if not what is the right way? and how to account for inter module dependencies?