handstandsam / kmp4free

A Gradle Plugin that allows seamless switching between Kotlin JVM and the Kotlin Multiplatform Plugins
Apache License 2.0
62 stars 1 forks source link

Create Configuration for the Plugin for Multiplatform Targets #2

Closed handstandsam closed 2 years ago

handstandsam commented 2 years ago

There is currently some hard coded target configurations in this plugin. It would be nice to specify those to pass into the plugin.

handstandsam commented 2 years ago

Looked more into this. The recommended way is to apply your config if the KotlinMultiplatformExtension is non-null.

project.extensions.findByType(
    org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension::class.java
)?.apply {
    listOf(
        iosSimulatorArm64()
    ).forEach { nativeTarget ->
        nativeTarget.binaries.framework {
            baseName = "jvm_kmp4free"
        }
    }
}

I had originally looked at having this be a configuration block like:

kmp4free {
    config = { 
        // CONFIG WOULD HAVE GONE HERE
    }
}

This doesn't work though because configuration is determined during project evaluation, but we need this config for evaluation. Therefore, the method first listed is the best approach.