Build refactoring

This commit is contained in:
Alexander Nozik 2019-04-23 22:05:47 +03:00
commit 56c23109b3
13 changed files with 116 additions and 229 deletions

View File

@ -1,27 +1,26 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
val kmathVersion by extra("0.1.2-dev-1") val kmathVersion by extra("0.1.2-dev-1")
allprojects { allprojects {
// apply(plugin = "maven")
// apply(plugin = "maven-publish")
// apply(plugin = "com.jfrog.artifactory")
repositories { repositories {
jcenter() jcenter()
maven("https://kotlin.bintray.com/kotlinx") maven("https://kotlin.bintray.com/kotlinx")
} }
group = "scientifik" group = "scientifik"
version = kmathVersion version = kmathVersion
} }
subprojects { subprojects {
// Actually, probably we should apply it to plugins explicitly
// We also can merge them to single kmath-publish plugin
if (name.startsWith("kmath")) { if (name.startsWith("kmath")) {
// apply bintray configuration
apply(plugin = "bintray-config") apply(plugin = "bintray-config")
//apply artifactory configuration
apply(plugin = "artifactory-config") apply(plugin = "artifactory-config")
} }
plugins.withType<KotlinMultiplatformPlugin> {
apply(plugin = "multiplatform-config")
// dokka { // dokka {
// outputFormat = "html" // outputFormat = "html"
// outputDirectory = javadoc.destinationDir // outputDirectory = javadoc.destinationDir
@ -32,5 +31,3 @@ subprojects {
// classifier = "javadoc" // classifier = "javadoc"
// } // }
} }
}

View File

@ -4,7 +4,7 @@
object Ver { object Ver {
val ioVersion = "0.1.5" val ioVersion = "0.1.5"
val coroutinesVersion = "1.1.1" val coroutinesVersion = "1.1.1"
val atomicfuVersion = "0.12.1" val atomicfuVersion = "0.12.4"
// This version is not used and IDEA shows this property as unused // This version is not used and IDEA shows this property as unused
val dokkaVersion = "0.9.17" val dokkaVersion = "0.9.17"
} }

View File

@ -1,7 +1,6 @@
import com.moowork.gradle.node.NodeExtension
import com.moowork.gradle.node.npm.NpmTask import com.moowork.gradle.node.npm.NpmTask
import com.moowork.gradle.node.task.NodeTask import com.moowork.gradle.node.task.NodeTask
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
plugins { plugins {
@ -9,26 +8,18 @@ plugins {
kotlin("multiplatform") kotlin("multiplatform")
} }
configure<NodeExtension> { node {
nodeModulesDir = file("$buildDir/node_modules") nodeModulesDir = file("$buildDir/node_modules")
} }
val compileKotlinJs by tasks.getting(Kotlin2JsCompile::class) val compileKotlinJs by tasks.getting(Kotlin2JsCompile::class)
val compileTestKotlinJs by tasks.getting(Kotlin2JsCompile::class) val compileTestKotlinJs by tasks.getting(Kotlin2JsCompile::class)
inline fun <reified T : Task> TaskContainer.registering(
crossinline action: T.() -> Unit
): RegisteringDomainObjectDelegateProviderWithTypeAndAction<TaskContainer, T> =
RegisteringDomainObjectDelegateProviderWithTypeAndAction.of(this, T::class, { action() })
configure<KotlinMultiplatformExtension> {
val populateNodeModules by tasks.registering(Copy::class) { val populateNodeModules by tasks.registering(Copy::class) {
dependsOn(compileKotlinJs) dependsOn(compileKotlinJs)
from(compileKotlinJs.destinationDir) from(compileKotlinJs.destinationDir)
js().compilations["test"].runtimeDependencyFiles.forEach { kotlin.js().compilations["test"].runtimeDependencyFiles.forEach {
if (it.exists() && !it.isDirectory) { if (it.exists() && !it.isDirectory) {
from(zipTree(it.absolutePath).matching { include("*.js") }) from(zipTree(it.absolutePath).matching { include("*.js") })
} }
@ -37,7 +28,7 @@ configure<KotlinMultiplatformExtension> {
into("$buildDir/node_modules") into("$buildDir/node_modules")
} }
val installMocha by tasks.registering<NpmTask> { val installMocha by tasks.registering(NpmTask::class) {
setWorkingDir(buildDir) setWorkingDir(buildDir)
setArgs(listOf("install", "mocha")) setArgs(listOf("install", "mocha"))
} }
@ -49,5 +40,5 @@ configure<KotlinMultiplatformExtension> {
} }
tasks["jsTest"].dependsOn(runMocha) tasks["jsTest"].dependsOn(runMocha)
}

View File

@ -11,6 +11,8 @@ kotlin {
compilations.all { compilations.all {
kotlinOptions { kotlinOptions {
jvmTarget = "1.8" jvmTarget = "1.8"
// This was used in kmath-koma, but probably if we need it better to apply it for all modules
freeCompilerArgs += "-progressive"
} }
} }
} }
@ -71,7 +73,7 @@ kotlin {
sourceSets.all { sourceSets.all {
languageSettings.progressiveMode = true languageSettings.progressiveMode = true
languageSettings.enableLanguageFeature("InlineClasses") languageSettings.enableLanguageFeature("InlineClasses")
languageSettings.useExperimentalAnnotation("ExperimentalContracts") //languageSettings.useExperimentalAnnotation("ExperimentalContracts")
//languageSettings.enableLanguageFeature("Contracts") //languageSettings.enableLanguageFeature("Contracts")
} }
} }
@ -116,4 +118,3 @@ kotlin {
} }
} }

View File

