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

@ -21,7 +21,7 @@ dependencies {
//jmh project(':kmath-core') //jmh project(':kmath-core')
} }
jmh{ jmh {
warmupIterations = 1 warmupIterations = 1
} }

View File

@ -1,36 +1,33 @@
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")
} }
// dokka {
plugins.withType<KotlinMultiplatformPlugin> { // outputFormat = "html"
apply(plugin = "multiplatform-config") // outputDirectory = javadoc.destinationDir
// dokka { // }
// outputFormat = "html" //
// outputDirectory = javadoc.destinationDir // task dokkaJar (type: Jar, dependsOn: dokka) {
// } // from javadoc . destinationDir
// // classifier = "javadoc"
// task dokkaJar (type: Jar, dependsOn: dokka) {
// from javadoc . destinationDir
// 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,45 +8,37 @@ 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( val populateNodeModules by tasks.registering(Copy::class) {
crossinline action: T.() -> Unit dependsOn(compileKotlinJs)
): RegisteringDomainObjectDelegateProviderWithTypeAndAction<TaskContainer, T> = from(compileKotlinJs.destinationDir)
RegisteringDomainObjectDelegateProviderWithTypeAndAction.of(this, T::class, { action() })
kotlin.js().compilations["test"].runtimeDependencyFiles.forEach {
configure<KotlinMultiplatformExtension> { if (it.exists() && !it.isDirectory) {
from(zipTree(it.absolutePath).matching { include("*.js") })
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> { into("$buildDir/node_modules")
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)
} }
val installMocha by tasks.registering(NpmTask::class) {
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)

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 {
commonMain {
dependencies {
kotlin { api(project(":kmath-memory"))
jvm()
js()
sourceSets {
commonMain {
dependencies {
api(project(":kmath-memory"))
}
} }
// mingwMain {
// }
// mingwTest {
// }
} }
//mingwMain {}
//mingwTest {}
} }

View File

@ -1,44 +1,22 @@
plugins { plugins {
kotlin("multiplatform") `multiplatform-config`
} }
kotlin { kotlin.sourceSets {
jvm() commonMain {
js() dependencies {
api(project(":kmath-core"))
sourceSets.invoke { api("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Ver.coroutinesVersion}")
commonMain {
dependencies {
api(project(":kmath-core"))
api("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Ver.coroutinesVersion}")
}
} }
commonTest { }
dependencies { jvmMain {
implementation(kotlin("test-common")) dependencies {
implementation(kotlin("test-annotations-common")) api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Ver.coroutinesVersion}")
}
} }
"jvmMain" { }
dependencies { jsMain {
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Ver.coroutinesVersion}") dependencies {
} api("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${Ver.coroutinesVersion}")
}
"jvmTest" {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
"jsMain" {
dependencies {
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() dependencies {
api(project(":kmath-core"))
sourceSets.invoke {
commonMain {
dependencies {
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 { dependencies {
kotlinOptions { api(project(":kmath-core"))
jvmTarget = "1.8" api("com.kyonifer:koma-core-api-common:0.12")
freeCompilerArgs += "-progressive"
}
} }
} }
js() jvmMain {
dependencies {
sourceSets { api("com.kyonifer:koma-core-api-jvm:0.12")
val commonMain by getting {
dependencies {
api(project(":kmath-core"))
api("com.kyonifer:koma-core-api-common:0.12")
}
} }
val commonTest by getting { }
dependencies { jvmTest {
implementation(kotlin("test-common")) dependencies {
implementation(kotlin("test-annotations-common")) implementation("com.kyonifer:koma-core-ejml:0.12")
}
} }
val jvmMain by getting { }
dependencies { jsMain {
api("com.kyonifer:koma-core-api-jvm:0.12") dependencies {
} api("com.kyonifer:koma-core-api-js:0.12")
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
implementation("com.kyonifer:koma-core-ejml:0.12")
}
}
val jsMain by getting {
dependencies {
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,34 +1,27 @@
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 { dependencies {
jvm () api(project(":kmath-core"))
js() api(project(":kmath-coroutines"))
compileOnly("org.jetbrains.kotlinx:atomicfu-common:${Ver.atomicfuVersion}")
sourceSets {
val commonMain by getting {
dependencies {
api(project(":kmath-core"))
api(project(":kmath-coroutines"))
compileOnly("org.jetbrains.kotlinx:atomicfu-common:${Ver.atomicfuVersion}")
}
} }
val jvmMain by getting {
dependencies {
compileOnly("org.jetbrains.kotlinx:atomicfu:${Ver.atomicfuVersion}")
}
}
val jsMain by getting {
dependencies {
compileOnly("org.jetbrains.kotlinx:atomicfu-js:${Ver.atomicfuVersion}")
}
}
} }
jvmMain {
dependencies {
compileOnly("org.jetbrains.kotlinx:atomicfu:${Ver.atomicfuVersion}")
}
}
jsMain {
dependencies {
compileOnly("org.jetbrains.kotlinx:atomicfu-js:${Ver.atomicfuVersion}")
}
}
} }
atomicfu { atomicfu {

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")
} }
} }
} }