From b8635df01c2986b6723c840e33f3171c9195429b Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 22 Sep 2020 16:21:09 +0300 Subject: [PATCH 01/21] Add Readme generator --- CHANGELOG.md | 19 +++ build.gradle.kts | 15 +- .../ru/mipt/npm/gradle/KScienceBasePlugin.kt | 13 -- .../ru/mipt/npm/gradle/KScienceExtension.kt | 25 +--- .../ru/mipt/npm/gradle/KScienceJSPlugin.kt | 10 +- .../ru/mipt/npm/gradle/KScienceMPPlugin.kt | 12 +- .../ru/mipt/npm/gradle/KScienceNodePlugin.kt | 28 ---- .../mipt/npm/gradle/KScienceProjectPlugin.kt | 133 ++++++++++++++++++ .../mipt/npm/gradle/KSciencePublishPlugin.kt | 3 +- 9 files changed, 164 insertions(+), 94 deletions(-) delete mode 100644 src/main/kotlin/ru/mipt/npm/gradle/KScienceBasePlugin.kt delete mode 100644 src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt create mode 100644 src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c559f..a55859c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,25 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- Changelog plugin automatically applied to `project` +- Feature matrix and Readme generation task for a `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` +- Move publishing out of general extension and apply it to project plugin instead. + +### Deprecated + +### Removed +- Node plugin + +### Fixed + +### Security +## [0.6.0] ### Added - Migrate to kotlin 1.4.0 diff --git a/build.gradle.kts b/build.gradle.kts index 07fa8c6..85c1824 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.6.0" +version = "0.6.1" repositories { gradlePluginPortal() @@ -29,13 +29,14 @@ dependencies { implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.14.4") implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.0") implementation("org.jetbrains.dokka:dokka-base:1.4.0") + implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:0.5.0") } gradlePlugin { plugins { - create("kscience.base"){ - id = "ru.mipt.npm.base" - description = "The basic plugin that does not do anything but loading classpath, versions and extensions" + create("kscience.project"){ + id = "ru.mipt.npm.project" + description = "The root plugin for multimodule project infrastructure" implementationClass = "ru.mipt.npm.gradle.KScienceBasePlugin" } create("kscience.publish") { @@ -67,12 +68,6 @@ 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 = "NodeJS target for kotlin-mpp and kotlin-js" - implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin" - } } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceBasePlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceBasePlugin.kt deleted file mode 100644 index 341be36..0000000 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceBasePlugin.kt +++ /dev/null @@ -1,13 +0,0 @@ -package ru.mipt.npm.gradle - -import org.gradle.api.Plugin -import org.gradle.api.Project - -/** - * Apply extension and repositories - */ -open class KScienceBasePlugin : Plugin { - override fun apply(target: Project): Unit = target.run{ - registerKScienceExtension() - } -} \ No newline at end of file diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt index 0a19219..150c2ca 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt @@ -1,7 +1,7 @@ package ru.mipt.npm.gradle import org.gradle.api.Project -import org.gradle.kotlin.dsl.* +import org.gradle.kotlin.dsl.findByType import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension @@ -88,29 +88,6 @@ class KScienceExtension(val project: Project) { } } - - /** - * Activate publishing and configure it - */ - fun publish(block: Publishing.() -> Unit = {}) = Publishing().apply(block) - - inner class Publishing { - init { - if (project.plugins.findPlugin(KSciencePublishPlugin::class) == null) { - project.plugins.apply(KSciencePublishPlugin::class) - } - } - - var githubOrg: String? by project.extra - var githubProject: String? by project.extra - var spaceRepo: String? by project.extra - var spaceUser: String? by project.extra - var spaceToken: String? by project.extra - var bintrayOrg: String? by project.extra - var bintrayUser: String? by project.extra - var bintrayApiKey: String? by project.extra - var bintrayRepo: String? by project.extra - } } internal fun Project.registerKScienceExtension() { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt index aa1a822..6f150ac 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt @@ -19,14 +19,8 @@ open class KScienceJSPlugin : Plugin { configure { explicitApiWarning() js(IR) { - browser { - webpackTask { - outputFileName = "main.bundle.js" - } - distribution { - directory = project.jsDistDirectory - } - } + 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 85baece..7675142 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt @@ -26,14 +26,8 @@ open class KScienceMPPlugin : Plugin { } js(IR) { - browser { - webpackTask { - outputFileName = "main.bundle.js" - } - distribution { - directory = project.jsDistDirectory - } - } + browser() + nodejs() } sourceSets.invoke { @@ -92,7 +86,7 @@ open class KScienceMPPlugin : Plugin { // } tasks.apply { - withType() { + withType { useJUnitPlatform() } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt deleted file mode 100644 index bba5346..0000000 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt +++ /dev/null @@ -1,28 +0,0 @@ -package ru.mipt.npm.gradle - -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.kotlin.dsl.configure -import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension - -class KScienceNodePlugin : Plugin { - override fun apply(target: Project) = target.run{ - pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { - configure { - js { - nodejs() - } - } - } - - pluginManager.withPlugin("org.jetbrains.kotlin.js") { - configure { - js { - nodejs() - } - } - } - } - -} \ 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 new file mode 100644 index 0000000..acd7ed5 --- /dev/null +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt @@ -0,0 +1,133 @@ +package ru.mipt.npm.gradle + +import groovy.text.SimpleTemplateEngine +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.extra +import org.gradle.kotlin.dsl.findByType +import org.gradle.kotlin.dsl.provideDelegate +import org.jetbrains.changelog.ChangelogPlugin +import kotlin.collections.component1 +import kotlin.collections.component2 + +class KSciencePublishingExtension(val project: Project) { + var githubOrg: String? by project.extra + var githubProject: String? by project.extra + var spaceRepo: String? by project.extra + var spaceUser: String? by project.extra + var spaceToken: String? by project.extra + var bintrayOrg: String? by project.extra + var bintrayUser: String? by project.extra + var bintrayApiKey: String? by project.extra + var bintrayRepo: String? by project.extra +} + +class KScienceReadmeExtension(val project: Project) { + val properties = HashMap() + var readmeStubPath: String = "docs/README-STUB.md" + val features = ArrayList() + + data class Feature(val id: String, val ref: String, val description: String, val name: String = id) + + + fun feature(id: String, ref: String, description: String, name: String = id) { + features.add(Feature(id, ref, description, name)) + } + + /** + * Generate a markdown string listing features + */ + fun featuresString(itemPrefix: String = " - ", pathPrefix: String = "") = buildString { + features.forEach { + appendln("$itemPrefix[${it.id}]($pathPrefix${it.ref}) : ${it.description}") + } + } + + /** + * Generate a readme string from the stub + */ + fun readmeString(): String? { + val readmeStubFile = project.file(readmeStubPath) + return if (readmeStubFile.exists()) { + buildString { + + val readmeProperties: Map = (properties + mapOf( + "name" to project.name, + "group" to project.group, + "version" to project.version, + "features" to featuresString() + )).withDefault { null } + SimpleTemplateEngine().createTemplate(readmeStubFile).make(properties).toString() + } + } else { + null + } + } +} + +/** + * Apply extension and repositories + */ +open class KScienceProjectPlugin : Plugin { + override fun apply(target: Project): Unit = target.run { + apply() + val rootReadmeExtension = KScienceReadmeExtension(this) + extensions.add("ksciencePublish", KSciencePublishingExtension(this)) + extensions.add("kscienceReadme", rootReadmeExtension) + + //Add readme generators to individual subprojects + subprojects { + val readmeExtension = KScienceReadmeExtension(this) + extensions.add("kscienceReadme", readmeExtension) + tasks.create("generateReadme") { + group = "documentation" + description = "Generate a README file if stub is present" + doLast { + val readmeString = readmeExtension.readmeString() + if (readmeString != null) { + val readmeFile = file("README.md") + readmeFile.writeText(readmeString) + } + } + } + } + + tasks.create("generateReadme") { + group = "documentation" + description = "Generate a README file and a feature matrix if stub is present" + + doLast { + val reader = groovy.json.JsonSlurper() + val projects = subprojects.associate { + it.name to it.extensions.findByType() + } + + + val rootReadmeStub = project.file(rootReadmeExtension.readmeStubPath) + if (rootReadmeStub.exists()) { + + val modulesString = buildString { + projects.entries.filter { !it.value?.features.isNullOrEmpty() }.forEach { (name, ext) -> + appendln("### [$name]($name)") + appendln(ext!!.featuresString(pathPrefix = "$name/")) + } + } + + val rootReadmeProperties: Map = mapOf( + "name" to project.name, + "group" to project.group, + "version" to project.version, + "modulesString" to modulesString + ) + + val readmeFile = project.file("README.md") + readmeFile.writeText( + SimpleTemplateEngine().createTemplate(rootReadmeStub).make(rootReadmeProperties).toString() + ) + } + + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt index e45ea06..7f13c79 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt @@ -11,9 +11,8 @@ import org.gradle.kotlin.dsl.withType open class KSciencePublishPlugin : Plugin { - override fun apply(project: Project): Unit = project.run{ + override fun apply(project: Project): Unit = project.run { plugins.apply("maven-publish") - registerKScienceExtension() afterEvaluate { val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm" -- 2.34.1 From 981687ee5e767069234ec17a0beb7ef793684531 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 25 Sep 2020 09:55:01 +0300 Subject: [PATCH 02/21] Readme template update --- build.gradle.kts | 4 +- .../mipt/npm/gradle/KScienceProjectPlugin.kt | 83 +++++++++++++------ 2 files changed, 59 insertions(+), 28 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 85c1824..50641e7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ plugins { `java-gradle-plugin` `kotlin-dsl` `maven-publish` - id("org.jetbrains.changelog") version "0.4.0" + id("org.jetbrains.changelog") version "0.5.0" } group = "ru.mipt.npm" @@ -37,7 +37,7 @@ gradlePlugin { create("kscience.project"){ id = "ru.mipt.npm.project" description = "The root plugin for multimodule project infrastructure" - implementationClass = "ru.mipt.npm.gradle.KScienceBasePlugin" + implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin" } create("kscience.publish") { id = "ru.mipt.npm.publish" diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt index acd7ed5..09a5a75 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt @@ -8,8 +8,10 @@ import org.gradle.kotlin.dsl.extra import org.gradle.kotlin.dsl.findByType import org.gradle.kotlin.dsl.provideDelegate import org.jetbrains.changelog.ChangelogPlugin +import java.io.File import kotlin.collections.component1 import kotlin.collections.component2 +import kotlin.reflect.KFunction class KSciencePublishingExtension(val project: Project) { var githubOrg: String? by project.extra @@ -23,18 +25,54 @@ class KSciencePublishingExtension(val project: Project) { var bintrayRepo: String? by project.extra } +enum class Maturity { + PROTOTYPE, + EXPERIMENTAL, + DEVELOPMENT, + PRODUCTION +} + class KScienceReadmeExtension(val project: Project) { - val properties = HashMap() - var readmeStubPath: String = "docs/README-STUB.md" - val features = ArrayList() + var description: String = "" + var maturity: Maturity = Maturity.EXPERIMENTAL + + var readmeTemplate: File = project.file("docs/README-TEMPLATE.md")//"docs/README-TEMPLATE.md" data class Feature(val id: String, val ref: String, val description: String, val name: String = id) + val features = ArrayList() fun feature(id: String, ref: String, description: String, name: String = id) { features.add(Feature(id, ref, description, name)) } + val properties: MutableMap = mutableMapOf( + "name" to project.name, + "group" to project.group, + "version" to project.version, + "features" to featuresString() + ) + + private val actualizedProperties get() = properties.mapValues {(_,value)-> + if(value is KFunction<*>){ + value.call() + } else { + value + } + } + + fun property(key: String, value: Any?) { + properties[key] = value + } + + fun propertyByTemplate(key: String, template: String){ + properties[key] = SimpleTemplateEngine().createTemplate(template).make(actualizedProperties).toString() + } + + fun propertyByTemplate(key: String, template: File){ + properties[key] = SimpleTemplateEngine().createTemplate(template).make(actualizedProperties).toString() + } + /** * Generate a markdown string listing features */ @@ -48,18 +86,8 @@ class KScienceReadmeExtension(val project: Project) { * Generate a readme string from the stub */ fun readmeString(): String? { - val readmeStubFile = project.file(readmeStubPath) - return if (readmeStubFile.exists()) { - buildString { - - val readmeProperties: Map = (properties + mapOf( - "name" to project.name, - "group" to project.group, - "version" to project.version, - "features" to featuresString() - )).withDefault { null } - SimpleTemplateEngine().createTemplate(readmeStubFile).make(properties).toString() - } + return if (readmeTemplate.exists()) { + SimpleTemplateEngine().createTemplate(readmeTemplate).make(actualizedProperties).toString() } else { null } @@ -74,19 +102,19 @@ open class KScienceProjectPlugin : Plugin { apply() val rootReadmeExtension = KScienceReadmeExtension(this) extensions.add("ksciencePublish", KSciencePublishingExtension(this)) - extensions.add("kscienceReadme", rootReadmeExtension) + extensions.add("readme", rootReadmeExtension) //Add readme generators to individual subprojects subprojects { val readmeExtension = KScienceReadmeExtension(this) - extensions.add("kscienceReadme", readmeExtension) + extensions.add("readme", readmeExtension) tasks.create("generateReadme") { group = "documentation" description = "Generate a README file if stub is present" doLast { val readmeString = readmeExtension.readmeString() if (readmeString != null) { - val readmeFile = file("README.md") + val readmeFile = this@subprojects.file("README.md") readmeFile.writeText(readmeString) } } @@ -103,27 +131,30 @@ open class KScienceProjectPlugin : Plugin { it.name to it.extensions.findByType() } - - val rootReadmeStub = project.file(rootReadmeExtension.readmeStubPath) - if (rootReadmeStub.exists()) { + if (rootReadmeExtension.readmeTemplate.exists()) { val modulesString = buildString { - projects.entries.filter { !it.value?.features.isNullOrEmpty() }.forEach { (name, ext) -> + projects.entries.forEach { (name, ext) -> appendln("### [$name]($name)") - appendln(ext!!.featuresString(pathPrefix = "$name/")) + if (ext != null) { + appendln(ext.description) + appendln("**Maturity**: ${ext.maturity}") + appendln("#### Features:") + appendln(ext.featuresString(pathPrefix = "$name/")) + } } } - val rootReadmeProperties: Map = mapOf( + val rootReadmeProperties: Map = mapOf( "name" to project.name, "group" to project.group, "version" to project.version, - "modulesString" to modulesString + "modules" to modulesString ) val readmeFile = project.file("README.md") readmeFile.writeText( - SimpleTemplateEngine().createTemplate(rootReadmeStub).make(rootReadmeProperties).toString() + SimpleTemplateEngine().createTemplate(rootReadmeExtension.readmeTemplate).make(rootReadmeProperties).toString() ) } -- 2.34.1 From f4e13a9979246ab8cace98fe6803968304850fd7 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 27 Sep 2020 17:45:40 +0300 Subject: [PATCH 03/21] Native deployment update --- build.gradle.kts | 4 +- .../mipt/npm/gradle/KScienceNativePlugin.kt | 67 +++++++--- .../mipt/npm/gradle/KScienceProjectPlugin.kt | 124 +++++++++++++----- 3 files changed, 144 insertions(+), 51 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 50641e7..9f9a287 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,8 +27,8 @@ 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.0") - implementation("org.jetbrains.dokka:dokka-base:1.4.0") + 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") } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt index c0d659c..6169787 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt @@ -15,24 +15,61 @@ class KScienceNativePlugin : Plugin { } configure { - val hostOs = System.getProperty("os.name") - val isMingwX64 = hostOs.startsWith("Windows") + val ideaActive = System.getProperty("idea.active") == "true" - val nativeTarget = when { - hostOs == "Mac OS X" -> macosX64("native") - hostOs == "Linux" -> linuxX64("native") - isMingwX64 -> { - mingwX64("native") - linuxX64() + if (ideaActive) { + //development mode + val hostOs = System.getProperty("os.name") + + when { + hostOs == "Mac OS X" -> macosX64("native") + hostOs == "Linux" -> linuxX64("native") + hostOs.startsWith("Windows") -> mingwX64("native") + else -> throw GradleException("Host OS is not supported in Kotlin/Native.") } - else -> throw GradleException("Host OS is not supported in Kotlin/Native.") - } + } else { + //deploy mode + linuxX64() + mingwX64() + macosX64() - sourceSets.invoke { - val nativeMain by getting - findByName("linuxX64Main")?.dependsOn(nativeMain) - val nativeTest by getting - findByName("linuxX64Test")?.dependsOn(nativeTest) + sourceSets{ + val commonMain by getting + val nativeMain by creating{ + dependsOn(commonMain) + } + + val commonTest by getting + + val nativeTest by creating{ + dependsOn(nativeMain) + dependsOn(commonTest) + } + + val linuxX64Main by getting{ + dependsOn(nativeMain) + } + + val mingwX64Main by getting{ + dependsOn(nativeMain) + } + + val macosX64Main by getting{ + dependsOn(nativeMain) + } + + val linuxX64Test by getting{ + dependsOn(nativeTest) + } + + val mingwX64Test by getting{ + dependsOn(nativeTest) + } + + val macosX64Test by getting{ + dependsOn(nativeTest) + } + } } } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt index 09a5a75..29baf02 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt @@ -3,15 +3,13 @@ package ru.mipt.npm.gradle import groovy.text.SimpleTemplateEngine import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.extra -import org.gradle.kotlin.dsl.findByType -import org.gradle.kotlin.dsl.provideDelegate +import org.gradle.kotlin.dsl.* import org.jetbrains.changelog.ChangelogPlugin +import org.jetbrains.dokka.gradle.DokkaPlugin +import org.jetbrains.dokka.gradle.DokkaTask import java.io.File import kotlin.collections.component1 import kotlin.collections.component2 -import kotlin.reflect.KFunction class KSciencePublishingExtension(val project: Project) { var githubOrg: String? by project.extra @@ -36,7 +34,7 @@ class KScienceReadmeExtension(val project: Project) { var description: String = "" var maturity: Maturity = Maturity.EXPERIMENTAL - var readmeTemplate: File = project.file("docs/README-TEMPLATE.md")//"docs/README-TEMPLATE.md" + var readmeTemplate: File = project.file("docs/README-TEMPLATE.md") data class Feature(val id: String, val ref: String, val description: String, val name: String = id) @@ -46,31 +44,32 @@ class KScienceReadmeExtension(val project: Project) { features.add(Feature(id, ref, description, name)) } - val properties: MutableMap = mutableMapOf( - "name" to project.name, - "group" to project.group, - "version" to project.version, - "features" to featuresString() + val properties: MutableMap Any?> = mutableMapOf( + "name" to { project.name }, + "group" to { project.group }, + "version" to { project.version }, + "features" to { featuresString() } ) - private val actualizedProperties get() = properties.mapValues {(_,value)-> - if(value is KFunction<*>){ - value.call() - } else { - value - } + private fun getActualizedProperties() = properties.mapValues { (_, value) -> + value.invoke() } fun property(key: String, value: Any?) { - properties[key] = value + properties[key] = {value} } - fun propertyByTemplate(key: String, template: String){ - properties[key] = SimpleTemplateEngine().createTemplate(template).make(actualizedProperties).toString() + fun propertyByTemplate(key: String, template: String) { + val actual = getActualizedProperties() + properties[key] = {SimpleTemplateEngine().createTemplate(template).make(actual).toString()} } - fun propertyByTemplate(key: String, template: File){ - properties[key] = SimpleTemplateEngine().createTemplate(template).make(actualizedProperties).toString() + internal val additionalFiles = ArrayList() + + fun propertyByTemplate(key: String, template: File) { + val actual = getActualizedProperties() + properties[key] = {SimpleTemplateEngine().createTemplate(template).make(actual).toString()} + additionalFiles.add(template) } /** @@ -87,7 +86,8 @@ class KScienceReadmeExtension(val project: Project) { */ fun readmeString(): String? { return if (readmeTemplate.exists()) { - SimpleTemplateEngine().createTemplate(readmeTemplate).make(actualizedProperties).toString() + val actual = getActualizedProperties() + SimpleTemplateEngine().createTemplate(readmeTemplate).make(actual).toString() } else { null } @@ -100,6 +100,7 @@ class KScienceReadmeExtension(val project: Project) { open class KScienceProjectPlugin : Plugin { override fun apply(target: Project): Unit = target.run { apply() + apply() val rootReadmeExtension = KScienceReadmeExtension(this) extensions.add("ksciencePublish", KSciencePublishingExtension(this)) extensions.add("readme", rootReadmeExtension) @@ -108,25 +109,57 @@ open class KScienceProjectPlugin : Plugin { subprojects { val readmeExtension = KScienceReadmeExtension(this) extensions.add("readme", readmeExtension) - tasks.create("generateReadme") { + val generateReadme by tasks.creating { group = "documentation" description = "Generate a README file if stub is present" + + if(readmeExtension.readmeTemplate.exists()) { + inputs.file(readmeExtension.readmeTemplate) + } + readmeExtension.additionalFiles.forEach { + if(it.exists()){ + inputs.file(it) + } + } + + val readmeFile = this@subprojects.file("README.md") + outputs.file(readmeFile) + doLast { val readmeString = readmeExtension.readmeString() if (readmeString != null) { - val readmeFile = this@subprojects.file("README.md") readmeFile.writeText(readmeString) } } } + tasks.withType{ + dependsOn(generateReadme) + } } - tasks.create("generateReadme") { + val generateReadme by tasks.creating { group = "documentation" description = "Generate a README file and a feature matrix if stub is present" + subprojects { + tasks.findByName("generateReadme")?.let { + dependsOn(it) + } + } + + if(rootReadmeExtension.readmeTemplate.exists()) { + inputs.file(rootReadmeExtension.readmeTemplate) + } + rootReadmeExtension.additionalFiles.forEach { + if(it.exists()){ + inputs.file(it) + } + } + + val readmeFile = project.file("README.md") + outputs.file(readmeFile) + doLast { - val reader = groovy.json.JsonSlurper() val projects = subprojects.associate { it.name to it.extensions.findByType() } @@ -135,14 +168,19 @@ open class KScienceProjectPlugin : Plugin { val modulesString = buildString { projects.entries.forEach { (name, ext) -> - appendln("### [$name]($name)") + appendln("
") + appendln("\n* ### [$name]($name)") if (ext != null) { - appendln(ext.description) - appendln("**Maturity**: ${ext.maturity}") - appendln("#### Features:") - appendln(ext.featuresString(pathPrefix = "$name/")) + appendln("> ${ext.description}") + appendln(">\n> **Maturity**: ${ext.maturity}") + val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$name/") + if(featureString.isNotBlank()) { + appendln(">\n> **Features:**") + appendln(featureString) + } } } + appendln("
") } val rootReadmeProperties: Map = mapOf( @@ -152,13 +190,31 @@ open class KScienceProjectPlugin : Plugin { "modules" to modulesString ) - val readmeFile = project.file("README.md") readmeFile.writeText( - SimpleTemplateEngine().createTemplate(rootReadmeExtension.readmeTemplate).make(rootReadmeProperties).toString() + SimpleTemplateEngine().createTemplate(rootReadmeExtension.readmeTemplate) + .make(rootReadmeProperties).toString() ) } } } + + tasks.withType{ + dependsOn(generateReadme) + } + + val patchChangelog by tasks.getting + + val release by tasks.creating{ + group = RELEASE_GROUP + description = "Publish development or production release based on version suffix" + dependsOn(generateReadme, patchChangelog) + tasks.findByName("publishAllPublicationsToBintrayRepository")?.let { + dependsOn(it) + } + } + } + companion object{ + const val RELEASE_GROUP = "release" } } \ No newline at end of file -- 2.34.1 From 6dfd71c1fe128b85e698206bf6f44a28e01b51ca Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Sun, 27 Sep 2020 19:40:05 +0300 Subject: [PATCH 04/21] 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" } -- 2.34.1 From 96bfd552195ad1accdfe21874d64ede81940be01 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 28 Sep 2020 11:47:08 +0300 Subject: [PATCH 05/21] 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 ) { -- 2.34.1 From 774596bbf65053836a33debc0ab1522a5d1a156c Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 30 Sep 2020 20:43:02 +0300 Subject: [PATCH 06/21] 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" -- 2.34.1 From 2fc4bb1f3d7d09acc707fdc86ea2f1c24a0d480d Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 2 Oct 2020 19:07:10 +0300 Subject: [PATCH 07/21] 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 -- 2.34.1 From f44a0aaa3ef038ef850d23ce3c1e800d371122b2 Mon Sep 17 00:00:00 2001 From: darksnake Date: Tue, 20 Oct 2020 08:38:40 +0300 Subject: [PATCH 08/21] 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 ) -- 2.34.1 From 152578aaf74aced40b4179c438ae42dcc22961cd Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 20 Oct 2020 09:56:01 +0300 Subject: [PATCH 09/21] 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 { -- 2.34.1 From f456be46d425b0bf87d4ad8783b502cec1389dbb Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 25 Nov 2020 12:16:09 +0300 Subject: [PATCH 10/21] 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 { -- 2.34.1 From 723a959a0bf5e081391e3b35720035bb7d72c600 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 25 Nov 2020 14:26:08 +0300 Subject: [PATCH 11/21] 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) } } } -- 2.34.1 From be571a90282679fee415e748e9647b46ca19ab1d Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 25 Nov 2020 15:25:46 +0300 Subject: [PATCH 12/21] 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) } } } -- 2.34.1 From aa2ba8caf082e147004b4c13d5760350a8e3e782 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 26 Nov 2020 13:12:02 +0300 Subject: [PATCH 13/21] Removed unused JS distribution execution --- gradle/wrapper/gradle-wrapper.properties | 2 +- .../ru/mipt/npm/gradle/KScienceJSPlugin.kt | 9 --------- .../ru/mipt/npm/gradle/KScienceMPPlugin.kt | 9 --------- src/main/kotlin/ru/mipt/npm/gradle/common.kt | 18 +----------------- 4 files changed, 2 insertions(+), 36 deletions(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 12d38de..4d9ca16 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.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt index 6f150ac..e0ed26f 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJSPlugin.kt @@ -42,15 +42,6 @@ open class KScienceJSPlugin : Plugin { 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}") - } - } - } } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt index 7675142..55133f2 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt @@ -95,15 +95,6 @@ open class KScienceMPPlugin : Plugin { 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}") - } - } - } } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/common.kt b/src/main/kotlin/ru/mipt/npm/gradle/common.kt index 9b33cb5..d38ce2c 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.maven import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder -import java.io.File internal fun LanguageSettingsBuilder.applySettings(): Unit { progressiveMode = true @@ -86,18 +84,4 @@ internal fun Copy.copyJVMResources(configuration: Configuration): Unit = project } } } -} - - -val Project.jsDistDirectory: File - get() { - val distributionName = listOf( - name, - "js", - version.toString() - ).joinToString("-") - - return buildDir.resolve( - "distributions/$distributionName" - ) - } \ No newline at end of file +} \ No newline at end of file -- 2.34.1 From f56f1be429bddd046fab188a5c5087ec16cf1796 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 26 Nov 2020 13:44:36 +0300 Subject: [PATCH 14/21] cleanup --- CHANGELOG.md | 4 ++-- src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt | 1 - src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef4e7dd..6affdae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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 +- Moved all logic to a common plugin, leaving only proxies for platform plugins ### Changed - Remove node plugin. Node binaries should be turned on manually. @@ -24,7 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support of `kaml` and `snake-yaml` in favor of `yamlKt` ### Removed -- Node plugin. + ### Fixed diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt index eaaab4d..f496817 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceJVMPlugin.kt @@ -13,5 +13,4 @@ open class KScienceJVMPlugin : Plugin { } plugins.apply(KScienceCommonPlugin::class) } - } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt index 7f13c79..4e9661c 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt @@ -28,7 +28,6 @@ open class KSciencePublishPlugin : Plugin { project.configure { // Process each publication we have in this project publications.withType().forEach { publication -> - @Suppress("UnstableApiUsage") publication.pom { name.set(project.name) description.set(project.description) -- 2.34.1 From f418a101bf382224379f2db6d17b4e808bc6b66f Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 27 Nov 2020 10:49:39 +0300 Subject: [PATCH 15/21] minor fix --- build.gradle.kts | 2 +- src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt | 4 ++-- src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt | 3 ++- .../kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt | 8 ++++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8317e59..b1cc4a8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.7.0" +version = "0.7.0-fix" repositories { gradlePluginPortal() diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt index 305c2f3..2837af4 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt @@ -86,8 +86,8 @@ class KScienceExtension(val project: Project) { js { binaries.executable() } - (targets.findByName("native") as? KotlinNativeTarget)?.apply { - binaries.executable() + targets.filterIsInstance().forEach { + it.binaries.executable() } } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt index 92a97d3..167d9b9 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceMPPlugin.kt @@ -7,8 +7,9 @@ import org.gradle.kotlin.dsl.apply open class KScienceMPPlugin : Plugin { override fun apply(project: Project): Unit = project.run { if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) { - logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically") pluginManager.apply("org.jetbrains.kotlin.multiplatform") + } else { + logger.info("Kotlin MPP plugin is already present") } plugins.apply(KScienceCommonPlugin::class) } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt index 4e9661c..51fce36 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt @@ -14,6 +14,14 @@ open class KSciencePublishPlugin : Plugin { override fun apply(project: Project): Unit = project.run { plugins.apply("maven-publish") +// plugins.withId("org.jetbrains.kotlin.jvm"){ +// extensions.findByType()?.apply { +// withSourcesJar() +// //withJavadocJar() +// } +// } + + afterEvaluate { val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm" val githubProject: String? by project -- 2.34.1 From 3416598434c27ed0f294980f6a5c5ff12dbc9a6b Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 27 Nov 2020 15:10:15 +0300 Subject: [PATCH 16/21] Refactor and fix publications for non-mpp --- CHANGELOG.md | 4 + build.gradle.kts | 4 +- .../mipt/npm/gradle/KScienceCommonPlugin.kt | 3 + .../ru/mipt/npm/gradle/KScienceExtension.kt | 42 +++++ .../mipt/npm/gradle/KSciencePublishPlugin.kt | 129 +------------- .../mipt/npm/gradle/SerializationTargets.kt | 4 + .../mipt/npm/gradle/{ => internal}/common.kt | 2 +- .../npm/gradle/{ => internal}/dependencies.kt | 15 +- .../ru/mipt/npm/gradle/{ => internal}/fx.kt | 29 +--- .../ru/mipt/npm/gradle/internal/publish.kt | 157 ++++++++++++++++++ 10 files changed, 227 insertions(+), 162 deletions(-) rename src/main/kotlin/ru/mipt/npm/gradle/{ => internal}/common.kt (98%) rename src/main/kotlin/ru/mipt/npm/gradle/{ => internal}/dependencies.kt (95%) rename src/main/kotlin/ru/mipt/npm/gradle/{ => internal}/fx.kt (69%) create mode 100644 src/main/kotlin/ru/mipt/npm/gradle/internal/publish.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 6affdae..49cde24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,13 +19,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `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 +- FX configuration moved to extension +- Moved internals to internals ### Deprecated - Support of `kaml` and `snake-yaml` in favor of `yamlKt` +- Publish plugin ### Removed + ### Fixed ### Security diff --git a/build.gradle.kts b/build.gradle.kts index b1cc4a8..9c02cfe 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.7.0-fix" +version = "0.7.0" repositories { gradlePluginPortal() @@ -40,11 +40,13 @@ gradlePlugin { 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" implementationClass = "ru.mipt.npm.gradle.KScienceProjectPlugin" } + create("kscience.publish") { id = "ru.mipt.npm.publish" description = "The publication plugin for bintray and github" diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt index fdf6f90..d8f67ee 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt @@ -10,6 +10,9 @@ 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 +import ru.mipt.npm.gradle.internal.applyRepos +import ru.mipt.npm.gradle.internal.applySettings +import ru.mipt.npm.gradle.internal.fromDependencies open class KScienceCommonPlugin : Plugin { override fun apply(project: Project): Unit = project.run { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt index 2837af4..33cbaa1 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt @@ -7,9 +7,40 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget +import ru.mipt.npm.gradle.internal.configurePublishing +import ru.mipt.npm.gradle.internal.defaultPlatform +import ru.mipt.npm.gradle.internal.useCommonDependency +import ru.mipt.npm.gradle.internal.useFx class KScienceExtension(val project: Project) { + enum class FXModule(val artifact: String, vararg val dependencies: FXModule) { + BASE("javafx-base"), + GRAPHICS("javafx-graphics", BASE), + CONTROLS("javafx-controls", GRAPHICS, BASE), + FXML("javafx-fxml", BASE), + MEDIA("javafx-media", GRAPHICS, BASE), + SWING("javafx-swing", GRAPHICS, BASE), + WEB("javafx-web", CONTROLS, GRAPHICS, BASE) + } + + enum class FXPlatform(val id: String) { + WINDOWS("win"), + LINUX("linux"), + MAC("mac") + } + + enum class DependencyConfiguration { + API, + IMPLEMENTATION, + COMPILE_ONLY + } + + enum class DependencySourceSet(val setName: String, val suffix: String) { + MAIN("main", "Main"), + TEST("test", "Test") + } + fun useCoroutines( version: String = KScienceVersions.coroutinesVersion, sourceSet: DependencySourceSet = DependencySourceSet.MAIN, @@ -64,6 +95,13 @@ class KScienceExtension(val project: Project) { plugins.apply("org.jetbrains.dokka") } + fun useFx( + vararg modules: FXModule, + configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY, + version: String = "14", + platform: FXPlatform = defaultPlatform + ) = project.useFx(modules.toList(), configuration, version, platform) + /** * Mark this module as an application module. JVM application should be enabled separately */ @@ -91,6 +129,10 @@ class KScienceExtension(val project: Project) { } } } + + fun publish() { + project.configurePublishing() + } } internal fun Project.registerKScienceExtension() { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt index 51fce36..c45e556 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt @@ -2,135 +2,12 @@ package ru.mipt.npm.gradle import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.publish.PublishingExtension -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.provideDelegate -import org.gradle.kotlin.dsl.withType +import ru.mipt.npm.gradle.internal.configurePublishing open class KSciencePublishPlugin : Plugin { - override fun apply(project: Project): Unit = project.run { - plugins.apply("maven-publish") - -// plugins.withId("org.jetbrains.kotlin.jvm"){ -// extensions.findByType()?.apply { -// withSourcesJar() -// //withJavadocJar() -// } -// } - - - afterEvaluate { - val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm" - val githubProject: String? by project - val vcs = findProperty("vcs") as? String - ?: githubProject?.let { "https://github.com/$githubOrg/$it" } - - if (vcs == null) { - project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.") - return@afterEvaluate - } - - project.configure { - // Process each publication we have in this project - publications.withType().forEach { publication -> - publication.pom { - name.set(project.name) - description.set(project.description) - url.set(vcs) - - licenses { - license { - name.set("The Apache Software License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - distribution.set("repo") - } - } - developers { - developer { - id.set("MIPT-NPM") - name.set("MIPT nuclear physics methods laboratory") - organization.set("MIPT") - organizationUrl.set("http://npm.mipt.ru") - } - - } - scm { - url.set(vcs) - tag.set(project.version.toString()) - } - } - } - - val githubUser: String? by project - val githubToken: String? by project - - if (githubProject != null && githubUser != null && githubToken != null) { - project.logger.info("Adding github publishing to project [${project.name}]") - repositories { - maven { - name = "github" - url = uri("https://maven.pkg.github.com/mipt-npm/$githubProject/") - credentials { - username = githubUser - password = githubToken - } - } - } - } - - val spaceRepo: String? by project - val spaceUser: String? by project - val spaceToken: String? by project - - if (spaceRepo != null && spaceUser != null && spaceToken != null) { - project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]") - repositories { - maven { - name = "space" - url = uri(spaceRepo!!) - credentials { - username = spaceUser - password = spaceToken - } - - } - } - } - - val bintrayOrg = project.findProperty("bintrayOrg") as? String ?: "mipt-npm" - val bintrayUser: String? by project - val bintrayApiKey: String? by project - - - val bintrayRepo = if (project.version.toString().contains("dev")) { - "dev" - } else { - findProperty("bintrayRepo") as? String - } - - val projectName = project.name - - if (bintrayRepo != null && bintrayUser != null && bintrayApiKey != null) { - project.logger.info("Adding bintray publishing to project [$projectName]") - - repositories { - maven { - name = "bintray" - url = uri( - "https://api.bintray.com/maven/$bintrayOrg/$bintrayRepo/$projectName/;publish=1;override=1" - ) - credentials { - username = bintrayUser - password = bintrayApiKey - } - } - } - - } - } - } + override fun apply(project: Project): Unit = project.plugins.withId("ru.mipt.npm.kscience") { + project.configurePublishing() } } \ No newline at end of file diff --git a/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt b/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt index dc762f6..0b672f1 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt @@ -3,6 +3,10 @@ package ru.mipt.npm.gradle import org.gradle.api.Project import org.gradle.kotlin.dsl.maven import org.gradle.kotlin.dsl.repositories +import ru.mipt.npm.gradle.KScienceExtension.DependencyConfiguration +import ru.mipt.npm.gradle.KScienceExtension.DependencySourceSet +import ru.mipt.npm.gradle.internal.useCommonDependency +import ru.mipt.npm.gradle.internal.useDependency class SerializationTargets( val sourceSet: DependencySourceSet, diff --git a/src/main/kotlin/ru/mipt/npm/gradle/common.kt b/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt similarity index 98% rename from src/main/kotlin/ru/mipt/npm/gradle/common.kt rename to src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt index 790296e..2745658 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/common.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt @@ -1,4 +1,4 @@ -package ru.mipt.npm.gradle +package ru.mipt.npm.gradle.internal import org.gradle.api.artifacts.ProjectDependency import org.gradle.api.artifacts.dsl.RepositoryHandler diff --git a/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt b/src/main/kotlin/ru/mipt/npm/gradle/internal/dependencies.kt similarity index 95% rename from src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt rename to src/main/kotlin/ru/mipt/npm/gradle/internal/dependencies.kt index 78dc949..d1f2237 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/dependencies.kt @@ -1,4 +1,4 @@ -package ru.mipt.npm.gradle +package ru.mipt.npm.gradle.internal import org.gradle.api.Project import org.gradle.kotlin.dsl.configure @@ -6,17 +6,8 @@ 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 { - API, - IMPLEMENTATION, - COMPILE_ONLY -} - -enum class DependencySourceSet(val setName: String, val suffix: String) { - MAIN("main", "Main"), - TEST("test", "Test") -} +import ru.mipt.npm.gradle.KScienceExtension.DependencyConfiguration +import ru.mipt.npm.gradle.KScienceExtension.DependencySourceSet internal fun Project.useDependency( vararg pairs: Pair, diff --git a/src/main/kotlin/ru/mipt/npm/gradle/fx.kt b/src/main/kotlin/ru/mipt/npm/gradle/internal/fx.kt similarity index 69% rename from src/main/kotlin/ru/mipt/npm/gradle/fx.kt rename to src/main/kotlin/ru/mipt/npm/gradle/internal/fx.kt index 76f30c0..66a4e22 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/fx.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/fx.kt @@ -1,4 +1,4 @@ -package ru.mipt.npm.gradle +package ru.mipt.npm.gradle.internal import org.apache.tools.ant.taskdefs.condition.Os import org.gradle.api.Project @@ -6,22 +6,7 @@ import org.gradle.kotlin.dsl.findByType import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler - -enum class FXModule(val artifact: String, vararg val dependencies: FXModule) { - BASE("javafx-base"), - GRAPHICS("javafx-graphics", BASE), - CONTROLS("javafx-controls", GRAPHICS, BASE), - FXML("javafx-fxml", BASE), - MEDIA("javafx-media", GRAPHICS, BASE), - SWING("javafx-swing", GRAPHICS, BASE), - WEB("javafx-web", CONTROLS, GRAPHICS, BASE) -} - -enum class FXPlatform(val id: String) { - WINDOWS("win"), - LINUX("linux"), - MAC("mac") -} +import ru.mipt.npm.gradle.KScienceExtension.* val defaultPlatform: FXPlatform = when { Os.isFamily(Os.FAMILY_WINDOWS) -> FXPlatform.WINDOWS @@ -31,7 +16,7 @@ val defaultPlatform: FXPlatform = when { } private fun KotlinDependencyHandler.addFXDependencies( - vararg modules: FXModule, + modules: List, configuration: DependencyConfiguration, version: String = "14", platform: FXPlatform = defaultPlatform @@ -46,8 +31,8 @@ private fun KotlinDependencyHandler.addFXDependencies( } } -fun Project.useFx( - vararg modules: FXModule, +internal fun Project.useFx( + modules: List, configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY, version: String = "14", platform: FXPlatform = defaultPlatform @@ -56,7 +41,7 @@ fun Project.useFx( extensions.findByType()?.apply { sourceSets.findByName("jvmMain")?.apply { dependencies { - addFXDependencies(*modules, configuration = configuration, version = version, platform = platform) + addFXDependencies(modules, configuration = configuration, version = version, platform = platform) } } } @@ -66,7 +51,7 @@ fun Project.useFx( extensions.findByType()?.apply { sourceSets.findByName("main")?.apply { dependencies { - addFXDependencies(*modules, configuration = configuration, version = version, platform = platform) + addFXDependencies(modules, configuration = configuration, version = version, platform = platform) } } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/internal/publish.kt b/src/main/kotlin/ru/mipt/npm/gradle/internal/publish.kt new file mode 100644 index 0000000..433b7d4 --- /dev/null +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/publish.kt @@ -0,0 +1,157 @@ +package ru.mipt.npm.gradle.internal + +import org.gradle.api.Project +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.jvm.tasks.Jar +import org.gradle.kotlin.dsl.* +import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension + +internal fun Project.configurePublishing() { + if (plugins.findPlugin("maven-publish") == null) { + plugins.apply("maven-publish") + } + + val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm" + val githubProject: String? by project + val vcs = findProperty("vcs") as? String + ?: githubProject?.let { "https://github.com/$githubOrg/$it" } + + if (vcs == null) { + project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.") + return + } + + project.configure { + plugins.withId("org.jetbrains.kotlin.js") { + val kotlin = extensions.findByType()!! + + val sourcesJar: Jar by project.tasks.creating(Jar::class){ + archiveClassifier.set("sources") + from(kotlin.sourceSets["main"].kotlin) + } + + publications { + create("kotlinJs", MavenPublication::class) { + from(components["kotlin"]) + artifact(sourcesJar) + } + } + } + + plugins.withId("org.jetbrains.kotlin.jvm") { + val kotlin = extensions.findByType()!! + + val sourcesJar: Jar by project.tasks.creating(Jar::class){ + archiveClassifier.set("sources") + from(kotlin.sourceSets["main"].kotlin) + } + + publications { + create("kotlinJvm", MavenPublication::class) { + from(components["kotlin"]) + artifact(sourcesJar) + } + } + } + + + // Process each publication we have in this project + publications.withType().forEach { publication -> + publication.pom { + name.set(project.name) + description.set(project.description) + url.set(vcs) + + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } + } + developers { + developer { + id.set("MIPT-NPM") + name.set("MIPT nuclear physics methods laboratory") + organization.set("MIPT") + organizationUrl.set("http://npm.mipt.ru") + } + + } + scm { + url.set(vcs) + tag.set(project.version.toString()) + } + } + } + + val githubUser: String? by project + val githubToken: String? by project + + if (githubProject != null && githubUser != null && githubToken != null) { + project.logger.info("Adding github publishing to project [${project.name}]") + repositories { + maven { + name = "github" + url = uri("https://maven.pkg.github.com/mipt-npm/$githubProject/") + credentials { + username = githubUser + password = githubToken + } + } + } + } + + val spaceRepo: String? by project + val spaceUser: String? by project + val spaceToken: String? by project + + if (spaceRepo != null && spaceUser != null && spaceToken != null) { + project.logger.info("Adding mipt-npm Space publishing to project [${project.name}]") + repositories { + maven { + name = "space" + url = uri(spaceRepo!!) + credentials { + username = spaceUser + password = spaceToken + } + + } + } + } + + val bintrayOrg = project.findProperty("bintrayOrg") as? String ?: "mipt-npm" + val bintrayUser: String? by project + val bintrayApiKey: String? by project + + + val bintrayRepo = if (project.version.toString().contains("dev")) { + "dev" + } else { + findProperty("bintrayRepo") as? String + } + + val projectName = project.name + + if (bintrayRepo != null && bintrayUser != null && bintrayApiKey != null) { + project.logger.info("Adding bintray publishing to project [$projectName]") + + repositories { + maven { + name = "bintray" + url = uri( + "https://api.bintray.com/maven/$bintrayOrg/$bintrayRepo/$projectName/;publish=1;override=1" + ) + credentials { + username = bintrayUser + password = bintrayApiKey + } + } + } + + } + } +} \ No newline at end of file -- 2.34.1 From 83ab554955b8e45b8e28f4eede4ec566658d273e Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 27 Nov 2020 20:26:58 +0300 Subject: [PATCH 17/21] Remove useDokka --- CHANGELOG.md | 16 +++++++++++++++- .../ru/mipt/npm/gradle/KScienceCommonPlugin.kt | 7 ++++++- .../ru/mipt/npm/gradle/KScienceExtension.kt | 4 ---- .../ru/mipt/npm/gradle/internal/publish.kt | 4 ++-- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49cde24..cc955e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + +### Changed + +### Deprecated + +### Removed + +### Fixed + +### Security + +## [0.7.0] + ### Added - Changelog plugin automatically applied to `project`. - Feature matrix and Readme generation task for a `project` plugin. @@ -27,7 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Publish plugin ### Removed - +- `useDokka` method. Documentation jar should be added manually if needed. ### Fixed diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt index d8f67ee..d919907 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt @@ -20,6 +20,11 @@ open class KScienceCommonPlugin : Plugin { registerKScienceExtension() repositories.applyRepos() + // apply dokka for all projects + if (!plugins.hasPlugin("org.jetbrains.dokka")) { + plugins.apply("org.jetbrains.dokka") + } + //Configuration for K-JVM plugin pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { //logger.info("Applying KScience configuration for JVM project") @@ -122,7 +127,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/KScienceExtension.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt index 33cbaa1..495d8f3 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt @@ -91,10 +91,6 @@ class KScienceExtension(val project: Project) { ) } - fun useDokka(): Unit = project.run { - plugins.apply("org.jetbrains.dokka") - } - fun useFx( vararg modules: FXModule, configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY, diff --git a/src/main/kotlin/ru/mipt/npm/gradle/internal/publish.kt b/src/main/kotlin/ru/mipt/npm/gradle/internal/publish.kt index 433b7d4..12bb161 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/internal/publish.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/publish.kt @@ -33,7 +33,7 @@ internal fun Project.configurePublishing() { } publications { - create("kotlinJs", MavenPublication::class) { + create("js", MavenPublication::class) { from(components["kotlin"]) artifact(sourcesJar) } @@ -49,7 +49,7 @@ internal fun Project.configurePublishing() { } publications { - create("kotlinJvm", MavenPublication::class) { + create("jvm", MavenPublication::class) { from(components["kotlin"]) artifact(sourcesJar) } -- 2.34.1 From 1b7a2038edccd74338d4afa858467fdaf7129e1d Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 27 Nov 2020 21:00:24 +0300 Subject: [PATCH 18/21] Move enums to top level --- .../ru/mipt/npm/gradle/KScienceExtension.kt | 55 ++++++++++--------- .../mipt/npm/gradle/SerializationTargets.kt | 2 - .../mipt/npm/gradle/internal/dependencies.kt | 4 +- .../kotlin/ru/mipt/npm/gradle/internal/fx.kt | 6 +- 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt index 495d8f3..e7e3d59 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt @@ -12,35 +12,36 @@ import ru.mipt.npm.gradle.internal.defaultPlatform import ru.mipt.npm.gradle.internal.useCommonDependency import ru.mipt.npm.gradle.internal.useFx +enum class FXModule(val artifact: String, vararg val dependencies: FXModule) { + BASE("javafx-base"), + GRAPHICS("javafx-graphics", BASE), + CONTROLS("javafx-controls", GRAPHICS, BASE), + FXML("javafx-fxml", BASE), + MEDIA("javafx-media", GRAPHICS, BASE), + SWING("javafx-swing", GRAPHICS, BASE), + WEB("javafx-web", CONTROLS, GRAPHICS, BASE) +} + +enum class FXPlatform(val id: String) { + WINDOWS("win"), + LINUX("linux"), + MAC("mac") +} + +enum class DependencyConfiguration { + API, + IMPLEMENTATION, + COMPILE_ONLY +} + +enum class DependencySourceSet(val setName: String, val suffix: String) { + MAIN("main", "Main"), + TEST("test", "Test") +} + + class KScienceExtension(val project: Project) { - enum class FXModule(val artifact: String, vararg val dependencies: FXModule) { - BASE("javafx-base"), - GRAPHICS("javafx-graphics", BASE), - CONTROLS("javafx-controls", GRAPHICS, BASE), - FXML("javafx-fxml", BASE), - MEDIA("javafx-media", GRAPHICS, BASE), - SWING("javafx-swing", GRAPHICS, BASE), - WEB("javafx-web", CONTROLS, GRAPHICS, BASE) - } - - enum class FXPlatform(val id: String) { - WINDOWS("win"), - LINUX("linux"), - MAC("mac") - } - - enum class DependencyConfiguration { - API, - IMPLEMENTATION, - COMPILE_ONLY - } - - enum class DependencySourceSet(val setName: String, val suffix: String) { - MAIN("main", "Main"), - TEST("test", "Test") - } - fun useCoroutines( version: String = KScienceVersions.coroutinesVersion, sourceSet: DependencySourceSet = DependencySourceSet.MAIN, diff --git a/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt b/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt index 0b672f1..0868496 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt @@ -3,8 +3,6 @@ package ru.mipt.npm.gradle import org.gradle.api.Project import org.gradle.kotlin.dsl.maven import org.gradle.kotlin.dsl.repositories -import ru.mipt.npm.gradle.KScienceExtension.DependencyConfiguration -import ru.mipt.npm.gradle.KScienceExtension.DependencySourceSet import ru.mipt.npm.gradle.internal.useCommonDependency import ru.mipt.npm.gradle.internal.useDependency diff --git a/src/main/kotlin/ru/mipt/npm/gradle/internal/dependencies.kt b/src/main/kotlin/ru/mipt/npm/gradle/internal/dependencies.kt index d1f2237..eaf260b 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/internal/dependencies.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/dependencies.kt @@ -6,8 +6,8 @@ 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 -import ru.mipt.npm.gradle.KScienceExtension.DependencyConfiguration -import ru.mipt.npm.gradle.KScienceExtension.DependencySourceSet +import ru.mipt.npm.gradle.DependencyConfiguration +import ru.mipt.npm.gradle.DependencySourceSet internal fun Project.useDependency( vararg pairs: Pair, diff --git a/src/main/kotlin/ru/mipt/npm/gradle/internal/fx.kt b/src/main/kotlin/ru/mipt/npm/gradle/internal/fx.kt index 66a4e22..83c07df 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/internal/fx.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/fx.kt @@ -6,7 +6,9 @@ import org.gradle.kotlin.dsl.findByType import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler -import ru.mipt.npm.gradle.KScienceExtension.* +import ru.mipt.npm.gradle.DependencyConfiguration +import ru.mipt.npm.gradle.FXModule +import ru.mipt.npm.gradle.FXPlatform val defaultPlatform: FXPlatform = when { Os.isFamily(Os.FAMILY_WINDOWS) -> FXPlatform.WINDOWS @@ -36,7 +38,7 @@ internal fun Project.useFx( configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY, version: String = "14", platform: FXPlatform = defaultPlatform -): Unit = afterEvaluate{ +): Unit = afterEvaluate { pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { extensions.findByType()?.apply { sourceSets.findByName("jvmMain")?.apply { -- 2.34.1 From 3108f16dea82fcca2e21e949aed319563073f857 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 27 Nov 2020 22:42:44 +0300 Subject: [PATCH 19/21] Move copy dependencies to platform configuration --- .../mipt/npm/gradle/KScienceCommonPlugin.kt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt index d919907..405b3a5 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt @@ -65,6 +65,11 @@ open class KScienceCommonPlugin : Plugin { } } } + + (tasks.findByName("processResources") as? Copy)?.apply { + fromDependencies("runtimeClasspath") + } + } pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { @@ -114,14 +119,16 @@ open class KScienceCommonPlugin : Plugin { } } } + + (tasks.findByName("jsProcessResources") as? Copy)?.apply { + fromDependencies("jsRuntimeClasspath") + } } } afterEvaluate { extensions.findByType()?.apply { targetCompatibility = KScienceVersions.JVM_TARGET - //withSourcesJar() - //withJavadocJar() } tasks.apply { @@ -134,14 +141,6 @@ open class KScienceCommonPlugin : Plugin { withType { useJUnitPlatform() } - - (findByName("processResources") as? Copy)?.apply { - fromDependencies("runtimeClasspath") - } - - (findByName("jsProcessResources") as? Copy)?.apply { - fromDependencies("jsRuntimeClasspath") - } } } } -- 2.34.1 From 261be8938b1ed3f59c533c2408b709b3561dc516 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 27 Nov 2020 22:50:15 +0300 Subject: [PATCH 20/21] Fix process JS resources --- src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt b/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt index 2745658..6eede47 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt @@ -36,24 +36,19 @@ internal fun Copy.fromDependencies(configurationName: String) = project.afterEva val projectDeps = configuration.allDependencies.filterIsInstance().map { it.dependencyProject } - into(buildDir.resolve("processedResources/js")) projectDeps.forEach { dep -> 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.js") { dep.tasks.findByName("processResources")?.let { task -> dependsOn(task) from(task) - //from(dep.buildDir.resolve("processedResources/js")) } - // from(dep.buildDir.resolve("processedResources/js")) } } } -- 2.34.1 From a9d0ddc4e58bce7e28f45b4c1baf05fd2969d22a Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 16 Dec 2020 14:14:51 +0300 Subject: [PATCH 21/21] Update versions --- build.gradle.kts | 10 +++++----- src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt | 8 ++++---- .../kotlin/ru/mipt/npm/gradle/SerializationTargets.kt | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 9c02cfe..1a5dbd4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.7.0" +version = "0.7.1" repositories { gradlePluginPortal() @@ -16,7 +16,7 @@ repositories { maven("https://dl.bintray.com/kotlin/kotlin-dev") } -val kotlinVersion = "1.4.20" +val kotlinVersion = "1.4.21" java { targetCompatibility = JavaVersion.VERSION_1_8 @@ -26,9 +26,9 @@ java { 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.2") - implementation("org.jetbrains.dokka:dokka-base:1.4.10") + implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.15.0") + implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20") + implementation("org.jetbrains.dokka:dokka-base:1.4.20") implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:0.6.2") implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.2.4") } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt index 4cf4049..7849dda 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt @@ -6,9 +6,9 @@ import org.gradle.api.JavaVersion * Build constants */ object KScienceVersions { - const val kotlinVersion = "1.4.20" + const val kotlinVersion = "1.4.21" const val kotlinxNodeVersion = "0.0.7" - const val coroutinesVersion = "1.4.1" + const val coroutinesVersion = "1.4.2" const val serializationVersion = "1.0.1" const val atomicVersion = "0.14.4" @@ -18,7 +18,7 @@ object KScienceVersions { 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" + const val bsonVersion = "0.4.4" + const val yamlKtVersion = "0.7.5" } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt b/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt index 0868496..1f66db2 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt @@ -66,7 +66,7 @@ class SerializationTargets( } fun Project.yamlKt( - version: String = KScienceVersions.Serialization.yamlVersion + version: String = KScienceVersions.Serialization.yamlKtVersion ) { useCommonDependency( "net.mamoe.yamlkt:yamlkt:$version", -- 2.34.1