-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ support deploy with sign
- Loading branch information
Showing
9 changed files
with
179 additions
and
59 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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
language: java | ||
jdk: | ||
- oraclejdk8 | ||
- oraclejdk8 | ||
before_cache: | ||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock | ||
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock | ||
cache: | ||
directories: | ||
- $HOME/.gradle/caches/ | ||
- $HOME/.gradle/wrapper/ | ||
- "$HOME/.gradle/caches/" | ||
- "$HOME/.gradle/wrapper/" | ||
before_install: | ||
- openssl aes-256-cbc -K $encrypted_35d5c0204248_key -iv $encrypted_35d5c0204248_iv -in private.key.enc -out ./private.key -d | ||
- gpg --import ./private.key | ||
after_success: | ||
- "[[ ${TRAVIS_PULL_REQUEST} == 'false' ]] && [[ ${TRAVIS_TAG} == '' ]] && ./gradlew publish" | ||
- "[[ ${TRAVIS_PULL_REQUEST} == 'false' ]] && [[ ${TRAVIS_TAG} == '' ]] && ./gradlew publish" |
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
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 |
---|---|---|
@@ -0,0 +1,140 @@ | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'signing' | ||
|
||
gradle.taskGraph.whenReady { taskGraph -> | ||
if (taskGraph.allTasks.any { it instanceof Sign }) { | ||
def id = System.getenv('GPG_ID') | ||
def file = '/home/travis/.gnupg/secring.gpg' | ||
def password = System.getenv('GPG_PASSWORD') | ||
|
||
allprojects { ext."signing.keyId" = id } | ||
allprojects { ext."signing.secretKeyRingFile" = file } | ||
allprojects { ext."signing.password" = password } | ||
} | ||
} | ||
|
||
ext { | ||
pomFile = file("${project.buildDir}/generated-pom.xml") | ||
isReleaseVersion = project.version.endsWith('RELEASE') | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
classifier = 'javadoc' | ||
from javadoc.destinationDir | ||
} | ||
|
||
task sourceJar(type: Jar) { | ||
classifier = 'sources' | ||
from sourceSets.main.allSource | ||
} | ||
|
||
artifacts { | ||
archives jar | ||
archives sourceJar | ||
archives javadocJar | ||
} | ||
|
||
|
||
signing { | ||
sign configurations.archives | ||
} | ||
|
||
publishing { | ||
publications { | ||
jar(MavenPublication) { | ||
pom.withXml { | ||
asNode().children().first() + { | ||
resolveStrategy = Closure.DELEGATE_FIRST | ||
name 'spring boot grpc' | ||
description 'spring boot grpc' | ||
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]' | ||
} | ||
} | ||
} | ||
} | ||
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.artifactId.text() == "grpc-spring-boot-autoconfigure") { | ||
it.scope*.value = 'compile' | ||
} | ||
} | ||
} | ||
from components.java | ||
|
||
artifact(sourceJar) { | ||
classifier = 'sources' | ||
} | ||
artifact(javadocJar) { | ||
classifier = 'javadoc' | ||
} | ||
|
||
|
||
pom.withXml { | ||
writeTo(project.ext.pomFile) | ||
def pomAscFile = signing.sign(project.ext.pomFile).signatureFiles[0] | ||
artifact(pomAscFile) { | ||
classifier = null | ||
extension = 'pom.asc' | ||
} | ||
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' | ||
} | ||
} | ||
} | ||
} | ||
repositories { | ||
maven { | ||
credentials { | ||
username System.getenv('OSSRH_USER') | ||
password System.getenv('OSSRH_PASS') | ||
} | ||
println(project.ext.isReleaseVersion) | ||
if(project.version.endsWith('RELEASE')) { | ||
url "https://oss.sonatype.org/service/local/staging/deploy/maven2" | ||
} else { | ||
url "https://oss.sonatype.org/content/repositories/snapshots" | ||
} | ||
} | ||
} | ||
} | ||
|
||
model { | ||
tasks.publishJarPublicationToMavenLocal { | ||
dependsOn(project.tasks.signArchives) | ||
} | ||
tasks.publishJarPublicationToMavenRepository { | ||
dependsOn(project.tasks.signArchives) | ||
} | ||
} |
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
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
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
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
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 |
---|---|---|
@@ -1,29 +1,8 @@ | ||
apply plugin: 'maven-publish' | ||
apply from: '../deploy.gradle' | ||
|
||
group = "net.devh" | ||
version = "${projectVersion}" | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
from components.java | ||
} | ||
} | ||
repositories { | ||
maven { | ||
credentials { | ||
username System.getenv('OSSRH_USER') | ||
password System.getenv('OSSRH_PASS') | ||
} | ||
if(project.version.endsWith('SNAPSHOT')) { | ||
url "https://oss.sonatype.org/content/repositories/snapshots" | ||
} else if(project.version.endsWith('RELEASE')) { | ||
url "https://oss.sonatype.org/service/local/staging/deploy/maven2" | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile project(':grpc-spring-boot-autoconfigure') | ||
} |
Binary file not shown.