Fix plugin loading order for publishing

This commit is contained in:
Alexander Nozik 2021-02-23 10:43:15 +03:00
parent a871db0c15
commit 9c12501a57
3 changed files with 34 additions and 32 deletions

View File

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed ### Removed
### Fixed ### Fixed
- Plugin loading order for publishing
### Security ### Security

View File

@ -8,7 +8,7 @@ plugins {
} }
group = "ru.mipt.npm" group = "ru.mipt.npm"
version = "0.8.1" version = "0.8.2"
description = "Build tools for DataForge and kscience projects" description = "Build tools for DataForge and kscience projects"

View File

@ -15,48 +15,46 @@ private fun Project.isSnapshot() = version.toString().contains("dev") || version
open class KSciencePublishingPlugin : Plugin<Project> { open class KSciencePublishingPlugin : Plugin<Project> {
override fun apply(project: Project): Unit { override fun apply(project: Project): Unit = project.run {
project.run { if (plugins.findPlugin("maven-publish") == null) {
if (plugins.findPlugin("maven-publish") == null) { plugins.apply("maven-publish")
plugins.apply("maven-publish") }
}
configure<PublishingExtension> {
plugins.withId("org.jetbrains.kotlin.js") {
val kotlin = extensions.findByType<KotlinJsProjectExtension>()!!
val sourcesJar: Jar by project.tasks.creating(Jar::class) { configure<PublishingExtension> {
archiveClassifier.set("sources") plugins.withId("ru.mipt.npm.gradle.js") {
from(kotlin.sourceSets["main"].kotlin) val kotlin = extensions.findByType<KotlinJsProjectExtension>()!!
}
publications { val sourcesJar: Jar by project.tasks.creating(Jar::class) {
create("js", MavenPublication::class) { archiveClassifier.set("sources")
from(components["kotlin"]) from(kotlin.sourceSets["main"].kotlin)
artifact(sourcesJar)
}
}
} }
plugins.withId("org.jetbrains.kotlin.jvm") { publications {
val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!! create("js", MavenPublication::class) {
from(components["kotlin"])
val sourcesJar: Jar by project.tasks.creating(Jar::class) { artifact(sourcesJar)
archiveClassifier.set("sources")
from(kotlin.sourceSets["main"].kotlin)
} }
}
}
publications { plugins.withId("ru.mipt.npm.gradle.jvm") {
create("jvm", MavenPublication::class) { val kotlin = extensions.findByType<KotlinJvmProjectExtension>()!!
from(components["kotlin"])
artifact(sourcesJar) 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 { project.afterEvaluate {
val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm" val githubOrg: String = project.findProperty("githubOrg") as? String ?: "mipt-npm"
val githubProject: String? by project val githubProject: String? by project
val vcs = findProperty("vcs") as? String val vcs = findProperty("vcs") as? String
@ -174,7 +172,8 @@ open class KSciencePublishingPlugin : Plugin<Project> {
val sonatypePassword: String? by project val sonatypePassword: String? by project
val keyId: 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 val signingKeyPassphrase: String? by project
if (sonatypePublish == "true" && sonatypeUser != null && sonatypePassword != null) { if (sonatypePublish == "true" && sonatypeUser != null && sonatypePassword != null) {
@ -212,3 +211,5 @@ open class KSciencePublishingPlugin : Plugin<Project> {
} }
} }
} }