Use optional in-memory signing
This commit is contained in:
parent
d8dc65da79
commit
c37ff35b4c
@ -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"
|
||||
|
@ -153,6 +153,9 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
||||
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)
|
||||
}
|
||||
|
@ -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<Project> {
|
||||
|
||||
override fun apply(project: Project): Unit = project.plugins.withId("ru.mipt.npm.kscience") {
|
||||
@ -74,7 +81,7 @@ open class KSciencePublishPlugin : Plugin<Project> {
|
||||
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<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
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<Project> {
|
||||
plugins.apply("signing")
|
||||
}
|
||||
|
||||
extensions.findByType<SigningExtension>()?.apply {
|
||||
//useGpgCmd()
|
||||
extensions.configure<SigningExtension>("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<Project> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user