@@ -7,6 +7,7 @@ import org.gradle.api.plugins.JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME
77import org.gradle.plugin.compatibility.compatibility
88import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
99import org.jetbrains.kotlin.gradle.dsl.JvmTarget
10+ import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
1011import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
1112import org.jetbrains.kotlin.gradle.dsl.abi.ExperimentalAbiValidation
1213
@@ -30,7 +31,7 @@ dokka { dokkaPublications.html { outputDirectory = rootDir.resolve("docs/api") }
3031kotlin {
3132 explicitApi()
3233 @OptIn(ExperimentalAbiValidation ::class ) abiValidation { enabled = true }
33- val jdkRelease = " 24 "
34+ val jdkRelease = " 17 "
3435 compilerOptions {
3536 allWarningsAsErrors = true
3637 // https://docs.gradle.org/current/userguide/compatibility.html#kotlin
@@ -45,6 +46,8 @@ kotlin {
4546 }
4647}
4748
49+ addMultiReleaseSourceSet(24 )
50+
4851lint {
4952 baseline = file(" gradle/lint-baseline.xml" )
5053 ignoreTestFixturesSources = true
@@ -222,6 +225,8 @@ kotlin.target.compilations {
222225 }
223226}
224227
228+ tasks.jar { manifest.attributes(" Multi-Release" to true ) }
229+
225230tasks.pluginUnderTestMetadata { pluginClasspath.from(testPluginClasspath) }
226231
227232tasks.check { dependsOn(tasks.withType<Test >()) }
@@ -236,3 +241,21 @@ tasks.clean {
236241 rootDir.resolve(" site" ),
237242 )
238243}
244+
245+ fun addMultiReleaseSourceSet (version : Int ) {
246+ kotlin.target.compilations.create(" java${version} " ) {
247+ associateWith(kotlin.target.compilations.getByName(" main" ))
248+ compileTaskProvider {
249+ compilerOptions {
250+ this @compilerOptions as KotlinJvmCompilerOptions
251+ jvmTarget = JvmTarget .fromTarget(version.toString())
252+ freeCompilerArgs.add(" -Xjdk-release=$version " )
253+ }
254+ }
255+ compileJavaTaskProvider { options.release = version }
256+
257+ tasks.jar { from(output.allOutputs) { into(" META-INF/versions/$version " ) } }
258+
259+ tasks.withType<Test >().configureEach { inputs.files(output.allOutputs) }
260+ }
261+ }
0 commit comments