diff --git a/.travis.yml b/.travis.yml index 918101db8..70b7873a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" \ No newline at end of file +- "[[ ${TRAVIS_PULL_REQUEST} == 'false' ]] && [[ ${TRAVIS_TAG} == '' ]] && ./gradlew publish" diff --git a/build.gradle b/build.gradle index acf80d0bf..46433b93e 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } ext { - projectVersion = '1.0.0.RELEASE' + projectVersion = '1.0.0.SNAPSHOT' springBootVersion = '1.4.2.RELEASE' springSleuthVersion = '1.1.0.RELEASE' springCloudVersion = 'Camden.SR3' @@ -49,14 +49,5 @@ subprojects { mavenLocal() mavenCentral() } - dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" - } - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") - classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.6' - } } } \ No newline at end of file diff --git a/deploy.gradle b/deploy.gradle new file mode 100644 index 000000000..e0decec8c --- /dev/null +++ b/deploy.gradle @@ -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:ssh@github.com: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 'yidongnan@gmail.com' + } + } + } + } + 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) + } +} \ No newline at end of file diff --git a/example/grpc-client/build.gradle b/example/grpc-client/build.gradle index d97a122d4..a50c8f9a1 100644 --- a/example/grpc-client/build.gradle +++ b/example/grpc-client/build.gradle @@ -7,4 +7,15 @@ dependencies { compile project(':example:grpc-lib') compile project(':grpc-spring-boot-starter') +} + +buildscript { + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") + } + dependencyManagement { + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" + } + } } \ No newline at end of file diff --git a/example/grpc-lib/build.gradle b/example/grpc-lib/build.gradle index e60803858..30d19923d 100644 --- a/example/grpc-lib/build.gradle +++ b/example/grpc-lib/build.gradle @@ -34,3 +34,9 @@ idea { generatedSourceDirs += file("src/generated/main/grpc") } } + +buildscript { + dependencies { + classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.6' + } +} \ No newline at end of file diff --git a/example/grpc-server/build.gradle b/example/grpc-server/build.gradle index d3785eb96..a50c8f9a1 100644 --- a/example/grpc-server/build.gradle +++ b/example/grpc-server/build.gradle @@ -8,3 +8,14 @@ dependencies { compile project(':example:grpc-lib') compile project(':grpc-spring-boot-starter') } + +buildscript { + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") + } + dependencyManagement { + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" + } + } +} \ No newline at end of file diff --git a/grpc-spring-boot-autoconfigure/build.gradle b/grpc-spring-boot-autoconfigure/build.gradle index 3483259b9..96a90a43c 100644 --- a/grpc-spring-boot-autoconfigure/build.gradle +++ b/grpc-spring-boot-autoconfigure/build.gradle @@ -2,32 +2,11 @@ apply plugin: 'propdeps' apply plugin: 'propdeps-maven' apply plugin: 'propdeps-idea' apply plugin: 'propdeps-eclipse' -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" - } - } - } -} - compileJava.dependsOn(processResources) dependencies { diff --git a/grpc-spring-boot-starter/build.gradle b/grpc-spring-boot-starter/build.gradle index 670d1929c..ba875884f 100644 --- a/grpc-spring-boot-starter/build.gradle +++ b/grpc-spring-boot-starter/build.gradle @@ -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') } diff --git a/private.key.enc b/private.key.enc new file mode 100644 index 000000000..af7f96d60 Binary files /dev/null and b/private.key.enc differ