diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle index 989590397..7c948e219 100644 --- a/benchmarks/build.gradle +++ b/benchmarks/build.gradle @@ -21,7 +21,7 @@ dependencies { //jmh project(':kmath-core') } -jmh{ +jmh { warmupIterations = 1 } diff --git a/build.gradle.kts b/build.gradle.kts index 49592b0d7..0084793bd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,36 +1,33 @@ -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin - val kmathVersion by extra("0.1.2-dev-1") allprojects { +// apply(plugin = "maven") +// apply(plugin = "maven-publish") +// apply(plugin = "com.jfrog.artifactory") + repositories { jcenter() maven("https://kotlin.bintray.com/kotlinx") } + group = "scientifik" version = kmathVersion } subprojects { + // Actually, probably we should apply it to plugins explicitly + // We also can merge them to single kmath-publish plugin if (name.startsWith("kmath")) { - // apply bintray configuration apply(plugin = "bintray-config") - - //apply artifactory configuration apply(plugin = "artifactory-config") } - - plugins.withType { - apply(plugin = "multiplatform-config") -// dokka { -// outputFormat = "html" -// outputDirectory = javadoc.destinationDir -// } -// -// task dokkaJar (type: Jar, dependsOn: dokka) { -// from javadoc . destinationDir -// classifier = "javadoc" + // dokka { +// outputFormat = "html" +// outputDirectory = javadoc.destinationDir // } - } - -} \ No newline at end of file +// +// task dokkaJar (type: Jar, dependsOn: dokka) { +// from javadoc . destinationDir +// classifier = "javadoc" +// } +} diff --git a/buildSrc/src/main/kotlin/Dep.kt b/buildSrc/src/main/kotlin/Dep.kt index ab7a243a7..87f963643 100644 --- a/buildSrc/src/main/kotlin/Dep.kt +++ b/buildSrc/src/main/kotlin/Dep.kt @@ -4,7 +4,7 @@ object Ver { val ioVersion = "0.1.5" 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 val dokkaVersion = "0.9.17" } diff --git a/buildSrc/src/main/kotlin/js-test.gradle.kts b/buildSrc/src/main/kotlin/js-test.gradle.kts index 1f49b2c3b..61759a28a 100644 --- a/buildSrc/src/main/kotlin/js-test.gradle.kts +++ b/buildSrc/src/main/kotlin/js-test.gradle.kts @@ -1,7 +1,6 @@ -import com.moowork.gradle.node.NodeExtension import com.moowork.gradle.node.npm.NpmTask 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 plugins { @@ -9,45 +8,37 @@ plugins { kotlin("multiplatform") } -configure { +node { nodeModulesDir = file("$buildDir/node_modules") } val compileKotlinJs by tasks.getting(Kotlin2JsCompile::class) val compileTestKotlinJs by tasks.getting(Kotlin2JsCompile::class) -inline fun TaskContainer.registering( - crossinline action: T.() -> Unit -): RegisteringDomainObjectDelegateProviderWithTypeAndAction = - RegisteringDomainObjectDelegateProviderWithTypeAndAction.of(this, T::class, { action() }) +val populateNodeModules by tasks.registering(Copy::class) { + dependsOn(compileKotlinJs) + from(compileKotlinJs.destinationDir) - -configure { - - 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") }) - } + 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 { - 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) + into("$buildDir/node_modules") } +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) + + diff --git a/buildSrc/src/main/kotlin/multiplatform-config.gradle.kts b/buildSrc/src/main/kotlin/multiplatform-config.gradle.kts index 0b845aa76..2fd7fab00 100644 --- a/buildSrc/src/main/kotlin/multiplatform-config.gradle.kts +++ b/buildSrc/src/main/kotlin/multiplatform-config.gradle.kts @@ -11,6 +11,8 @@ kotlin { compilations.all { kotlinOptions { 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 { languageSettings.progressiveMode = true languageSettings.enableLanguageFeature("InlineClasses") - languageSettings.useExperimentalAnnotation("ExperimentalContracts") + //languageSettings.useExperimentalAnnotation("ExperimentalContracts") //languageSettings.enableLanguageFeature("Contracts") } } @@ -116,4 +118,3 @@ kotlin { } } - diff --git a/kmath-core/build.gradle.kts b/kmath-core/build.gradle.kts index 108ee75fa..b24d41a87 100644 --- a/kmath-core/build.gradle.kts +++ b/kmath-core/build.gradle.kts @@ -1,23 +1,14 @@ plugins { - kotlin("multiplatform") + `multiplatform-config` } -val ioVersion: String by rootProject.extra - - -kotlin { - jvm() - js() - - sourceSets { - commonMain { - dependencies { - api(project(":kmath-memory")) - } +kotlin.sourceSets { + commonMain { + dependencies { + api(project(":kmath-memory")) } -// mingwMain { -// } -// mingwTest { -// } } + //mingwMain {} + //mingwTest {} } + diff --git a/kmath-coroutines/build.gradle.kts b/kmath-coroutines/build.gradle.kts index 1da34e0d7..e72514803 100644 --- a/kmath-coroutines/build.gradle.kts +++ b/kmath-coroutines/build.gradle.kts @@ -1,44 +1,22 @@ plugins { - kotlin("multiplatform") + `multiplatform-config` } -kotlin { - jvm() - js() - - sourceSets.invoke { - commonMain { - dependencies { - api(project(":kmath-core")) - api("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Ver.coroutinesVersion}") - } +kotlin.sourceSets { + commonMain { + dependencies { + api(project(":kmath-core")) + api("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:${Ver.coroutinesVersion}") } - commonTest { - dependencies { - implementation(kotlin("test-common")) - implementation(kotlin("test-annotations-common")) - } + } + jvmMain { + dependencies { + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Ver.coroutinesVersion}") } - "jvmMain" { - dependencies { - api("org.jetbrains.kotlinx:kotlinx-coroutines-core:${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")) - } + } + jsMain { + dependencies { + api("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:${Ver.coroutinesVersion}") } } } diff --git a/kmath-histograms/build.gradle.kts b/kmath-histograms/build.gradle.kts index 2e9210843..cdae1ad09 100644 --- a/kmath-histograms/build.gradle.kts +++ b/kmath-histograms/build.gradle.kts @@ -1,33 +1,10 @@ plugins { - kotlin("multiplatform") + `multiplatform-config` } -kotlin { - jvm() - js() - - 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")) - } - } +// Just an example how we can collapse nested DSL for simple declarations +kotlin.sourceSets.commonMain { + dependencies { + api(project(":kmath-core")) } -} +} \ No newline at end of file diff --git a/kmath-koma/build.gradle.kts b/kmath-koma/build.gradle.kts index b95aaf3c8..5942182d5 100644 --- a/kmath-koma/build.gradle.kts +++ b/kmath-koma/build.gradle.kts @@ -1,57 +1,31 @@ plugins { - kotlin("multiplatform") + `multiplatform-config` } repositories { maven("http://dl.bintray.com/kyonifer/maven") } -kotlin { - jvm { - compilations.all { - kotlinOptions { - jvmTarget = "1.8" - freeCompilerArgs += "-progressive" - } +kotlin.sourceSets { + commonMain { + dependencies { + api(project(":kmath-core")) + api("com.kyonifer:koma-core-api-common:0.12") } } - js() - - sourceSets { - - val commonMain by getting { - dependencies { - api(project(":kmath-core")) - api("com.kyonifer:koma-core-api-common:0.12") - } - } - val commonTest by getting { - dependencies { - implementation(kotlin("test-common")) - implementation(kotlin("test-annotations-common")) - } - } - val jvmMain by getting { - dependencies { - api("com.kyonifer:koma-core-api-jvm: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")) - } + jvmMain { + dependencies { + api("com.kyonifer:koma-core-api-jvm:0.12") } } -} \ No newline at end of file + jvmTest { + dependencies { + implementation("com.kyonifer:koma-core-ejml:0.12") + } + } + jsMain { + dependencies { + api("com.kyonifer:koma-core-api-js:0.12") + } + } +} diff --git a/kmath-memory/build.gradle.kts b/kmath-memory/build.gradle.kts index 03a05c9fe..c42d35c3a 100644 --- a/kmath-memory/build.gradle.kts +++ b/kmath-memory/build.gradle.kts @@ -1,16 +1,3 @@ plugins { - kotlin("multiplatform") + `multiplatform-config` } - -val ioVersion: String by rootProject.extra - - -kotlin { - jvm() - js() -// mingwMain { -// } -// mingwTest { -// } - -} \ No newline at end of file diff --git a/kmath-prob/build.gradle.kts b/kmath-prob/build.gradle.kts index 45979c89f..26449f6d4 100644 --- a/kmath-prob/build.gradle.kts +++ b/kmath-prob/build.gradle.kts @@ -1,36 +1,29 @@ plugins { - kotlin("multiplatform") - id("kotlinx-atomicfu") + `multiplatform-config` + id("kotlinx-atomicfu") version Ver.atomicfuVersion } -val atomicfuVersion: String by rootProject.extra - -kotlin { - jvm () - js() - - sourceSets { - val commonMain by getting { - dependencies { - api(project(":kmath-core")) - api(project(":kmath-coroutines")) - compileOnly("org.jetbrains.kotlinx:atomicfu-common:${Ver.atomicfuVersion}") - } +kotlin.sourceSets { + commonMain { + 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 { variant = "VH" -} \ No newline at end of file +} diff --git a/kmath-streaming/build.gradle.kts b/kmath-streaming/build.gradle.kts index 45979c89f..562fe1c57 100644 --- a/kmath-streaming/build.gradle.kts +++ b/kmath-streaming/build.gradle.kts @@ -1,9 +1,9 @@ plugins { kotlin("multiplatform") - id("kotlinx-atomicfu") + id("kotlinx-atomicfu") version Ver.atomicfuVersion } -val atomicfuVersion: String by rootProject.extra + kotlin { jvm () diff --git a/settings.gradle.kts b/settings.gradle.kts index f8a3797ae..32ac77e48 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,9 +8,7 @@ pluginManagement { eachPlugin { when (requested.id.id) { "kotlinx-atomicfu" -> { - // Just hardcode version here, - // because anyway different submodules cannot use different versions - useModule("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.12.1") + useModule("org.jetbrains.kotlinx:atomicfu-gradle-plugin:${requested.version}") } } }