Skip to content

Commit ec8186c

Browse files
committed
grouped tasks
1 parent c8838db commit ec8186c

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

build.gradle.kts

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,32 @@ tasks {
3737
outputFormat = "html"
3838
outputDirectory = "$buildDir/dokka"
3939
}
40+
41+
compileKotlin {
42+
// Enable Kotlin compilation to Java 8 class files with method parameter name metadata
43+
kotlinOptions {
44+
jvmTarget = "11"
45+
freeCompilerArgs = listOf("-XXLanguage:+InlineClasses")
46+
// javaParameters = true
47+
}
48+
// As per https://stackoverflow.com/a/47669720
49+
// See also https://discuss.kotlinlang.org/t/kotlin-support-for-java-9-module-system/2499/9
50+
// destinationDir = compileJava.destinationDir
51+
}
52+
53+
compileTestKotlin {
54+
kotlinOptions {
55+
jvmTarget = "11"
56+
// javaParameters = true
57+
}
58+
}
59+
60+
compileJava {
61+
// this is needed because we have a separate compile step in this example with the 'module-info.java' is in 'main/java' and the Kotlin code is in 'main/kotlin'
62+
options.compilerArgs = listOf("--patch-module", "$moduleName=${sourceSets.main.get().output.asPath}")
63+
}
64+
65+
withType<Test> { useJUnitPlatform() }
4066
}
4167

4268
val dokkaJar by tasks.creating(Jar::class) {
@@ -57,33 +83,6 @@ artifacts {
5783
archives(dokkaJar)
5884
}
5985

60-
61-
tasks.compileKotlin {
62-
// Enable Kotlin compilation to Java 8 class files with method parameter name metadata
63-
kotlinOptions {
64-
jvmTarget = "11"
65-
freeCompilerArgs = listOf("-XXLanguage:+InlineClasses")
66-
// javaParameters = true
67-
}
68-
// As per https://stackoverflow.com/a/47669720
69-
// See also https://discuss.kotlinlang.org/t/kotlin-support-for-java-9-module-system/2499/9
70-
// destinationDir = compileJava.destinationDir
71-
}
72-
73-
tasks.compileTestKotlin {
74-
kotlinOptions {
75-
jvmTarget = "11"
76-
// javaParameters = true
77-
}
78-
}
79-
80-
tasks.compileJava {
81-
// this is needed because we have a separate compile step in this example with the 'module-info.java' is in 'main/java' and the Kotlin code is in 'main/kotlin'
82-
options.compilerArgs = listOf("--patch-module", "$moduleName=${sourceSets.main.get().output.asPath}")
83-
}
84-
85-
tasks.withType<Test> { useJUnitPlatform() }
86-
8786
// == Add access to the 'modular' variant of kotlin("stdlib"): Put this into a buildSrc plugin and reuse it in all your subprojects
8887
configurations.all {
8988
val n = name.toLowerCase()

0 commit comments

Comments
 (0)