Fix native and node hmpp
This commit is contained in:
parent
1cc83e8803
commit
8efae2ca4d
@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "ru.mipt.npm"
|
||||
version = "0.8.2"
|
||||
version = "0.8.3"
|
||||
|
||||
description = "Build tools for DataForge and kscience projects"
|
||||
|
||||
|
@ -1,12 +1,20 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.NamedDomainObjectContainer
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.findPlugin
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
|
||||
private fun KotlinMultiplatformExtension.sourceSets(configure: Action<NamedDomainObjectContainer<KotlinSourceSet>>): Unit =
|
||||
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure("sourceSets", configure)
|
||||
|
||||
class KScienceNativePlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) = target.run {
|
||||
override fun apply(project: Project) = project.run {
|
||||
//Apply multiplatform plugin is not applied, apply it
|
||||
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
|
||||
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
|
||||
@ -35,45 +43,25 @@ class KScienceNativePlugin : Plugin<Project> {
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting
|
||||
val commonTest by getting
|
||||
val commonMain = findByName("commonMain")!!
|
||||
val commonTest = findByName("commonTest")!!
|
||||
|
||||
val nativeMain by creating {
|
||||
val nativeMain = create("nativeMain").apply {
|
||||
dependsOn(commonMain)
|
||||
}
|
||||
|
||||
val nativeTest by creating {
|
||||
val nativeTest = create("nativeTest").apply {
|
||||
dependsOn(commonTest)
|
||||
}
|
||||
|
||||
if (isLinux) {
|
||||
val linuxX64Main by getting {
|
||||
dependsOn(nativeMain)
|
||||
}
|
||||
val linuxX64Test by getting {
|
||||
dependsOn(nativeTest)
|
||||
}
|
||||
}
|
||||
findByName("linuxX64Main")?.dependsOn(nativeMain)
|
||||
findByName("linuxX64Test")?.dependsOn(nativeTest)
|
||||
|
||||
if (isMinGw) {
|
||||
val mingwX64Main by getting {
|
||||
dependsOn(nativeMain)
|
||||
}
|
||||
findByName("mingwX64Main")?.dependsOn(nativeMain)
|
||||
findByName("mingwX64Test")?.dependsOn(nativeTest)
|
||||
|
||||
val mingwX64Test by getting {
|
||||
dependsOn(nativeTest)
|
||||
}
|
||||
}
|
||||
|
||||
if (isMacOs) {
|
||||
val macosX64Main by getting {
|
||||
dependsOn(nativeMain)
|
||||
}
|
||||
|
||||
val macosX64Test by getting {
|
||||
dependsOn(nativeTest)
|
||||
}
|
||||
}
|
||||
findByName("macosX64Main")?.dependsOn(nativeMain)
|
||||
findByName("macosX64Test")?.dependsOn(nativeTest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,17 @@
|
||||
package ru.mipt.npm.gradle
|
||||
|
||||
import org.gradle.api.Action
|
||||
import org.gradle.api.NamedDomainObjectContainer
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.findPlugin
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||
|
||||
private fun KotlinMultiplatformExtension.sourceSets(configure: Action<NamedDomainObjectContainer<KotlinSourceSet>>): Unit =
|
||||
(this as org.gradle.api.plugins.ExtensionAware).extensions.configure("sourceSets", configure)
|
||||
|
||||
/**
|
||||
* Create a separate target for node
|
||||
@ -24,38 +32,30 @@ class KScienceNodePlugin : Plugin<Project> {
|
||||
js(name = "node", compiler = IR) {
|
||||
nodejs()
|
||||
}
|
||||
sourceSets {
|
||||
val commonMain by getting
|
||||
val commonTest by getting
|
||||
|
||||
val jsCommonMain by creating{
|
||||
sourceSets {
|
||||
val commonMain = findByName("commonMain")!!
|
||||
val commonTest = findByName("commonTest")!!
|
||||
|
||||
val jsCommonMain = create("jsCommonMain").apply {
|
||||
dependsOn(commonMain)
|
||||
}
|
||||
|
||||
val jsCommonTest by creating{
|
||||
val jsCommonTest = create("jsCommonTest").apply {
|
||||
dependsOn(commonTest)
|
||||
}
|
||||
|
||||
val jsMain by getting{
|
||||
dependsOn(jsCommonMain)
|
||||
}
|
||||
findByName("jsMain")?.dependsOn(jsCommonMain)
|
||||
findByName("jsTest")?.dependsOn(jsCommonTest)
|
||||
|
||||
val jsTest by getting{
|
||||
dependsOn(jsCommonTest)
|
||||
}
|
||||
|
||||
val nodeMain by creating {
|
||||
findByName("nodeMain")?.apply {
|
||||
dependsOn(jsCommonMain)
|
||||
dependencies{
|
||||
dependencies {
|
||||
api("org.jetbrains.kotlinx:kotlinx-nodejs:${KScienceVersions.kotlinxNodeVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
val nodeTest by creating {
|
||||
dependsOn(jsCommonTest)
|
||||
findByName("nodeTest")?.dependsOn(jsCommonMain)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user