Will build JAR for each 3 step separately when executing `gradlew build` or `gradlew jarStepX` where X is the step you want to export as JAR. The generated JARs are located in `build/libs`. To run a JAR, use `java -jar build/libs/stepX-1.0-SNAPSHOT.jar` where `X` is the step number
69 lines
1.5 KiB
Kotlin
69 lines
1.5 KiB
Kotlin
plugins {
|
|
id("java")
|
|
}
|
|
|
|
sourceSets {
|
|
create("common") {
|
|
java.srcDir("src/main/java/common")
|
|
}
|
|
|
|
// Step1-3 each depend on common
|
|
create("step1") {
|
|
java.srcDirs("src/main/java/common", "src/main/java/step1")
|
|
}
|
|
create("step2") {
|
|
java.srcDirs("src/main/java/common", "src/main/java/step2")
|
|
}
|
|
create("step3") {
|
|
java.srcDirs("src/main/java/common", "src/main/java/step3")
|
|
}
|
|
}
|
|
|
|
// === Create JAR tasks for each step ===
|
|
tasks.register<Jar>("jarStep1") {
|
|
manifest {
|
|
attributes["Main-Class"] = "step1.Main"
|
|
}
|
|
archiveBaseName.set("step1")
|
|
from(sourceSets["step1"].output)
|
|
dependsOn("classes")
|
|
}
|
|
|
|
tasks.register<Jar>("jarStep2") {
|
|
manifest {
|
|
attributes["Main-Class"] = "step2.Main"
|
|
}
|
|
archiveBaseName.set("step2")
|
|
from(sourceSets["step2"].output)
|
|
dependsOn("classes")
|
|
}
|
|
|
|
tasks.register<Jar>("jarStep3") {
|
|
manifest {
|
|
attributes["Main-Class"] = "step3.Main"
|
|
}
|
|
archiveBaseName.set("step3")
|
|
from(sourceSets["step3"].output)
|
|
dependsOn("classes")
|
|
}
|
|
|
|
tasks.named("build") {
|
|
dependsOn("jarStep1", "jarStep2", "jarStep3")
|
|
}
|
|
|
|
group = "be.naaturel"
|
|
version = "1.0-SNAPSHOT"
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
testImplementation(platform("org.junit:junit-bom:5.10.0"))
|
|
testImplementation("org.junit.jupiter:junit-jupiter")
|
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
}
|
|
|
|
tasks.test {
|
|
useJUnitPlatform()
|
|
} |