@ -1,23 +1,14 @@
plugins { plugins {
kotlin("multiplatform") `multiplatform-config`
} }
val ioVersion: String by rootProject.extra kotlin.sourceSets {
kotlin {
jvm()
js()
sourceSets {
commonMain { commonMain {
dependencies { dependencies {
api(project(":kmath-memory")) api(project(":kmath-memory"))
} }
} }
// mingwMain { //mingwMain {}
// } //mingwTest {}
// mingwTest {
// }
}
} }

View File

@ -1,44 +1,22 @@
plugins { plugins {
kotlin("multiplatform") `multiplatform-config`
} }
kotlin { kotlin.sourceSets {
jvm()
js()
sourceSets.invoke {
commonMain { commonMain {
dependencies { dependencies {
api(project(":kmath-core")) api(project(":kmath-core"))
api("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Ver.coroutinesVersion}") api("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Ver.coroutinesVersion}")
} }
} }
commonTest { jvmMain {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
"jvmMain" {
dependencies { dependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Ver.coroutinesVersion}") api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Ver.coroutinesVersion}")
} }
} }
"jvmTest" { jsMain {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
"jsMain" {
dependencies { dependencies {
api("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${Ver.coroutinesVersion}") api("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${Ver.coroutinesVersion}")
} }
} }
"jsTest" {
dependencies {
implementation(kotlin("test-js"))
}
}
}
} }

View File

@ -1,33 +1,10 @@
plugins { plugins {
kotlin("multiplatform") `multiplatform-config`
} }
kotlin { // Just an example how we can collapse nested DSL for simple declarations
jvm() kotlin.sourceSets.commonMain {
js()
sourceSets.invoke {
commonMain {
dependencies { dependencies {
api(project(":kmath-core")) api(project(":kmath-core"))
} }
} }
commonTest {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
"jvmTest" {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
"jsTest" {
dependencies {
implementation(kotlin("test-js"))
}
}
}
}

View File

@ -1,57 +1,31 @@
plugins { plugins {
kotlin("multiplatform") `multiplatform-config`
} }
repositories { repositories {
maven("http://dl.bintray.com/kyonifer/maven") maven("http://dl.bintray.com/kyonifer/maven")
} }
kotlin { kotlin.sourceSets {
jvm { commonMain {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += "-progressive"
}
}
}
js()
sourceSets {
val commonMain by getting {
dependencies { dependencies {
api(project(":kmath-core")) api(project(":kmath-core"))
api("com.kyonifer:koma-core-api-common:0.12") api("com.kyonifer:koma-core-api-common:0.12")
} }
} }
val commonTest by getting { jvmMain {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting {
dependencies { dependencies {
api("com.kyonifer:koma-core-api-jvm:0.12") api("com.kyonifer:koma-core-api-jvm:0.12")
} }
} }
val jvmTest by getting { jvmTest {
dependencies { dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
implementation("com.kyonifer:koma-core-ejml:0.12") implementation("com.kyonifer:koma-core-ejml:0.12")
} }
} }
val jsMain by getting { jsMain {
dependencies { dependencies {
api("com.kyonifer:koma-core-api-js:0.12") api("com.kyonifer:koma-core-api-js:0.12")
} }
} }
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
}
} }

View File

@ -1,16 +1,3 @@
plugins { plugins {
kotlin("multiplatform") `multiplatform-config`
}
val ioVersion: String by rootProject.extra
kotlin {
jvm()
js()
// mingwMain {
// }
// mingwTest {
// }
} }

View File

@ -1,35 +1,28 @@
plugins { plugins {
kotlin("multiplatform") `multiplatform-config`
id("kotlinx-atomicfu") id("kotlinx-atomicfu") version Ver.atomicfuVersion
} }
val atomicfuVersion: String by rootProject.extra kotlin.sourceSets {
commonMain {
kotlin {
jvm ()
js()
sourceSets {
val commonMain by getting {
dependencies { dependencies {
api(project(":kmath-core")) api(project(":kmath-core"))
api(project(":kmath-coroutines")) api(project(":kmath-coroutines"))
compileOnly("org.jetbrains.kotlinx:atomicfu-common:${Ver.atomicfuVersion}") compileOnly("org.jetbrains.kotlinx:atomicfu-common:${Ver.atomicfuVersion}")
} }
} }
val jvmMain by getting { jvmMain {
dependencies { dependencies {
compileOnly("org.jetbrains.kotlinx:atomicfu:${Ver.atomicfuVersion}") compileOnly("org.jetbrains.kotlinx:atomicfu:${Ver.atomicfuVersion}")
} }
} }
val jsMain by getting { jsMain {
dependencies { dependencies {
compileOnly("org.jetbrains.kotlinx:atomicfu-js:${Ver.atomicfuVersion}") compileOnly("org.jetbrains.kotlinx:atomicfu-js:${Ver.atomicfuVersion}")
} }
} }
} }
}
atomicfu { atomicfu {
variant = "VH" variant = "VH"

View File

@ -1,9 +1,9 @@
plugins { plugins {
kotlin("multiplatform") kotlin("multiplatform")
id("kotlinx-atomicfu") id("kotlinx-atomicfu") version Ver.atomicfuVersion
} }
val atomicfuVersion: String by rootProject.extra
kotlin { kotlin {
jvm () jvm ()

View File

@ -8,9 +8,7 @@ pluginManagement {
eachPlugin { eachPlugin {
when (requested.id.id) { when (requested.id.id) {
"kotlinx-atomicfu" -> { "kotlinx-atomicfu" -> {
// Just hardcode version here, useModule("org.jetbrains.kotlinx:atomicfu-gradle-plugin:${requested.version}")
// because anyway different submodules cannot use different versions
useModule("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.12.1")
} }
} }
} }