Revert native plugin configuration

This commit is contained in:
Alexander Nozik 2022-08-24 19:02:19 +03:00
parent 8df651bead
commit b4f494e58a
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357

View File

@ -2,24 +2,61 @@ package space.kscience.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.hasPlugin
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
@Deprecated("Use common configuration block")
public class KScienceNativePlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
logger.warn("Native plugin is deprecated. Use `ksceince.native()`")
//Apply multiplatform plugin is not applied, apply it
if (!plugins.hasPlugin("org.jetbrains.kotlin.multiplatform")) {
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
plugins.apply("org.jetbrains.kotlin.multiplatform")
}
registerKScienceExtension(::KScienceMppExtension).apply {
native()
if (!plugins.hasPlugin(KScienceCommonPlugin::class)) {
logger.info("KScience plugin is not resolved. Adding it automatically")
apply<KScienceCommonPlugin>()
}
if (!plugins.hasPlugin(KScienceCommonPlugin::class)) {
configureKScience()
} else {
project.logger.warn("Use `kscience.native()` configuration block")
configure<KotlinMultiplatformExtension> {
val nativeTargets = setOf(
linuxX64(),
mingwX64(),
macosX64(),
iosX64(),
iosArm64()
)
sourceSets {
val commonMain = findByName("commonMain")!!
val commonTest = findByName("commonTest")!!
val nativeMain by creating {
dependsOn(commonMain)
}
val nativeTest by creating {
//should NOT depend on nativeMain because automatic dependency by plugin
dependsOn(commonTest)
}
configure(nativeTargets) {
compilations["main"]?.apply {
configure(kotlinSourceSets) {
dependsOn(nativeMain)
}
}
compilations["test"]?.apply {
configure(kotlinSourceSets) {
dependsOn(nativeTest)
}
}
}
}
}
}
}