diff --git a/build.gradle.kts b/build.gradle.kts index 2375d93..a214e29 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,13 +3,12 @@ plugins { `kotlin-dsl` `maven-publish` signing - id("de.marcphilipp.nexus-publish") version "0.4.0" id("org.jetbrains.changelog") version "1.0.0" id("org.jetbrains.dokka") version "1.4.20" } group = "ru.mipt.npm" -version = "0.7.7" +version = "0.7.8" description = "Build tools for DataForge and kscience projects" @@ -35,7 +34,6 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion") implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.15.1") 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:1.0.0") implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.4.0") } @@ -164,17 +162,6 @@ publishing { val sonatypeUser: String? by project val sonatypePassword: String? by project -// if (sonatypeUser != null && sonatypePassword != null) { -// nexusPublishing { -// repositories { -// sonatype { -// username.set(sonatypeUser) -// password.set(sonatypePassword) -// } -// } -// } -// } - if (sonatypeUser != null && sonatypePassword != null) { val sonatypeRepo: String = if (project.version.toString().contains("dev")) { "https://oss.sonatype.org/content/repositories/snapshots" diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt index dd725d5..c728463 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt @@ -153,6 +153,9 @@ open class KScienceProjectPlugin : Plugin { group = RELEASE_GROUP description = "Publish development or production release based on version suffix" dependsOn(generateReadme) + tasks.findByName("publishAllPublicationsToSonatypeRepository")?.let { + dependsOn(it) + } tasks.findByName("publishAllPublicationsToBintrayRepository")?.let { dependsOn(it) } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt index 5c34659..8977420 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KSciencePublishPlugin.kt @@ -11,6 +11,13 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension +/** + * From https://github.com/Kotlin/kotlinx.serialization/blob/master/buildSrc/src/main/kotlin/Publishing.kt + */ +private fun Project.getSensitiveProperty(name: String): String? { + return project.findProperty(name) as? String ?: System.getenv(name) +} + open class KSciencePublishPlugin : Plugin { override fun apply(project: Project): Unit = project.plugins.withId("ru.mipt.npm.kscience") { @@ -74,7 +81,7 @@ open class KSciencePublishPlugin : Plugin { publication.artifact(dokkaJar) publication.pom { name.set(project.name) - description.set(project.description) + description.set(project.description ?: project.name) vcs?.let { url.set(vcs) } licenses { @@ -169,10 +176,15 @@ open class KSciencePublishPlugin : Plugin { } } + val sonatypePublish: Boolean? by project val sonatypeUser: String? by project val sonatypePassword: String? by project - if (sonatypeUser != null && sonatypePassword != null) { + val keyId: String? by project + val signingKey: String? = getSensitiveProperty("signingKey") + val signingKeyPassphrase: String? by project + + if (sonatypePublish == true && sonatypeUser != null && sonatypePassword != null) { val sonatypeRepo: String = if (project.version.toString().contains("dev")) { "https://oss.sonatype.org/content/repositories/snapshots" } else { @@ -183,8 +195,12 @@ open class KSciencePublishPlugin : Plugin { plugins.apply("signing") } - extensions.findByType()?.apply { - //useGpgCmd() + extensions.configure("signing") { + if (!signingKey.isNullOrBlank()) { + //if key is provided, use it + @Suppress("UnstableApiUsage") + useInMemoryPgpKeys(keyId, signingKey, signingKeyPassphrase) + } // else use file signing sign(publications) } @@ -199,7 +215,6 @@ open class KSciencePublishPlugin : Plugin { } } } - } } }