-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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') | ||
|
@@ -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' | ||
} | ||
} | ||
} | ||
|
@@ -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) | ||
} | ||
} | ||
} |