Implement proper artifacts signing, add missing install and publish tasks
This commit is contained in:
+6
-1
@@ -75,6 +75,7 @@ extra["distKotlinHomeDir"] = distKotlinHomeDir
|
|||||||
extra["distLibDir"] = project.file(distLibDir)
|
extra["distLibDir"] = project.file(distLibDir)
|
||||||
extra["libsDir"] = project.file(distLibDir)
|
extra["libsDir"] = project.file(distLibDir)
|
||||||
extra["ideaPluginDir"] = project.file(ideaPluginDir)
|
extra["ideaPluginDir"] = project.file(ideaPluginDir)
|
||||||
|
extra["isSonatypeRelease"] = false
|
||||||
|
|
||||||
Properties().apply {
|
Properties().apply {
|
||||||
load(File(rootDir, "resources", "kotlinManifest.properties").reader())
|
load(File(rootDir, "resources", "kotlinManifest.properties").reader())
|
||||||
@@ -141,7 +142,11 @@ apply {
|
|||||||
from("libraries/commonConfiguration.gradle")
|
from("libraries/commonConfiguration.gradle")
|
||||||
from("libraries/gradlePluginsConfiguration.gradle")
|
from("libraries/gradlePluginsConfiguration.gradle")
|
||||||
from("libraries/configureGradleTools.gradle")
|
from("libraries/configureGradleTools.gradle")
|
||||||
// from("libraries/prepareSonatypeStaging.gradle")
|
|
||||||
|
if (extra["isSonatypeRelease"] as? Boolean == true) {
|
||||||
|
logger.info("Applying configuration for sonatype release")
|
||||||
|
from("libraries/prepareSonatypeStaging.gradle")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val importedAntTasksPrefix = "imported-ant-update-"
|
val importedAntTasksPrefix = "imported-ant-update-"
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ package plugins
|
|||||||
import org.codehaus.groovy.runtime.InvokerHelper
|
import org.codehaus.groovy.runtime.InvokerHelper
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
import org.gradle.api.artifacts.Dependency
|
||||||
import org.gradle.api.artifacts.maven.GroovyMavenDeployer
|
import org.gradle.api.artifacts.maven.MavenResolver
|
||||||
|
|
||||||
import org.gradle.api.plugins.MavenRepositoryHandlerConvention
|
import org.gradle.api.plugins.MavenRepositoryHandlerConvention
|
||||||
import org.gradle.api.tasks.Upload
|
import org.gradle.api.tasks.Upload
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
|
import org.gradle.plugins.signing.Sign
|
||||||
|
import org.gradle.plugins.signing.SigningExtension
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,9 +25,74 @@ open class PublishedKotlinModule : Plugin<Project> {
|
|||||||
|
|
||||||
plugins.apply("maven")
|
plugins.apply("maven")
|
||||||
|
|
||||||
(tasks.getByName("uploadArchives") as Upload).apply {
|
if (!project.hasProperty("prebuiltJar")) {
|
||||||
|
plugins.apply("signing")
|
||||||
|
|
||||||
|
val signingProp = project.rootProject.properties["signingRequired"]
|
||||||
|
val signingRequired = when (signingProp) {
|
||||||
|
is Boolean -> signingProp == true
|
||||||
|
is String -> listOf("true", "yes").contains(signingProp.toLowerCase().trim())
|
||||||
|
else -> project.rootProject.extra["isSonatypeRelease"] as? Boolean == true
|
||||||
|
}
|
||||||
|
|
||||||
|
configure<SigningExtension> {
|
||||||
|
isRequired = signingRequired
|
||||||
|
sign(configurations["archives"])
|
||||||
|
}
|
||||||
|
|
||||||
|
(tasks.getByName("signArchives") as Sign).apply {
|
||||||
|
enabled = signingRequired
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun MavenResolver.configurePom() {
|
||||||
|
pom.project {
|
||||||
|
withGroovyBuilder {
|
||||||
|
"licenses" {
|
||||||
|
"license" {
|
||||||
|
"name"("The Apache Software License, Version 2.0")
|
||||||
|
"url"("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||||
|
"distribution"("repo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"name"("${project.group}:${project.name}")
|
||||||
|
"packaging"("jar")
|
||||||
|
// optionally artifactId can be defined here
|
||||||
|
"description"(project.description)
|
||||||
|
"url"("https://kotlinlang.org/")
|
||||||
|
"licenses" {
|
||||||
|
"license" {
|
||||||
|
"name"("The Apache License, Version 2.0")
|
||||||
|
"url"("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"scm" {
|
||||||
|
"url"("https://github.com/JetBrains/kotlin")
|
||||||
|
"connection"("scm:git:https://github.com/JetBrains/kotlin.git")
|
||||||
|
"developerConnection"("scm:git:https://github.com/JetBrains/kotlin.git")
|
||||||
|
}
|
||||||
|
"developers" {
|
||||||
|
"developer" {
|
||||||
|
"name"("Kotlin Team")
|
||||||
|
"organization" {
|
||||||
|
"name"("JetBrains")
|
||||||
|
"url"("https://www.jetbrains.com")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pom.whenConfigured {
|
||||||
|
dependencies.removeIf {
|
||||||
|
InvokerHelper.getMetaClass(it).getProperty(it, "scope") == "test"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val preparePublication = project.rootProject.tasks.getByName("preparePublication")
|
||||||
|
|
||||||
|
val uploadArchives = (tasks.getByName("uploadArchives") as Upload).apply {
|
||||||
|
|
||||||
val preparePublication = project.rootProject.tasks.getByName("preparePublication")
|
|
||||||
dependsOn(preparePublication)
|
dependsOn(preparePublication)
|
||||||
|
|
||||||
val username: String? by preparePublication.extra
|
val username: String? by preparePublication.extra
|
||||||
@@ -43,51 +110,29 @@ open class PublishedKotlinModule : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pom.project {
|
configurePom()
|
||||||
withGroovyBuilder {
|
|
||||||
"licenses" {
|
|
||||||
"license" {
|
|
||||||
"name"("The Apache Software License, Version 2.0")
|
|
||||||
"url"("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
|
||||||
"distribution"("repo")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"name"("${project.group}:${project.name}")
|
|
||||||
"packaging"("jar")
|
|
||||||
// optionally artifactId can be defined here
|
|
||||||
"description"(project.description)
|
|
||||||
"url"("https://kotlinlang.org/")
|
|
||||||
"licenses" {
|
|
||||||
"license" {
|
|
||||||
"name"("The Apache License, Version 2.0")
|
|
||||||
"url"("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"scm" {
|
|
||||||
"url"("https://github.com/JetBrains/kotlin")
|
|
||||||
"connection"("scm:git:https://github.com/JetBrains/kotlin.git")
|
|
||||||
"developerConnection"("scm:git:https://github.com/JetBrains/kotlin.git")
|
|
||||||
}
|
|
||||||
"developers" {
|
|
||||||
"developer" {
|
|
||||||
"name"("Kotlin Team")
|
|
||||||
"organization" {
|
|
||||||
"name"("JetBrains")
|
|
||||||
"url"("https://www.jetbrains.com")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pom.whenConfigured {
|
|
||||||
dependencies.removeIf {
|
|
||||||
InvokerHelper.getMetaClass(it).getProperty(it, "scope") == "test"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val install = if (tasks.names.contains("install")) tasks.getByName("install") as Upload
|
||||||
|
else tasks.create("install", Upload::class.java)
|
||||||
|
install.apply {
|
||||||
|
configuration = project.configurations.getByName(Dependency.ARCHIVES_CONFIGURATION)
|
||||||
|
description = "Installs the 'archives' artifacts into the local Maven repository."
|
||||||
|
repositories {
|
||||||
|
withConvention(MavenRepositoryHandlerConvention::class) {
|
||||||
|
mavenInstaller {
|
||||||
|
configurePom()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.create("publish") {
|
||||||
|
dependsOn(uploadArchives)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user