diff --git a/build-tools/conventions/src/main/kotlin/NibelAndroidCommonPlugin.kt b/build-tools/conventions/src/main/kotlin/NibelAndroidCommonPlugin.kt index f52acd0..9585b3e 100644 --- a/build-tools/conventions/src/main/kotlin/NibelAndroidCommonPlugin.kt +++ b/build-tools/conventions/src/main/kotlin/NibelAndroidCommonPlugin.kt @@ -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 @@ -39,6 +41,12 @@ class NibelAndroidCommonPlugin : NibelConventionPlugin({ } } + kotlin { + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(NibelMetadata.JAVA_VERSION.toString())) + } + } + dependencies { implementation(platform(libs.bom.kotlin)) } diff --git a/build-tools/conventions/src/main/kotlin/NibelKotlinJvmLibraryPlugin.kt b/build-tools/conventions/src/main/kotlin/NibelKotlinJvmLibraryPlugin.kt index ce87ffc..00fea99 100644 --- a/build-tools/conventions/src/main/kotlin/NibelKotlinJvmLibraryPlugin.kt +++ b/build-tools/conventions/src/main/kotlin/NibelKotlinJvmLibraryPlugin.kt @@ -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 @@ -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())) + } + } }) diff --git a/build-tools/conventions/src/main/kotlin/com/turo/nibel/buildtools/DslExtensions.kt b/build-tools/conventions/src/main/kotlin/com/turo/nibel/buildtools/DslExtensions.kt index 13180e8..958df61 100644 --- a/build-tools/conventions/src/main/kotlin/com/turo/nibel/buildtools/DslExtensions.kt +++ b/build-tools/conventions/src/main/kotlin/com/turo/nibel/buildtools/DslExtensions.kt @@ -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<*, *, *, *> @@ -21,6 +23,9 @@ fun Project.android(body: T.() -> Unit) { (extensions.getByName("android") as T).apply(body) } +fun Project.kotlin(body: KotlinSingleTargetExtension.() -> Unit): Unit = + (this as ExtensionAware).extensions.configure("kotlin", body) + fun CommonExtension.kotlinOptions(body: KotlinJvmOptions.() -> Unit) { (this as ExtensionAware).extensions.configure("kotlinOptions", body) } @@ -29,8 +34,9 @@ fun NamedDomainObjectContainer.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)