Skip to content

Commit

Permalink
fix: set jvm toolchain for kotlin according to project java version
Browse files Browse the repository at this point in the history
  • Loading branch information
Morfly committed Aug 17, 2023
1 parent 21c4323 commit dc53ed8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import com.turo.nibel.buildtools.CommonExtension
import com.turo.nibel.buildtools.NibelConventionPlugin
import com.turo.nibel.buildtools.android
import com.turo.nibel.buildtools.implementation
import com.turo.nibel.buildtools.kotlin
import com.turo.nibel.buildtools.kotlinOptions
import com.turo.nibel.buildtools.libs
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.withType

Expand Down Expand Up @@ -39,6 +41,12 @@ class NibelAndroidCommonPlugin : NibelConventionPlugin({
}
}

kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(NibelMetadata.JAVA_VERSION.toString()))
}
}

dependencies {
implementation(platform(libs.bom.kotlin))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import com.turo.nibel.buildtools.NibelConventionPlugin
import com.turo.nibel.buildtools.kotlin
import com.turo.nibel.buildtools.libs
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

Expand All @@ -19,4 +21,10 @@ class NibelKotlinJvmLibraryPlugin : NibelConventionPlugin({
targetCompatibility = NibelMetadata.JAVA_VERSION.toString()
sourceCompatibility = NibelMetadata.JAVA_VERSION.toString()
}

kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(NibelMetadata.JAVA_VERSION.toString()))
}
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import org.gradle.api.tasks.SourceSetContainer
import org.gradle.kotlin.dsl.DependencyHandlerScope
import org.gradle.kotlin.dsl.getByType
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
import org.jetbrains.kotlin.gradle.dsl.KotlinSingleTargetExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.AbstractKotlinTarget

typealias CommonExtension = com.android.build.api.dsl.CommonExtension<*, *, *, *>

Expand All @@ -21,6 +23,9 @@ fun <T : CommonExtension> Project.android(body: T.() -> Unit) {
(extensions.getByName("android") as T).apply(body)
}

fun Project.kotlin(body: KotlinSingleTargetExtension<AbstractKotlinTarget>.() -> Unit): Unit =
(this as ExtensionAware).extensions.configure("kotlin", body)

fun CommonExtension.kotlinOptions(body: KotlinJvmOptions.() -> Unit) {
(this as ExtensionAware).extensions.configure("kotlinOptions", body)
}
Expand All @@ -29,8 +34,9 @@ fun <T> NamedDomainObjectContainer<T>.release(body: T.() -> Unit) {
getByName("release", body)
}

val Project.sourceSets: SourceSetContainer get() =
(this as ExtensionAware).extensions.getByName("sourceSets") as SourceSetContainer
val Project.sourceSets: SourceSetContainer
get() = (this as ExtensionAware).extensions
.getByName("sourceSets") as SourceSetContainer

fun Project.mavenPublishing(configure: MavenPublishBaseExtension.() -> Unit) {
(this as ExtensionAware).extensions.configure("mavenPublishing", configure)
Expand Down

0 comments on commit dc53ed8

Please sign in to comment.