From 9c12501a5765ae4abfce98c5c6bc75ac5a18bebb Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 23 Feb 2021 10:43:15 +0300 Subject: [PATCH] Fix plugin loading order for publishing --- CHANGELOG.md | 1 + build.gradle.kts | 2 +- .../npm/gradle/KSciencePublishingPlugin.kt | 63 ++++++++++--------- 3 files changed, 34 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ddcb81..567b28e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed ### Fixed +- Plugin loading order for publishing ### Security diff --git a/build.gradle.kts b/build.gradle.kts index 4b5b363..1cb3b62 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.8.1" +version = "0.8.2" description = "Build tools for DataForge and kscience projects" diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishingPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishingPlugin.kt index d02563d..a0abdce 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishingPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishingPlugin.kt @@ -15,48 +15,46 @@ private fun Project.isSnapshot() = version.toString().contains("dev") || version open class KSciencePublishingPlugin : Plugin { - override fun apply(project: Project): Unit { - project.run { - if (plugins.findPlugin("maven-publish") == null) { - plugins.apply("maven-publish") - } - configure { - plugins.withId("org.jetbrains.kotlin.js") { - val kotlin = extensions.findByType()!! + override fun apply(project: Project): Unit = project.run { + if (plugins.findPlugin("maven-publish") == null) { + plugins.apply("maven-publish") + } - val sourcesJar: Jar by project.tasks.creating(Jar::class) { - archiveClassifier.set("sources") - from(kotlin.sourceSets["main"].kotlin) - } + configure { + plugins.withId("ru.mipt.npm.gradle.js") { + val kotlin = extensions.findByType()!! - publications { - create("js", MavenPublication::class) { - from(components["kotlin"]) - artifact(sourcesJar) - } - } + val sourcesJar: Jar by project.tasks.creating(Jar::class) { + archiveClassifier.set("sources") + from(kotlin.sourceSets["main"].kotlin) } - 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("js", MavenPublication::class) { + from(components["kotlin"]) + artifact(sourcesJar) } + } + } - publications { - create("jvm", MavenPublication::class) { - from(components["kotlin"]) - artifact(sourcesJar) - } + plugins.withId("ru.mipt.npm.gradle.jvm") { + val kotlin = extensions.findByType()!! + + val sourcesJar: Jar by project.tasks.creating(Jar::class) { + archiveClassifier.set("sources") + from(kotlin.sourceSets["main"].kotlin) + } + + publications { + create("jvm", MavenPublication::class) { + from(components["kotlin"]) + artifact(sourcesJar) } } } } project.afterEvaluate { - val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm" val githubProject: String? by project val vcs = findProperty("vcs") as? String @@ -174,7 +172,8 @@ open class KSciencePublishingPlugin : Plugin { val sonatypePassword: String? by project val keyId: String? by project - val signingKey: String? = project.findProperty("signingKey") as? String ?: System.getenv("signingKey") + val signingKey: String? = + project.findProperty("signingKey") as? String ?: System.getenv("signingKey") val signingKeyPassphrase: String? by project if (sonatypePublish == "true" && sonatypeUser != null && sonatypePassword != null) { @@ -212,3 +211,5 @@ open class KSciencePublishingPlugin : Plugin { } } } + +