or does anyone has any example repo that uses new ...
# gradle
t
or does anyone has any example repo that uses new multiplatform plugin with kotlin dsl?
ok, managed to do it myself rubber duck
l
Could you please share ? 🙂
t
sure, later today
👍 1
Copy code
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetConfigurator
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmTargetPreset
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinWithJavaTarget

plugins {
    application
}

apply {
    plugin("kotlin-multiplatform")
}

configure<KotlinMultiplatformExtension> {
    targets.add(presets["jvmWithJava"].createTarget("jvm"))

    sourceSets["commonMain"].apply {
        dependencies {
            implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
        }
    }
    sourceSets["jvmMain"].apply {
        dependsOn(sourceSets["commonMain"])

        dependencies{
            implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
            implementation("org.jetbrains.kotlin:kotlin-reflect")
        }
    }
}

application {
    mainClassName = "org.sample.MainKt"
}
note that this with old plugins
classpath
approach. Using new
plugin {}
dsl should be a little better
also
fromPerset()
is not currently available in Kotlin DSL, that is why has to use
targets.add(..)
l
thanks a lot!