From 6dfd71c1fe128b85e698206bf6f44a28e01b51ca Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 27 Sep 2020 19:40:05 +0300 Subject: [PATCH 1/9] Bump versions --- build.gradle.kts | 4 ++-- src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9f9a287..44c02d0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.6.1" +version = "0.6.1-dev-1.4.20-M1" repositories { gradlePluginPortal() @@ -16,7 +16,7 @@ repositories { maven("https://dl.bintray.com/kotlin/kotlin-dev") } -val kotlinVersion = "1.4.10" +val kotlinVersion = "1.4.20-M1" java { targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt index 5016871..8889c66 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt @@ -6,14 +6,15 @@ import org.gradle.api.JavaVersion * Build constants */ object KScienceVersions { + const val kotlinVersion = "1.4.20-M1" const val coroutinesVersion = "1.3.9" - const val serializationVersion = "1.0.0-RC" + const val serializationVersion = "1.0.0-RC2" const val atomicVersion = "0.14.4" val JVM_TARGET = JavaVersion.VERSION_11 object Serialization{ - const val xmlVersion = "0.80.0-RC"//to be fixed + const val xmlVersion = "0.80.0-RC" const val yamlVersion = "0.21.0" const val bsonVersion = "0.4.1-rc" } From 96bfd552195ad1accdfe21874d64ede81940be01 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 28 Sep 2020 11:47:08 +0300 Subject: [PATCH 2/9] Add plugable json serialization --- build.gradle.kts | 2 +- src/main/kotlin/ru/mipt/npm/gradle/serialization.kt | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 44c02d0..d7b576c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.6.1-dev-1.4.20-M1" +version = "0.6.2-dev-1.4.20-M1" repositories { gradlePluginPortal() diff --git a/src/main/kotlin/ru/mipt/npm/gradle/serialization.kt b/src/main/kotlin/ru/mipt/npm/gradle/serialization.kt index a5eb039..28d5d33 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/serialization.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/serialization.kt @@ -8,6 +8,17 @@ class SerializationTargets( val sourceSet: DependencySourceSet, val configuration: DependencyConfiguration ) { + + fun Project.json( + version: String = KScienceVersions.serializationVersion + ) { + useCommonDependency( + "org.jetbrains.kotlinx:kotlinx-serialization-json:$version", + dependencySourceSet = sourceSet, + dependencyConfiguration = configuration + ) + } + fun Project.cbor( version: String = KScienceVersions.serializationVersion ) { From 774596bbf65053836a33debc0ab1522a5d1a156c Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 30 Sep 2020 20:43:02 +0300 Subject: [PATCH 3/9] Remove node to a separate plugin --- CHANGELOG.md | 21 +++++----- build.gradle.kts | 7 ++++ .../ru/mipt/npm/gradle/KScienceExtension.kt | 7 +++- .../ru/mipt/npm/gradle/KScienceJSPlugin.kt | 3 +- .../ru/mipt/npm/gradle/KScienceMPPlugin.kt | 1 - .../ru/mipt/npm/gradle/KScienceNodePlugin.kt | 42 +++++++++++++++++++ .../mipt/npm/gradle/KScienceProjectPlugin.kt | 3 ++ .../ru/mipt/npm/gradle/KScienceVersions.kt | 1 + 8 files changed, 71 insertions(+), 14 deletions(-) create mode 100644 src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index a55859c..3735e34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,19 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -- Changelog plugin automatically applied to `project` -- Feature matrix and Readme generation task for a `project` plugin +- Changelog plugin automatically applied to `project`. +- Feature matrix and Readme generation task for a `project` plugin. +- Add `binary-compatibility-validator` to the `project` plugin. ### Changed -- Remove node plugin and make node binaries available by default -- Use default webpack distribution path -- `ru.mipt.npm.base` -> `ru.mipt.npm.project` +- Remove node plugin. Node binaries should be turned on manually. +- Use default webpack distribution path. +- `ru.mipt.npm.base` -> `ru.mipt.npm.project`. - Move publishing out of general extension and apply it to project plugin instead. ### Deprecated ### Removed -- Node plugin +- Node plugin. ### Fixed @@ -28,14 +29,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Migrate to kotlin 1.4.0 -- Separate Native (current platform) and nodeJs plugins +- Separate Native (current platform) and nodeJs plugins. - Add `application()` toggle in plugin configuration to produce binaries on JS and applicaion plugin on jvm. -- Add `publish` to expose publishing configuration +- Add `publish` to expose publishing configuration. ### Changed --Publishing in bintray now is automatic +-Publishing in bintray now is automatic. ## [0.5.2] ### Added -- Copy resources for jvm modules and jvm source sets in mpp \ No newline at end of file +- Copy resources for jvm modules and jvm source sets in mpp. \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index d7b576c..c43ecf9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,6 +30,7 @@ dependencies { implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.10") implementation("org.jetbrains.dokka:dokka-base:1.4.10") implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:0.5.0") + implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.2.3") } gradlePlugin { @@ -68,6 +69,12 @@ gradlePlugin { description = "Additional native targets to be use alongside mpp" implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin" } + + create("kscience.node") { + id = "ru.mipt.npm.node" + description = "Additional nodejs target to be use alongside mpp" + implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin" + } } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt index 150c2ca..305c2f3 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt @@ -1,6 +1,7 @@ package ru.mipt.npm.gradle import org.gradle.api.Project +import org.gradle.api.plugins.ApplicationPlugin import org.gradle.kotlin.dsl.findByType import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension @@ -70,14 +71,17 @@ class KScienceExtension(val project: Project) { project.extensions.findByType()?.apply { explicitApi = null } + project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { - project.plugins.apply("org.gradle.application") + project.plugins.apply(ApplicationPlugin::class.java) } + project.extensions.findByType()?.apply { js { binaries.executable() } } + project.extensions.findByType()?.apply { js { binaries.executable() @@ -86,7 +90,6 @@ class KScienceExtension(val project: Project) { binaries.executable() } } - } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt index 6f150ac..bacfbcd 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt @@ -18,10 +18,11 @@ open class KScienceJSPlugin : Plugin { configure { explicitApiWarning() + js(IR) { browser() - nodejs() } + sourceSets["main"].apply { languageSettings.applySettings() diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt index 7675142..eda2baf 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt @@ -27,7 +27,6 @@ open class KScienceMPPlugin : Plugin { js(IR) { browser() - nodejs() } sourceSets.invoke { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt new file mode 100644 index 0000000..66ea1c9 --- /dev/null +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt @@ -0,0 +1,42 @@ +package ru.mipt.npm.gradle + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.* +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension + +/** + * Create a separate target for node + */ +class KScienceNodePlugin : Plugin { + override fun apply(target: Project) = target.run { + //Apply multiplatform plugin is not applied, apply it + if (plugins.findPlugin(KScienceMPPlugin::class) == null) { + logger.info("Multiplatform KScience plugin is not resolved. Adding it automatically") + pluginManager.apply(KScienceMPPlugin::class) + } + + configure { + js(name = "node", compiler = IR) { + nodejs() + } + sourceSets { + val commonMain by getting + val nodeMain by creating { + dependsOn(commonMain) + dependencies{ + api("org.jetbrains.kotlinx:kotlinx-nodejs:${KScienceVersions.kotlinxNodeVersion}") + } + } + + val commonTest by getting + + val nodeTest by creating { + dependsOn(nodeMain) + dependsOn(commonTest) + } + } + } + + } +} \ No newline at end of file diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt index 29baf02..942334a 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt @@ -1,6 +1,7 @@ package ru.mipt.npm.gradle import groovy.text.SimpleTemplateEngine +import kotlinx.validation.BinaryCompatibilityValidatorPlugin import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.* @@ -101,6 +102,8 @@ open class KScienceProjectPlugin : Plugin { override fun apply(target: Project): Unit = target.run { apply() apply() + apply() + val rootReadmeExtension = KScienceReadmeExtension(this) extensions.add("ksciencePublish", KSciencePublishingExtension(this)) extensions.add("readme", rootReadmeExtension) diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt index 8889c66..08018bc 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt @@ -7,6 +7,7 @@ import org.gradle.api.JavaVersion */ object KScienceVersions { const val kotlinVersion = "1.4.20-M1" + const val kotlinxNodeVersion = "0.0.7" const val coroutinesVersion = "1.3.9" const val serializationVersion = "1.0.0-RC2" const val atomicVersion = "0.14.4" From 2fc4bb1f3d7d09acc707fdc86ea2f1c24a0d480d Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 2 Oct 2020 19:07:10 +0300 Subject: [PATCH 4/9] Fix JS resource copy --- build.gradle.kts | 2 +- .../ru/mipt/npm/gradle/KScienceJSPlugin.kt | 13 +-- .../ru/mipt/npm/gradle/KScienceJVMPlugin.kt | 7 +- .../ru/mipt/npm/gradle/KScienceMPPlugin.kt | 16 +-- src/main/kotlin/ru/mipt/npm/gradle/common.kt | 107 +++++++----------- 5 files changed, 52 insertions(+), 93 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c43ecf9..55e810f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.6.2-dev-1.4.20-M1" +version = "0.6.3-dev-1.4.20-M1" repositories { gradlePluginPortal() diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt index bacfbcd..579abc6 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt @@ -40,17 +40,8 @@ open class KScienceJSPlugin : Plugin { } tasks.apply { - - val processResources by getting(Copy::class) - processResources.copyJSResources(configurations["runtimeClasspath"]) - - findByName("jsBrowserDistribution")?.apply { - doLast { - val indexFile = project.jsDistDirectory.resolve("index.html") - if (indexFile.exists()) { - println("Run JS distribution at: ${indexFile.canonicalPath}") - } - } + val processResources by getting(Copy::class) { + fromDependencies("runtimeClasspath") } } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt index 0c6d26e..f3a6d1b 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt @@ -5,7 +5,6 @@ import org.gradle.api.Project import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPublication -import org.gradle.api.tasks.Copy import org.gradle.api.tasks.bundling.Jar import org.gradle.api.tasks.testing.Test import org.gradle.kotlin.dsl.* @@ -78,9 +77,9 @@ open class KScienceJVMPlugin : Plugin { withType() { useJUnitPlatform() } - - val processResources by getting(Copy::class) - processResources.copyJVMResources(configurations["runtimeClasspath"]) +// +// val processResources by getting(Copy::class) +// processResources.copyJVMResources(configurations["runtimeClasspath"]) } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt index eda2baf..bebd47a 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt @@ -89,20 +89,10 @@ open class KScienceMPPlugin : Plugin { useJUnitPlatform() } - val jsProcessResources by getting(Copy::class) - jsProcessResources.copyJSResources(configurations["jsRuntimeClasspath"]) - - val jvmProcessResources by getting(Copy::class) - jvmProcessResources.copyJVMResources(configurations["jvmRuntimeClasspath"]) - - findByName("jsBrowserDistribution")?.apply { - doLast { - val indexFile = project.jsDistDirectory.resolve("index.html") - if (indexFile.exists()) { - println("Run JS distribution at: ${indexFile.canonicalPath}") - } - } + val jsProcessResources by getting(Copy::class) { + fromDependencies("jsRuntimeClasspath") } + } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/common.kt b/src/main/kotlin/ru/mipt/npm/gradle/common.kt index 9b33cb5..1cbfebc 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/common.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/common.kt @@ -1,13 +1,11 @@ package ru.mipt.npm.gradle -import org.gradle.api.Project -import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.ProjectDependency import org.gradle.api.artifacts.dsl.RepositoryHandler import org.gradle.api.tasks.Copy +import org.gradle.kotlin.dsl.get import org.gradle.kotlin.dsl.maven import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder -import java.io.File internal fun LanguageSettingsBuilder.applySettings(): Unit { progressiveMode = true @@ -31,73 +29,54 @@ internal fun RepositoryHandler.applyRepos(): Unit { maven("https://dl.bintray.com/mipt-npm/dataforge") } - -internal fun Copy.copyJSResources(configuration: Configuration): Unit = project.afterEvaluate { - val projectDeps = configuration - .allDependencies - .filterIsInstance() - .map { it.dependencyProject } - - val destination = destinationDir - - projectDeps.forEach { dep -> - dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { - dep.tasks.findByName("jsProcessResources")?.let { task -> - val sourceDir = (task as Copy).destinationDir - inputs.files(sourceDir) - dependsOn(task) - from(sourceDir) - } - } - dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") { - dep.tasks.findByName("processResources")?.let { task -> - val sourceDir = (task as Copy).destinationDir - inputs.files(sourceDir) - dependsOn(task) - from(sourceDir) - } - } +internal fun Copy.fromDependencies(configurationName: String) = project.afterEvaluate { + val configuration = configurations[configurationName] + ?: error("Configuration with name $configurationName could not be resolved.") + val projectDeps = configuration.allDependencies.filterIsInstance().map { + it.dependencyProject } -} - -internal fun Copy.copyJVMResources(configuration: Configuration): Unit = project.afterEvaluate { - val projectDeps = configuration - .allDependencies - .filterIsInstance() - .map { it.dependencyProject } - - val destination = destinationDir - + into(buildDir.resolve("processedResources/js")) projectDeps.forEach { dep -> - dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { - dep.tasks.findByName("jvmProcessResources")?.let { task -> - val sourceDir = (task as Copy).destinationDir - inputs.files(sourceDir) - dependsOn(task) - from(sourceDir) + dep.afterEvaluate { + dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { + dep.tasks.findByName("jsProcessResources")?.let { task -> + dependsOn(task) + from(task) + //from(dep.buildDir.resolve("processedResources/js")) + } + //from(dep.buildDir.resolve("processedResources/js")) } - } - dep.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { - dep.tasks.findByName("processResources")?.let { task -> - val sourceDir = (task as Copy).destinationDir - inputs.files(sourceDir) - dependsOn(task) - from(sourceDir) + dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") { + dep.tasks.findByName("processResources")?.let { task -> + dependsOn(task) + from(task) + //from(dep.buildDir.resolve("processedResources/js")) + } + // from(dep.buildDir.resolve("processedResources/js")) } } } } -val Project.jsDistDirectory: File - get() { - val distributionName = listOf( - name, - "js", - version.toString() - ).joinToString("-") - - return buildDir.resolve( - "distributions/$distributionName" - ) - } \ No newline at end of file +// +//internal fun Copy.copyJVMResources(configuration: Configuration): Unit = project.afterEvaluate { +// val projectDeps = configuration.allDependencies +// .filterIsInstance() +// .map { it.dependencyProject } +// +// projectDeps.forEach { dep -> +// dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { +// dep.tasks.findByName("jvmProcessResources")?.let { task -> +// dependsOn(task) +// from(task) +// } +// } +// dep.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { +// dep.tasks.findByName("processResources")?.let { task -> +// dependsOn(task) +// from(task) +// } +// } +// } +//} \ No newline at end of file From f44a0aaa3ef038ef850d23ce3c1e800d371122b2 Mon Sep 17 00:00:00 2001 From: darksnake Date: Tue, 20 Oct 2020 08:38:40 +0300 Subject: [PATCH 5/9] Update kotlin to 1.4.20-M2 Update serialization to 1.0.0 --- build.gradle.kts | 6 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../kotlin/ru/mipt/npm/gradle/KScienceVersions.kt | 8 ++++---- src/main/kotlin/ru/mipt/npm/gradle/serialization.kt | 11 ++--------- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 55e810f..d49f099 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,11 +2,11 @@ plugins { `java-gradle-plugin` `kotlin-dsl` `maven-publish` - id("org.jetbrains.changelog") version "0.5.0" + id("org.jetbrains.changelog") version "0.6.2" } group = "ru.mipt.npm" -version = "0.6.3-dev-1.4.20-M1" +version = "0.6.3-dev-1.4.20-M2" repositories { gradlePluginPortal() @@ -16,7 +16,7 @@ repositories { maven("https://dl.bintray.com/kotlin/kotlin-dev") } -val kotlinVersion = "1.4.20-M1" +val kotlinVersion = "1.4.20-M2" java { targetCompatibility = JavaVersion.VERSION_1_8 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 12d38de..be52383 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt index 08018bc..0144c66 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt @@ -6,17 +6,17 @@ import org.gradle.api.JavaVersion * Build constants */ object KScienceVersions { - const val kotlinVersion = "1.4.20-M1" + const val kotlinVersion = "1.4.20-M2" const val kotlinxNodeVersion = "0.0.7" const val coroutinesVersion = "1.3.9" - const val serializationVersion = "1.0.0-RC2" + const val serializationVersion = "1.0.0" const val atomicVersion = "0.14.4" val JVM_TARGET = JavaVersion.VERSION_11 object Serialization{ - const val xmlVersion = "0.80.0-RC" + const val xmlVersion = "0.80.1" const val yamlVersion = "0.21.0" - const val bsonVersion = "0.4.1-rc" + const val bsonVersion = "0.4.2" } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/serialization.kt b/src/main/kotlin/ru/mipt/npm/gradle/serialization.kt index 28d5d33..b0859f3 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/serialization.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/serialization.kt @@ -1,8 +1,6 @@ package ru.mipt.npm.gradle import org.gradle.api.Project -import org.gradle.kotlin.dsl.maven -import org.gradle.kotlin.dsl.repositories class SerializationTargets( val sourceSet: DependencySourceSet, @@ -42,13 +40,8 @@ class SerializationTargets( fun Project.xml( version: String = KScienceVersions.Serialization.xmlVersion ) { - repositories { - maven("https://dl.bintray.com/pdvrieze/maven") - } - useDependency( - "common" to "net.devrieze:xmlutil-serialization:$version", - "jvm" to "net.devrieze:xmlutil-serialization:$version", - "js" to "net.devrieze:xmlutil-serialization:$version", + useCommonDependency( + "net.devrieze:xmlutil-serialization:$version", dependencySourceSet = sourceSet, dependencyConfiguration = configuration ) From 152578aaf74aced40b4179c438ae42dcc22961cd Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 20 Oct 2020 09:56:01 +0300 Subject: [PATCH 6/9] Bump version --- build.gradle.kts | 2 +- .../ru/mipt/npm/gradle/KScienceJVMPlugin.kt | 39 +++---------------- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d49f099..20b5880 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.6.3-dev-1.4.20-M2" +version = "0.6.4-dev-1.4.20-M2" repositories { gradlePluginPortal() diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt index f3a6d1b..6367268 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt @@ -3,11 +3,11 @@ package ru.mipt.npm.gradle import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.JavaPluginExtension -import org.gradle.api.publish.PublishingExtension -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.api.tasks.bundling.Jar import org.gradle.api.tasks.testing.Test -import org.gradle.kotlin.dsl.* +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.findByType +import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.withType import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -20,6 +20,8 @@ open class KScienceJVMPlugin : Plugin { extensions.findByType()?.apply { targetCompatibility = KScienceVersions.JVM_TARGET + withSourcesJar() + //withJavadocJar() } tasks.withType { @@ -42,35 +44,6 @@ open class KScienceJVMPlugin : Plugin { implementation("org.junit.jupiter:junit-jupiter:5.6.1") } } - - val sourcesJar by tasks.registering(Jar::class) { - archiveClassifier.set("sources") - from(sourceSet.kotlin.srcDirs.first()) - } - - pluginManager.withPlugin("maven-publish") { - - configure { - publications { - register("jvm", MavenPublication::class) { - from(components["java"]) - artifact(sourcesJar.get()) - } - } - } - -// pluginManager.withPlugin("org.jetbrains.dokka") { -// logger.info("Adding dokka functionality to project ${project.name}") - -// val dokkaHtml by tasks.getting(DokkaTask::class){ -// dokkaSourceSets { -// configureEach { -// jdkVersion.set(11) -// } -// } -// } -// } - } } tasks.apply { From f456be46d425b0bf87d4ad8783b502cec1389dbb Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 25 Nov 2020 12:16:09 +0300 Subject: [PATCH 7/9] Centralized logic for all plugins --- CHANGELOG.md | 4 + build.gradle.kts | 15 +- .../mipt/npm/gradle/KScienceCommonPlugin.kt | 138 ++++++++++++++++++ .../ru/mipt/npm/gradle/KScienceJSPlugin.kt | 45 +----- .../ru/mipt/npm/gradle/KScienceJVMPlugin.kt | 54 +------ .../ru/mipt/npm/gradle/KScienceMPPlugin.kt | 99 +------------ .../mipt/npm/gradle/KScienceNativePlugin.kt | 11 +- .../ru/mipt/npm/gradle/KScienceNodePlugin.kt | 11 +- .../ru/mipt/npm/gradle/KScienceVersions.kt | 8 +- ...rialization.kt => SerializationTargets.kt} | 16 ++ src/main/kotlin/ru/mipt/npm/gradle/common.kt | 1 + 11 files changed, 210 insertions(+), 192 deletions(-) create mode 100644 src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt rename src/main/kotlin/ru/mipt/npm/gradle/{serialization.kt => SerializationTargets.kt} (79%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3735e34..ef4e7dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,14 +10,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Changelog plugin automatically applied to `project`. - Feature matrix and Readme generation task for a `project` plugin. - Add `binary-compatibility-validator` to the `project` plugin. +- Separate `yamlKt` serialization target +- Separate `ain` plugin ### Changed - Remove node plugin. Node binaries should be turned on manually. - Use default webpack distribution path. - `ru.mipt.npm.base` -> `ru.mipt.npm.project`. - Move publishing out of general extension and apply it to project plugin instead. +- Platform plugins are now simple references to common plugin ### Deprecated +- Support of `kaml` and `snake-yaml` in favor of `yamlKt` ### Removed - Node plugin. diff --git a/build.gradle.kts b/build.gradle.kts index 20b5880..8317e59 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.6.4-dev-1.4.20-M2" +version = "0.7.0" repositories { gradlePluginPortal() @@ -16,7 +16,7 @@ repositories { maven("https://dl.bintray.com/kotlin/kotlin-dev") } -val kotlinVersion = "1.4.20-M2" +val kotlinVersion = "1.4.20" java { targetCompatibility = JavaVersion.VERSION_1_8 @@ -27,14 +27,19 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion") implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.14.4") - implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.10") + implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.10.2") implementation("org.jetbrains.dokka:dokka-base:1.4.10") - implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:0.5.0") - implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.2.3") + implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:0.6.2") + implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.2.4") } gradlePlugin { plugins { + create("kscience.common"){ + id = "ru.mipt.npm.kscience" + description = "The generalized kscience plugin that works in conjunction with any kotlin plugin" + implementationClass = "ru.mipt.npm.gradle.KScienceCommonPlugin" + } create("kscience.project"){ id = "ru.mipt.npm.project" description = "The root plugin for multimodule project infrastructure" diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt new file mode 100644 index 0000000..124926c --- /dev/null +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt @@ -0,0 +1,138 @@ +package ru.mipt.npm.gradle + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginExtension +import org.gradle.api.tasks.Copy +import org.gradle.api.tasks.testing.Test +import org.gradle.kotlin.dsl.* +import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension + +open class KScienceCommonPlugin : Plugin { + override fun apply(project: Project): Unit = project.run { + //Common configuration + registerKScienceExtension() + repositories.applyRepos() + + //Configuration for K-JVM plugin + pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { + configure { + explicitApiWarning() + + sourceSets["main"].apply { + languageSettings.applySettings() + } + + sourceSets["test"].apply { + languageSettings.applySettings() + dependencies { + implementation(kotlin("test-junit5")) + implementation("org.junit.jupiter:junit-jupiter:5.6.1") + } + } + } + } + + pluginManager.withPlugin("org.jetbrains.kotlin.js") { + configure { + explicitApiWarning() + + js(IR) { + browser() + } + + sourceSets["main"].apply { + languageSettings.applySettings() + } + + sourceSets["test"].apply { + languageSettings.applySettings() + dependencies { + implementation(kotlin("test-js")) + } + } + } + } + + pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { + configure { + explicitApiWarning() + + jvm { + compilations.all { + kotlinOptions { +// useIR = true + jvmTarget = KScienceVersions.JVM_TARGET.toString() + } + } + } + + js(IR) { + browser() + } + + sourceSets.invoke { + val commonMain by getting + val commonTest by getting { + dependencies { + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + } + } + val jvmMain by getting + val jvmTest by getting { + dependencies { + implementation(kotlin("test-junit5")) + implementation("org.junit.jupiter:junit-jupiter:5.6.1") + } + } + val jsMain by getting + val jsTest by getting { + dependencies { + implementation(kotlin("test-js")) + } + } + } + + afterEvaluate { + targets.all { + sourceSets.all { + languageSettings.applySettings() + } + } + } + } + } + + afterEvaluate { + extensions.findByType()?.apply { + targetCompatibility = KScienceVersions.JVM_TARGET + withSourcesJar() + //withJavadocJar() + } + + tasks.apply { + withType { + kotlinOptions { +// useIR = true + jvmTarget = KScienceVersions.JVM_TARGET.toString() + } + } + withType { + useJUnitPlatform() + } + + (findByName("processResources") as? Copy)?.apply { + fromDependencies("runtimeClasspath") + } + + (findByName("jsProcessResources") as? Copy)?.apply { + fromDependencies("jsRuntimeClasspath") + } + } + } + } +} diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt index 579abc6..75de0f4 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt @@ -2,48 +2,15 @@ package ru.mipt.npm.gradle import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.tasks.Copy -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.get -import org.gradle.kotlin.dsl.getValue -import org.gradle.kotlin.dsl.getting -import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension +import org.gradle.kotlin.dsl.apply open class KScienceJSPlugin : Plugin { override fun apply(project: Project): Unit = project.run { - plugins.apply("org.jetbrains.kotlin.js") - registerKScienceExtension() - - repositories.applyRepos() - - configure { - explicitApiWarning() - - js(IR) { - browser() - } - - sourceSets["main"].apply { - languageSettings.applySettings() - - dependencies { - api(kotlin("stdlib-js")) - } - } - - sourceSets["test"].apply { - languageSettings.applySettings() - dependencies { - implementation(kotlin("test-js")) - } - } - } - - tasks.apply { - val processResources by getting(Copy::class) { - fromDependencies("runtimeClasspath") - } + if (plugins.findPlugin("org.jetbrains.kotlin.js") == null) { + pluginManager.apply("org.jetbrains.kotlin.js") + } else { + logger.info("Kotlin JS plugin is already present") } + plugins.apply(KScienceCommonPlugin::class) } - } \ No newline at end of file diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt index 6367268..eaaab4d 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt @@ -2,58 +2,16 @@ package ru.mipt.npm.gradle import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.plugins.JavaPluginExtension -import org.gradle.api.tasks.testing.Test -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.findByType -import org.gradle.kotlin.dsl.get -import org.gradle.kotlin.dsl.withType -import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.gradle.kotlin.dsl.apply open class KScienceJVMPlugin : Plugin { override fun apply(project: Project): Unit = project.run { - plugins.apply("org.jetbrains.kotlin.jvm") - registerKScienceExtension() - - repositories.applyRepos() - - extensions.findByType()?.apply { - targetCompatibility = KScienceVersions.JVM_TARGET - withSourcesJar() - //withJavadocJar() - } - - tasks.withType { - kotlinOptions { -// useIR = true - jvmTarget = KScienceVersions.JVM_TARGET.toString() - } - } - - configure { - explicitApiWarning() - val sourceSet = sourceSets["main"].apply { - languageSettings.applySettings() - } - - sourceSets["test"].apply { - languageSettings.applySettings() - dependencies { - implementation(kotlin("test-junit5")) - implementation("org.junit.jupiter:junit-jupiter:5.6.1") - } - } - } - - tasks.apply { - withType() { - useJUnitPlatform() - } -// -// val processResources by getting(Copy::class) -// processResources.copyJVMResources(configurations["runtimeClasspath"]) + if (plugins.findPlugin("org.jetbrains.kotlin.jvm") == null) { + pluginManager.apply("org.jetbrains.kotlin.jvm") + } else { + logger.info("Kotlin JVM plugin is already present") } + plugins.apply(KScienceCommonPlugin::class) } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt index bebd47a..ef0a7de 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt @@ -2,99 +2,16 @@ package ru.mipt.npm.gradle import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.tasks.Copy -import org.gradle.api.tasks.testing.Test -import org.gradle.kotlin.dsl.* -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.findPlugin +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin open class KScienceMPPlugin : Plugin { override fun apply(project: Project): Unit = project.run { - plugins.apply("org.jetbrains.kotlin.multiplatform") - registerKScienceExtension() - repositories.applyRepos() - - configure { - explicitApiWarning() - - jvm { - compilations.all { - kotlinOptions { -// useIR = true - jvmTarget = KScienceVersions.JVM_TARGET.toString() - } - } - } - - js(IR) { - browser() - } - - sourceSets.invoke { - val commonMain by getting - val commonTest by getting { - dependencies { - implementation(kotlin("test-common")) - implementation(kotlin("test-annotations-common")) - } - } - val jvmMain by getting - val jvmTest by getting { - dependencies { - implementation(kotlin("test-junit5")) - implementation("org.junit.jupiter:junit-jupiter:5.6.1") - } - } - val jsMain by getting - val jsTest by getting { - dependencies { - implementation(kotlin("test-js")) - } - } - } - - afterEvaluate { - targets.all { - sourceSets.all { - languageSettings.applySettings() - } - } - } - -// pluginManager.withPlugin("org.jetbrains.dokka") { -// logger.info("Adding dokka functionality to project ${this@run.name}") -// -// val dokkaHtml by tasks.getting(DokkaTask::class) { -// dokkaSourceSets { -// register("commonMain") { -// displayName = "common" -// platform = "common" -// } -// register("jvmMain") { -// displayName = "jvm" -// platform = "jvm" -// } -// register("jsMain") { -// displayName = "js" -// platform = "js" -// } -// configureEach { -// jdkVersion = 11 -// } -// } -// } -// } - - tasks.apply { - withType { - useJUnitPlatform() - } - - val jsProcessResources by getting(Copy::class) { - fromDependencies("jsRuntimeClasspath") - } - - } - + if (plugins.findPlugin(KotlinMultiplatformPlugin::class) == null) { + logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically") + pluginManager.apply(KotlinMultiplatformPlugin::class) } - } + plugins.apply(KScienceCommonPlugin::class) + } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt index 6169787..80c5cdf 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt @@ -5,13 +5,18 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.* import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin class KScienceNativePlugin : Plugin { override fun apply(target: Project) = target.run { //Apply multiplatform plugin is not applied, apply it - if (plugins.findPlugin(KScienceMPPlugin::class) == null) { - logger.info("Multiplatform KScience plugin is not resolved. Adding it automatically") - pluginManager.apply(KScienceMPPlugin::class) + if (plugins.findPlugin(KotlinMultiplatformPlugin::class) == null) { + logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically") + pluginManager.apply(KotlinMultiplatformPlugin::class) + } + if (plugins.findPlugin(KScienceCommonPlugin::class) == null) { + logger.info("KScience plugin is not resolved. Adding it automatically") + pluginManager.apply(KScienceCommonPlugin::class) } configure { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt index 66ea1c9..a65229c 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt @@ -4,6 +4,7 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.* import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin /** * Create a separate target for node @@ -11,9 +12,13 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension class KScienceNodePlugin : Plugin { override fun apply(target: Project) = target.run { //Apply multiplatform plugin is not applied, apply it - if (plugins.findPlugin(KScienceMPPlugin::class) == null) { - logger.info("Multiplatform KScience plugin is not resolved. Adding it automatically") - pluginManager.apply(KScienceMPPlugin::class) + if (plugins.findPlugin(KotlinMultiplatformPlugin::class) == null) { + logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically") + pluginManager.apply(KotlinMultiplatformPlugin::class) + } + if (plugins.findPlugin(KScienceCommonPlugin::class) == null) { + logger.info("KScience plugin is not resolved. Adding it automatically") + pluginManager.apply(KScienceCommonPlugin::class) } configure { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt index 0144c66..4cf4049 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt @@ -6,17 +6,19 @@ import org.gradle.api.JavaVersion * Build constants */ object KScienceVersions { - const val kotlinVersion = "1.4.20-M2" + const val kotlinVersion = "1.4.20" const val kotlinxNodeVersion = "0.0.7" - const val coroutinesVersion = "1.3.9" - const val serializationVersion = "1.0.0" + const val coroutinesVersion = "1.4.1" + const val serializationVersion = "1.0.1" const val atomicVersion = "0.14.4" val JVM_TARGET = JavaVersion.VERSION_11 object Serialization{ const val xmlVersion = "0.80.1" + @Deprecated("Use yamlKt instead") const val yamlVersion = "0.21.0" const val bsonVersion = "0.4.2" + const val yamlKtVersion = "0.7.4" } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/serialization.kt b/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt similarity index 79% rename from src/main/kotlin/ru/mipt/npm/gradle/serialization.kt rename to src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt index b0859f3..dc762f6 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/serialization.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt @@ -1,6 +1,8 @@ package ru.mipt.npm.gradle import org.gradle.api.Project +import org.gradle.kotlin.dsl.maven +import org.gradle.kotlin.dsl.repositories class SerializationTargets( val sourceSet: DependencySourceSet, @@ -40,6 +42,9 @@ class SerializationTargets( fun Project.xml( version: String = KScienceVersions.Serialization.xmlVersion ) { + repositories { + maven("https://dl.bintray.com/pdvrieze/maven") + } useCommonDependency( "net.devrieze:xmlutil-serialization:$version", dependencySourceSet = sourceSet, @@ -47,6 +52,7 @@ class SerializationTargets( ) } + @Deprecated("Use multiplatform yamlKt instead") fun Project.yaml( version: String = KScienceVersions.Serialization.yamlVersion ) { @@ -57,6 +63,16 @@ class SerializationTargets( ) } + fun Project.yamlKt( + version: String = KScienceVersions.Serialization.yamlVersion + ) { + useCommonDependency( + "net.mamoe.yamlkt:yamlkt:$version", + dependencySourceSet = sourceSet, + dependencyConfiguration = configuration + ) + } + fun Project.bson( version: String = KScienceVersions.Serialization.bsonVersion ) { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/common.kt b/src/main/kotlin/ru/mipt/npm/gradle/common.kt index 1cbfebc..790296e 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/common.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/common.kt @@ -15,6 +15,7 @@ internal fun LanguageSettingsBuilder.applySettings(): Unit { useExperimentalAnnotation("kotlin.ExperimentalStdlibApi") useExperimentalAnnotation("kotlin.time.ExperimentalTime") useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts") + useExperimentalAnnotation("kotlin.js.ExperimentalJsExport") } internal fun RepositoryHandler.applyRepos(): Unit { From 723a959a0bf5e081391e3b35720035bb7d72c600 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 25 Nov 2020 14:26:08 +0300 Subject: [PATCH 8/9] Fix dependency configuration --- .../mipt/npm/gradle/KScienceCommonPlugin.kt | 4 +- .../ru/mipt/npm/gradle/KScienceMPPlugin.kt | 6 +- .../mipt/npm/gradle/KScienceNativePlugin.kt | 5 +- .../ru/mipt/npm/gradle/KScienceNodePlugin.kt | 5 +- .../kotlin/ru/mipt/npm/gradle/dependencies.kt | 104 +++++++++--------- 5 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt index 124926c..ace2634 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt @@ -19,6 +19,7 @@ open class KScienceCommonPlugin : Plugin { //Configuration for K-JVM plugin pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { + //logger.info("Applying KScience configuration for JVM project") configure { explicitApiWarning() @@ -37,6 +38,7 @@ open class KScienceCommonPlugin : Plugin { } pluginManager.withPlugin("org.jetbrains.kotlin.js") { + //logger.info("Applying KScience configuration for JS project") configure { explicitApiWarning() @@ -117,7 +119,7 @@ open class KScienceCommonPlugin : Plugin { tasks.apply { withType { kotlinOptions { -// useIR = true + // useIR = true jvmTarget = KScienceVersions.JVM_TARGET.toString() } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt index ef0a7de..92a97d3 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt @@ -3,14 +3,12 @@ package ru.mipt.npm.gradle import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.findPlugin -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin open class KScienceMPPlugin : Plugin { override fun apply(project: Project): Unit = project.run { - if (plugins.findPlugin(KotlinMultiplatformPlugin::class) == null) { + if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) { logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically") - pluginManager.apply(KotlinMultiplatformPlugin::class) + pluginManager.apply("org.jetbrains.kotlin.multiplatform") } plugins.apply(KScienceCommonPlugin::class) } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt index 80c5cdf..c507d49 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt @@ -5,14 +5,13 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.* import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin class KScienceNativePlugin : Plugin { override fun apply(target: Project) = target.run { //Apply multiplatform plugin is not applied, apply it - if (plugins.findPlugin(KotlinMultiplatformPlugin::class) == null) { + if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) { logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically") - pluginManager.apply(KotlinMultiplatformPlugin::class) + pluginManager.apply("org.jetbrains.kotlin.multiplatform") } if (plugins.findPlugin(KScienceCommonPlugin::class) == null) { logger.info("KScience plugin is not resolved. Adding it automatically") diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt index a65229c..473424e 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt @@ -4,7 +4,6 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.* import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin /** * Create a separate target for node @@ -12,9 +11,9 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin class KScienceNodePlugin : Plugin { override fun apply(target: Project) = target.run { //Apply multiplatform plugin is not applied, apply it - if (plugins.findPlugin(KotlinMultiplatformPlugin::class) == null) { + if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) { logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically") - pluginManager.apply(KotlinMultiplatformPlugin::class) + pluginManager.apply("org.jetbrains.kotlin.multiplatform") } if (plugins.findPlugin(KScienceCommonPlugin::class) == null) { logger.info("KScience plugin is not resolved. Adding it automatically") diff --git a/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt b/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt index 4dcea9b..472d82a 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt @@ -1,8 +1,7 @@ package ru.mipt.npm.gradle -import kotlinx.atomicfu.plugin.gradle.sourceSets import org.gradle.api.Project -import org.gradle.kotlin.dsl.findByType +import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.invoke import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension @@ -23,7 +22,7 @@ internal fun Project.useDependency( dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION ) { pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { - extensions.findByType()?.apply { + configure { sourceSets { pairs.forEach { (target, dep) -> val name = target + dependencySourceSet.suffix @@ -38,37 +37,39 @@ internal fun Project.useDependency( } } } - } - } - pairs.find { it.first == "jvm" }?.let { dep -> - pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { - sourceSets.findByName(dependencySourceSet.setName)?.apply { - dependencies.apply { - val configurationName = when (dependencyConfiguration) { - DependencyConfiguration.API -> apiConfigurationName - DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName - DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName + + pairs.find { it.first == "jvm" }?.let { dep -> + pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { + sourceSets.findByName(dependencySourceSet.setName)?.apply { + dependencies.apply { + val configurationName = when (dependencyConfiguration) { + DependencyConfiguration.API -> apiConfigurationName + DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName + DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName + } + add(configurationName, dep.second) + } + } + } + } + + pairs.find { it.first == "js" }?.let { dep -> + pluginManager.withPlugin("org.jetbrains.kotlin.js") { + sourceSets.findByName(dependencySourceSet.setName)?.apply { + dependencies.apply { + val configurationName = when (dependencyConfiguration) { + DependencyConfiguration.API -> apiConfigurationName + DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName + DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName + } + add(configurationName, dep.second) + } } - add(configurationName, dep.second) } } } - } - pairs.find { it.first == "js" }?.let { dep -> - pluginManager.withPlugin("org.jetbrains.kotlin.js") { - sourceSets.findByName(dependencySourceSet.setName)?.apply { - dependencies.apply { - val configurationName = when (dependencyConfiguration) { - DependencyConfiguration.API -> apiConfigurationName - DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName - DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName - } - add(configurationName, dep.second) - } - } - } } } @@ -76,9 +77,9 @@ internal fun Project.useCommonDependency( dep: String, dependencySourceSet: DependencySourceSet = DependencySourceSet.MAIN, dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION -): Unit = pluginManager.run{ - withPlugin("org.jetbrains.kotlin.multiplatform"){ - extensions.findByType()?.apply { +): Unit = pluginManager.run { + withPlugin("org.jetbrains.kotlin.multiplatform") { + configure { sourceSets.findByName("common${dependencySourceSet.suffix}")?.apply { dependencies { when (dependencyConfiguration) { @@ -88,29 +89,30 @@ internal fun Project.useCommonDependency( } } } - } - } - withPlugin("org.jetbrains.kotlin.jvm") { - sourceSets.findByName(dependencySourceSet.setName)?.apply { - dependencies.apply { - val configurationName = when (dependencyConfiguration) { - DependencyConfiguration.API -> apiConfigurationName - DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName - DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName + + withPlugin("org.jetbrains.kotlin.jvm") { + sourceSets.findByName(dependencySourceSet.setName)?.apply { + dependencies.apply { + val configurationName = when (dependencyConfiguration) { + DependencyConfiguration.API -> apiConfigurationName + DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName + DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName + } + add(configurationName, dep) + } } - add(configurationName, dep) } - } - } - withPlugin("org.jetbrains.kotlin.js") { - sourceSets.findByName(dependencySourceSet.setName)?.apply { - dependencies.apply { - val configurationName = when (dependencyConfiguration) { - DependencyConfiguration.API -> apiConfigurationName - DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName - DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName + withPlugin("org.jetbrains.kotlin.js") { + sourceSets.findByName(dependencySourceSet.setName)?.apply { + dependencies.apply { + val configurationName = when (dependencyConfiguration) { + DependencyConfiguration.API -> apiConfigurationName + DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName + DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName + } + add(configurationName, dep) + } } - add(configurationName, dep) } } } From be571a90282679fee415e748e9647b46ca19ab1d Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 25 Nov 2020 15:25:46 +0300 Subject: [PATCH 9/9] Fix dependency configuration --- .../mipt/npm/gradle/KScienceCommonPlugin.kt | 2 +- .../kotlin/ru/mipt/npm/gradle/dependencies.kt | 97 ++++++++++--------- 2 files changed, 54 insertions(+), 45 deletions(-) diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt index ace2634..fdf6f90 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt @@ -112,7 +112,7 @@ open class KScienceCommonPlugin : Plugin { afterEvaluate { extensions.findByType()?.apply { targetCompatibility = KScienceVersions.JVM_TARGET - withSourcesJar() + //withSourcesJar() //withJavadocJar() } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt b/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt index 472d82a..78dc949 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt @@ -3,6 +3,8 @@ package ru.mipt.npm.gradle import org.gradle.api.Project import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.invoke +import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension enum class DependencyConfiguration { @@ -37,39 +39,41 @@ internal fun Project.useDependency( } } } + } + } - - pairs.find { it.first == "jvm" }?.let { dep -> - pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { - sourceSets.findByName(dependencySourceSet.setName)?.apply { - dependencies.apply { - val configurationName = when (dependencyConfiguration) { - DependencyConfiguration.API -> apiConfigurationName - DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName - DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName - } - add(configurationName, dep.second) - } - } - } - } - - pairs.find { it.first == "js" }?.let { dep -> - pluginManager.withPlugin("org.jetbrains.kotlin.js") { - sourceSets.findByName(dependencySourceSet.setName)?.apply { - dependencies.apply { - val configurationName = when (dependencyConfiguration) { - DependencyConfiguration.API -> apiConfigurationName - DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName - DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName - } - add(configurationName, dep.second) + pairs.find { it.first == "jvm" }?.let { dep -> + pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { + configure { + sourceSets.findByName(dependencySourceSet.setName)?.apply { + dependencies.apply { + val configurationName = when (dependencyConfiguration) { + DependencyConfiguration.API -> apiConfigurationName + DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName + DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName } + add(configurationName, dep.second) } } } } + } + pairs.find { it.first == "js" }?.let { dep -> + pluginManager.withPlugin("org.jetbrains.kotlin.js") { + configure { + sourceSets.findByName(dependencySourceSet.setName)?.apply { + dependencies.apply { + val configurationName = when (dependencyConfiguration) { + DependencyConfiguration.API -> apiConfigurationName + DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName + DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName + } + add(configurationName, dep.second) + } + } + } + } } } @@ -89,29 +93,34 @@ internal fun Project.useCommonDependency( } } } + } + } - withPlugin("org.jetbrains.kotlin.jvm") { - sourceSets.findByName(dependencySourceSet.setName)?.apply { - dependencies.apply { - val configurationName = when (dependencyConfiguration) { - DependencyConfiguration.API -> apiConfigurationName - DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName - DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName - } - add(configurationName, dep) + + withPlugin("org.jetbrains.kotlin.jvm") { + configure { + sourceSets.findByName(dependencySourceSet.setName)?.apply { + dependencies.apply { + val configurationName = when (dependencyConfiguration) { + DependencyConfiguration.API -> apiConfigurationName + DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName + DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName } + add(configurationName, dep) } } - withPlugin("org.jetbrains.kotlin.js") { - sourceSets.findByName(dependencySourceSet.setName)?.apply { - dependencies.apply { - val configurationName = when (dependencyConfiguration) { - DependencyConfiguration.API -> apiConfigurationName - DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName - DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName - } - add(configurationName, dep) + } + } + withPlugin("org.jetbrains.kotlin.js") { + configure { + sourceSets.findByName(dependencySourceSet.setName)?.apply { + dependencies.apply { + val configurationName = when (dependencyConfiguration) { + DependencyConfiguration.API -> apiConfigurationName + DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName + DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName } + add(configurationName, dep) } } }