Configure pom signing before deployment
Use groovy where kotlin dsl lacks of typed api
This commit is contained in:
@@ -4,6 +4,7 @@ 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.Dependency
|
import org.gradle.api.artifacts.Dependency
|
||||||
|
import org.gradle.api.artifacts.maven.MavenDeployer
|
||||||
import org.gradle.api.artifacts.maven.MavenResolver
|
import org.gradle.api.artifacts.maven.MavenResolver
|
||||||
|
|
||||||
import org.gradle.api.plugins.MavenRepositoryHandlerConvention
|
import org.gradle.api.plugins.MavenRepositoryHandlerConvention
|
||||||
@@ -99,11 +100,22 @@ open class PublishedKotlinModule : Plugin<Project> {
|
|||||||
|
|
||||||
var repository: MavenRemoteRepository by Delegates.notNull()
|
var repository: MavenRemoteRepository by Delegates.notNull()
|
||||||
|
|
||||||
|
val signPom = rootProject.extra["signPom"] as groovy.lang.Closure<*>
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
withConvention(MavenRepositoryHandlerConvention::class) {
|
withConvention(MavenRepositoryHandlerConvention::class) {
|
||||||
|
|
||||||
mavenDeployer {
|
mavenDeployer {
|
||||||
|
signPom.call(project, this as MavenDeployer)
|
||||||
|
|
||||||
withGroovyBuilder {
|
withGroovyBuilder {
|
||||||
|
// TODO: Use with kotlin-dsl 0.12+ instead of signPom
|
||||||
|
// "beforeDeployment" {
|
||||||
|
// val signing = project.the<SigningExtension>()
|
||||||
|
// if (signing.isRequired)
|
||||||
|
// signing.signPom(this as MavenDeployment)
|
||||||
|
// }
|
||||||
|
|
||||||
"repository"("url" to repoUrl)!!.also { repository = it as MavenRemoteRepository }.withGroovyBuilder {
|
"repository"("url" to repoUrl)!!.also { repository = it as MavenRemoteRepository }.withGroovyBuilder {
|
||||||
if (username != null && password != null) {
|
if (username != null && password != null) {
|
||||||
"authentication"("userName" to username, "password" to password)
|
"authentication"("userName" to username, "password" to password)
|
||||||
|
|||||||
@@ -116,6 +116,13 @@ task preparePublication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ext.signPom = { Project project, MavenDeployer deployer ->
|
||||||
|
deployer.beforeDeployment { MavenDeployment deployment ->
|
||||||
|
if (project.signing.required)
|
||||||
|
project.signing.signPom(deployment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ext.configurePublishing = { Project project ->
|
ext.configurePublishing = { Project project ->
|
||||||
project.configure(project) {
|
project.configure(project) {
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven'
|
||||||
@@ -157,10 +164,7 @@ ext.configurePublishing = { Project project ->
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenDeployer {
|
mavenDeployer {
|
||||||
beforeDeployment { MavenDeployment deployment ->
|
signPom(project, it)
|
||||||
if (signing.required)
|
|
||||||
signing.signPom(deployment)
|
|
||||||
}
|
|
||||||
|
|
||||||
repository(url: prepareTask.repoUrl) {
|
repository(url: prepareTask.repoUrl) {
|
||||||
authentication(userName: prepareTask.username, password: prepareTask.password)
|
authentication(userName: prepareTask.username, password: prepareTask.password)
|
||||||
|
|||||||
Reference in New Issue
Block a user