0
所以我有一個項目結構如下搖籃:多項目建設
root
|-- module-1
|-- module-2
.
.
|-- module-n
我們正在尋找最後的神器是從所有模塊的所有信號源的總罐子。我不確定這是否正確。 這裏是我的構建腳本:當添加
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
}
所以我們只是附加sourceSets一個新的模塊。
我只是想確認這是否是正確的方式來構建一個多模塊項目,如果不是正確的方式是什麼?以及如何解釋模塊間依賴關係?
所以每個模塊都會有自己的gradle文件?如果是的話它會怎樣? – eatSleepCode
與maven不同,gradle不會規定這一點。您可以將所有模塊放在單個文件中,每個模塊放在單獨的文件中或兩者的組合中。我建議你閱讀關於多模塊構建的gradle文檔 –