-
Notifications
You must be signed in to change notification settings - Fork 0
/
BuildPluginMultiplatform.kt
57 lines (51 loc) · 1.94 KB
/
BuildPluginMultiplatform.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package ru.otus.otuskotlin.marketplace.plugin
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.jvm.toolchain.JavaLanguageVersion
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.the
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
@Suppress("unused")
internal class BuildPluginMultiplatform : Plugin<Project> {
override fun apply(project: Project) = with(project) {
pluginManager.apply("org.jetbrains.kotlin.multiplatform")
group = rootProject.group
version = rootProject.version
plugins.withId("org.jetbrains.kotlin.multiplatform") {
extensions.configure<KotlinMultiplatformExtension> {
configureTargets(this@with)
sourceSets.configureEach {
languageSettings.apply {
progressiveMode = true
optIn("kotlin.time.ExperimentalTime")
}
}
}
}
}
}
@Suppress("LongMethod", "MagicNumber")
private fun KotlinMultiplatformExtension.configureTargets(project: Project) {
val libs = project.the<LibrariesForLibs>()
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(libs.versions.jvm.language.get()))
// vendor.set(JvmVendorSpec.AZUL)
}
jvm()
linuxX64()
macosArm64()
macosX64()
project.tasks.withType(JavaCompile::class.java) {
sourceCompatibility = libs.versions.jvm.language.get()
targetCompatibility = libs.versions.jvm.compiler.get()
}
project.tasks.withType(KotlinJvmCompile::class.java).configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.valueOf("JVM_" + libs.versions.jvm.compiler.get()))
}
}
}