3
3
import io.gitlab.arturbosch.detekt.Detekt
4
4
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
5
5
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
6
+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
6
7
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
7
8
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetWithTests
9
+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
8
10
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
9
11
10
12
plugins {
@@ -18,15 +20,25 @@ plugins {
18
20
convention.publication
19
21
}
20
22
23
+ java {
24
+ toolchain {
25
+ languageVersion = JavaLanguageVersion .of(11 )
26
+ }
27
+ }
28
+
21
29
kotlin {
22
30
explicitApi()
23
31
24
32
@OptIn(ExperimentalKotlinGradlePluginApi ::class )
25
33
compilerOptions {
26
34
freeCompilerArgs.add(" -opt-in=io.github.optimumcode.json.schema.ExperimentalApi" )
27
35
}
28
- jvmToolchain(11 )
29
36
jvm {
37
+ withJava()
38
+ compilerOptions {
39
+ jvmTarget = JvmTarget .JVM_11
40
+ freeCompilerArgs.add(" -Xjdk-release=11" )
41
+ }
30
42
testRuns[" test" ].executionTask.configure {
31
43
useJUnitPlatform()
32
44
}
@@ -168,4 +180,24 @@ afterEvaluate {
168
180
tasks.named(" check" ).configure {
169
181
dependsOn(detektAllTask)
170
182
}
183
+ }
184
+
185
+ tasks {
186
+ named<JavaCompile >(" compileJava" ) {
187
+ options.compilerArgumentProviders + =
188
+ object : CommandLineArgumentProvider {
189
+ @InputFiles
190
+ @PathSensitive(PathSensitivity .RELATIVE )
191
+ val kotlinClasses =
192
+ this @tasks.named<KotlinCompile >(
193
+ " compileKotlinJvm" ,
194
+ ).flatMap(KotlinCompile ::destinationDirectory)
195
+
196
+ override fun asArguments () =
197
+ listOf (
198
+ " --patch-module" ,
199
+ " io.github.optimumcode.json.schema=${kotlinClasses.get().asFile.absolutePath} " ,
200
+ )
201
+ }
202
+ }
171
203
}
0 commit comments