forked from kscience/kmath
Build refactoring
This commit is contained in:
parent
0e7ad1c0c0
commit
4cd316758a
@ -1,3 +1,5 @@
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
|
||||
|
||||
val kmathVersion by extra("0.1.2-dev-1")
|
||||
|
||||
allprojects {
|
||||
@ -16,13 +18,11 @@ subprojects {
|
||||
|
||||
//apply artifactory configuration
|
||||
apply(plugin = "artifactory-config")
|
||||
}
|
||||
|
||||
plugins.withId("org.jetbrains.kotlin.multiplatform") {
|
||||
plugins.withType<KotlinMultiplatformPlugin> {
|
||||
apply(plugin = "multiplatform-config")
|
||||
}
|
||||
|
||||
}
|
||||
// dokka {
|
||||
// dokka {
|
||||
// outputFormat = "html"
|
||||
// outputDirectory = javadoc.destinationDir
|
||||
// }
|
||||
@ -31,5 +31,6 @@ subprojects {
|
||||
// from javadoc . destinationDir
|
||||
// classifier = "javadoc"
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
import com.moowork.gradle.node.NodeExtension
|
||||
import com.moowork.gradle.node.npm.NpmTask
|
||||
import com.moowork.gradle.node.task.NodeTask
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
|
||||
|
||||
plugins {
|
||||
@ -8,42 +9,45 @@ plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
node {
|
||||
configure<NodeExtension> {
|
||||
nodeModulesDir = file("$buildDir/node_modules")
|
||||
}
|
||||
|
||||
val compileKotlinJs by tasks.getting(Kotlin2JsCompile::class)
|
||||
val compileTestKotlinJs by tasks.getting(Kotlin2JsCompile::class)
|
||||
|
||||
val populateNodeModules by tasks.registering(Copy::class) {
|
||||
dependsOn(compileKotlinJs)
|
||||
from(compileKotlinJs.destinationDir)
|
||||
|
||||
kotlin.js().compilations["test"].runtimeDependencyFiles.forEach {
|
||||
if (it.exists() && !it.isDirectory) {
|
||||
from(zipTree(it.absolutePath).matching { include("*.js") })
|
||||
}
|
||||
}
|
||||
|
||||
into("$buildDir/node_modules")
|
||||
}
|
||||
|
||||
val installMocha by tasks.registering<NpmTask> {
|
||||
setWorkingDir(buildDir)
|
||||
setArgs(listOf("install", "mocha"))
|
||||
}
|
||||
|
||||
|
||||
inline fun <reified T : Task> TaskContainer.registering(
|
||||
crossinline action: T.() -> Unit
|
||||
): RegisteringDomainObjectDelegateProviderWithTypeAndAction<TaskContainer, T> =
|
||||
RegisteringDomainObjectDelegateProviderWithTypeAndAction.of(this, T::class, { action() })
|
||||
|
||||
|
||||
val runMocha by tasks.registering(NodeTask::class) {
|
||||
configure<KotlinMultiplatformExtension> {
|
||||
|
||||
val populateNodeModules by tasks.registering(Copy::class) {
|
||||
dependsOn(compileKotlinJs)
|
||||
from(compileKotlinJs.destinationDir)
|
||||
|
||||
js().compilations["test"].runtimeDependencyFiles.forEach {
|
||||
if (it.exists() && !it.isDirectory) {
|
||||
from(zipTree(it.absolutePath).matching { include("*.js") })
|
||||
}
|
||||
}
|
||||
|
||||
into("$buildDir/node_modules")
|
||||
}
|
||||
|
||||
val installMocha by tasks.registering<NpmTask> {
|
||||
setWorkingDir(buildDir)
|
||||
setArgs(listOf("install", "mocha"))
|
||||
}
|
||||
|
||||
val runMocha by tasks.registering(NodeTask::class) {
|
||||
dependsOn(compileTestKotlinJs, populateNodeModules, installMocha)
|
||||
setScript(file("$buildDir/node_modules/mocha/bin/mocha"))
|
||||
setArgs(listOf(compileTestKotlinJs.outputFile))
|
||||
}
|
||||
|
||||
tasks["jsTest"].dependsOn(runMocha)
|
||||
}
|
||||
|
||||
tasks["jsTest"].dependsOn(runMocha)
|
||||
|
Loading…
Reference in New Issue
Block a user