11import org.jetbrains.dokka.gradle.DokkaTask
2- import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
3+ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
34import java.net.URL
45
56plugins {
@@ -14,17 +15,28 @@ tasks.withType<JavaCompile> {
1415 options.release.set(8 )
1516}
1617
17- tasks.withType<KotlinCompile > {
18- kotlinOptions {
19- // Produce Java 8 byte code, would default to Java 6.
20- jvmTarget = " 1.8"
21- // Allow consumers of this library to use an older version of the Kotlin compiler. By default only the version
22- // previous to the compiler used for this project typically works.
23- // Kotlin supports the development with at least three previous versions, so pick the oldest one possible.
24- // https://kotlinlang.org/docs/kotlin-evolution.html#evolving-the-binary-format
18+ kotlin {
19+ compilerOptions {
20+ // Produce Java 8 byte code, would default to Java 6
21+ jvmTarget.set(JvmTarget .JVM_1_8 )
22+
23+ // Allow consumers of this library to use the oldest possible Kotlin compiler and standard libraries.
2524 // https://kotlinlang.org/docs/compatibility-modes.html
26- apiVersion = " 1.7"
27- languageVersion = " 1.7"
25+ // https://kotlinlang.org/docs/kotlin-evolution-principles.html#compatibility-tools
26+
27+ // Prevents using newer language features, sets this as the Kotlin version in produced metadata. So consumers
28+ // can compile this with a Kotlin compiler down to one minor version before this.
29+ // Pick the oldest not deprecated version.
30+ languageVersion.set(KotlinVersion .KOTLIN_1_7 )
31+ // Prevents using newer APIs from the Kotlin standard library. So consumers can run this library with a Kotlin
32+ // standard library down to this version.
33+ // Pick the oldest not deprecated version.
34+ apiVersion.set(KotlinVersion .KOTLIN_1_7 )
35+ // Depend on the oldest compatible Kotlin standard libraries (by default the Kotlin plugin coerces it to the one
36+ // matching its version). So consumers can safely use this or any later Kotlin standard library.
37+ // Pick the first release matching the versions above.
38+ // Note: when changing, also update coroutines dependency version (as this does not set that).
39+ coreLibrariesVersion = " 1.7.0"
2840 }
2941}
3042
@@ -57,11 +69,11 @@ val sourcesJar by tasks.registering(Jar::class) {
5769 from(sourceSets.main.get().allSource)
5870}
5971
60- val coroutinesVersion: String by rootProject.extra
61-
6272dependencies {
63- // Note: compileOnly as we do not want to require library users to use coroutines.
64- compileOnly(" org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion " )
73+ // Note: compileOnly so consumers do not depend on the coroutines library unless they manually add it.
74+ // Note: pick a version that depends on Kotlin standard library (org.jetbrains.kotlin:kotlin-stdlib) version
75+ // coreLibrariesVersion (set above) or older.
76+ compileOnly(" org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4" )
6577
6678 api(project(" :objectbox-java" ))
6779}
0 commit comments