Skip to content

Commit

Permalink
Fix deploy to maven center error
Browse files Browse the repository at this point in the history
  • Loading branch information
yidongnan committed Dec 22, 2018
1 parent 687a5e9 commit bee6193
Showing 1 changed file with 43 additions and 103 deletions.
146 changes: 43 additions & 103 deletions deploy.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'maven-publish'
apply plugin: 'signing'

gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.allTasks.any { it instanceof Sign } && project.ext.isReleaseVersion && isPublishing()) {
if (taskGraph.allTasks.any { it instanceof Sign } && project.ext.isReleaseVersion) {
def id = System.getenv('GPG_ID')
def file = '/home/travis/.gnupg/secring.gpg'
def password = System.getenv('GPG_PASSWORD')
Expand All @@ -14,116 +14,57 @@ gradle.taskGraph.whenReady { taskGraph ->
}

ext {
pomFile = file("${project.buildDir}/generated-pom.xml")
isReleaseVersion = !(projectVersion =~ /\.SNAPSHOT$/)
isNeedSign = System.getenv('GPG_ID') && isReleaseVersion
isPublishing = {
gradle.taskGraph.allTasks.find { it.name =~ /(?:^|:)publish[^:]*ToMaven[^:]*$/ } != null
}
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

task sourceJar(type: Jar) {
task sourcesJar(type: Jar) {
from sourceSets.main.allJava
classifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives jar
archives sourceJar
archives javadocJar
}


signing {
required { project.ext.isNeedSign }
sign configurations.archives
task javadocJar(type: Jar) {
from javadoc
classifier = 'javadoc'
}

publishing {
publications {
jar(MavenPublication) {
pom.withXml {
asNode().children().first() + {
resolveStrategy = Closure.DELEGATE_FIRST
name 'gRPC Spring Boot Starter'
description 'gRPC Spring Boot Starter'
url 'https://github.com/yidongnan/grpc-spring-boot-starter'
scm {
url 'https://github.com/yidongnan/grpc-spring-boot-starter'
connection 'scm:git:git://github.com/yidongnan/grpc-spring-boot-starter.git'
developerConnection 'scm:git:[email protected]:yidongnan/grpc-spring-boot-starter.git'
}
licenses {
license {
name 'MIT License'
url 'http://www.opensource.org/licenses/mit-license.php'
distribution 'repo'
}
}
developers {
developer {
id 'yidongnan'
name 'Michael Zhang'
email '[email protected]'
}
developer {
id 'ST-DDT'
name 'Daniel Theuke'
email '[email protected]'
organization 'Heusch/Boesefeldt GmbH'
organizationUrl 'http://www.heuboe.de'
}
}
}
}
pom.withXml {
asNode().dependencies.'*'.findAll() {
it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
dep.name == it.artifactId.text()
}
}.each {
if (it.groupId.text() == "net.devh" || it.groupId.text() == "io.grpc") {
it.scope*.value = 'compile'
}
}
}
mavenJava(MavenPublication) {

from components.java
artifact sourcesJar
artifact javadocJar

artifact(sourceJar) {
classifier = 'sources'
}
artifact(javadocJar) {
classifier = 'javadoc'
}

if (signing.required) {
pom.withXml {
writeTo(project.ext.pomFile)
def pomAscFile = signing.sign(project.ext.pomFile).signatureFiles[0]
artifact(pomAscFile) {
classifier = null
extension = 'pom.asc'
pom {
name = 'gRPC Spring Boot Starter'
description = 'gRPC Spring Boot Starter'
url = 'https://github.com/yidongnan/grpc-spring-boot-starter'
licenses {
license {
name = 'MIT License'
url = 'http://www.opensource.org/licenses/mit-license.php'
distribution = 'repo'
}
project.ext.pomFile.delete()
}

// Sign the artifacts.
project.tasks.signArchives.signatureFiles.each {
artifact(it) {
def matcher = it.file =~ /-(sources|javadoc)\.jar\.asc$/
if (matcher.find()) {
classifier = matcher.group(1)
} else {
classifier = null
}
extension = 'jar.asc'
developers {
developer {
id = 'yidongnan'
name = 'Michael Zhang'
email = '[email protected]'
}
developer {
id = 'ST-DDT'
name = 'Daniel Theuke'
email = '[email protected]'
organization = 'Heusch/Boesefeldt GmbH'
organizationUrl = 'http://www.heuboe.de'
}
}
scm {
connection = 'scm:git:git://github.com/yidongnan/grpc-spring-boot-starter.git'
developerConnection = 'scm:git:[email protected]:yidongnan/grpc-spring-boot-starter.git'
url = 'https://github.com/yidongnan/grpc-spring-boot-starter'
}
}
}
Expand All @@ -141,16 +82,15 @@ publishing {
}
}
}
}

model {
tasks.publishJarPublicationToMavenLocal {
dependsOn(project.tasks.signArchives)
signing {
required { project.ext.isNeedSign }
sign publishing.publications.mavenJava
}
tasks.publishJarPublicationToMavenRepository {
dependsOn(project.tasks.signArchives)
}
tasks.signArchives {
onlyIf { isPublishing() }

javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
}

0 comments on commit bee6193

Please sign in to comment.