Skip to content
Permalink
Browse files

Enable publish to maven central via Sonatype with plugin scoping (#849)

* Enable publish to maven central via Sonatype

__Motivation__

Directly publishing to sonatype maven central gives us more control over the artifacts to be promoted to central.

__Modifications__

- add POM metadata as required by maven central
- add signing of artifacts as per maven central requirements
- update Docker Compose to pass PGP and Sonatype credentials from the ENV
- disable bintray publishing

__Result__

Gradle can now publish to maven central.
  • Loading branch information
jayv committed Nov 7, 2019
1 parent 200e7e2 commit f67ce6fd5e99e6e9e8115141f7f0fe09723df3a8
Showing with 123 additions and 59 deletions.
  1. +1 −1 build.gradle
  2. +10 −2 docker/docker-compose.yaml
  3. +1 −1 servicetalk-annotations/build.gradle
  4. +1 −1 servicetalk-benchmarks/build.gradle
  5. +1 −1 servicetalk-bom/build.gradle
  6. +1 −1 servicetalk-buffer-api/build.gradle
  7. +1 −1 servicetalk-buffer-netty/build.gradle
  8. +1 −1 servicetalk-client-api-internal/build.gradle
  9. +1 −1 servicetalk-client-api/build.gradle
  10. +1 −1 servicetalk-concurrent-api-internal/build.gradle
  11. +1 −1 servicetalk-concurrent-api/build.gradle
  12. +1 −1 servicetalk-concurrent-internal/build.gradle
  13. +1 −1 servicetalk-concurrent-reactivestreams/build.gradle
  14. +1 −1 servicetalk-concurrent/build.gradle
  15. +1 −1 servicetalk-data-jackson-jersey/build.gradle
  16. +1 −1 servicetalk-data-jackson/build.gradle
  17. +1 −1 servicetalk-data-protobuf/build.gradle
  18. +1 −1 servicetalk-dns-discovery-netty/build.gradle
  19. +1 −1 servicetalk-examples/grpc/helloworld/build.gradle
  20. +1 −1 servicetalk-examples/grpc/routeguide/build.gradle
  21. +1 −1 servicetalk-gradle-plugin-internal/build.gradle
  22. +3 −3 servicetalk-gradle-plugin-internal/plugin-config.gradle
  23. +2 −2 ...lugin-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ServiceTalkCorePlugin.groovy
  24. +56 −0 ...in-internal/src/main/groovy/io/servicetalk/gradle/plugin/internal/ServiceTalkLibraryPlugin.groovy
  25. +1 −1 servicetalk-grpc-api/build.gradle
  26. +1 −1 servicetalk-grpc-gradle-plugin/README.adoc
  27. +1 −1 servicetalk-grpc-gradle-plugin/build.gradle
  28. +1 −1 servicetalk-grpc-gradle-plugin/plugin-config.gradle
  29. +2 −2 servicetalk-grpc-netty/build.gradle
  30. +1 −1 servicetalk-grpc-protobuf/build.gradle
  31. +1 −1 servicetalk-grpc-protoc/build.gradle
  32. +1 −1 servicetalk-http-api/build.gradle
  33. +1 −1 servicetalk-http-netty/build.gradle
  34. +1 −1 servicetalk-http-router-jersey-internal/build.gradle
  35. +1 −1 servicetalk-http-router-jersey/build.gradle
  36. +1 −1 servicetalk-http-router-predicate/build.gradle
  37. +1 −1 servicetalk-http-security-jersey/build.gradle
  38. +1 −1 servicetalk-http-utils/build.gradle
  39. +1 −1 servicetalk-loadbalancer/build.gradle
  40. +1 −1 servicetalk-log4j2-mdc-utils/build.gradle
  41. +1 −1 servicetalk-log4j2-mdc/build.gradle
  42. +1 −1 servicetalk-oio-api/build.gradle
  43. +1 −1 servicetalk-opentracing-asynccontext/build.gradle
  44. +1 −1 servicetalk-opentracing-http/build.gradle
  45. +1 −1 servicetalk-opentracing-inmemory-api/build.gradle
  46. +1 −1 servicetalk-opentracing-inmemory/build.gradle
  47. +1 −1 servicetalk-opentracing-internal/build.gradle
  48. +1 −1 servicetalk-opentracing-log4j2/build.gradle
  49. +1 −1 servicetalk-opentracing-zipkin-publisher/build.gradle
  50. +1 −1 servicetalk-serialization-api/build.gradle
  51. +1 −1 servicetalk-tcp-netty-internal/build.gradle
  52. +1 −1 servicetalk-test-resources/build.gradle
  53. +1 −1 servicetalk-transport-api/build.gradle
  54. +1 −1 servicetalk-transport-netty-internal/build.gradle
  55. +1 −1 servicetalk-transport-netty/build.gradle
@@ -29,7 +29,7 @@ if (!repositories) {
}
}

apply plugin: "servicetalk-root"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-root"

task validateLocalDocSite(type: Exec) {
workingDir 'docs/generation'
@@ -71,9 +71,13 @@ services:
- CI
- BINTRAY_USER
- BINTRAY_KEY
- ORG_GRADLE_PROJECT_signingKey
- ORG_GRADLE_PROJECT_signingPassword
- SONATYPE_USER
- SONATYPE_TOKEN
command: >
bash -cl "./gradlew --no-daemon --parallel --max-workers=4 clean check &&
./gradlew --no-daemon bintrayUpload"
./gradlew --no-daemon publish"
publish-release:
<< : *common
@@ -82,9 +86,13 @@ services:
- CI
- BINTRAY_USER
- BINTRAY_KEY
- ORG_GRADLE_PROJECT_signingKey
- ORG_GRADLE_PROJECT_signingPassword
- SONATYPE_USER
- SONATYPE_TOKEN
command: >
bash -cl "./gradlew --no-daemon --parallel --max-workers=4 -PreleaseBuild=true clean check &&
./gradlew --no-daemon -PreleaseBuild=true bintrayUpload"
./gradlew --no-daemon -PreleaseBuild=true publish"
shell:
<< : *common
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
implementation "com.google.code.findbugs:jsr305:$jsr305Version"
@@ -19,7 +19,7 @@ plugins {
id "me.champeau.gradle.jmh" version "0.5.0-rc-2"
}

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
implementation project(":servicetalk-annotations")
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-core"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-core"
apply plugin: "java-platform"

rootProject.subprojects.findAll { !it.name.contains("bom") && !it.name.contains("examples") }.each {
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
implementation project(":servicetalk-annotations")
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
api project(":servicetalk-buffer-api")
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
api project(":servicetalk-client-api")
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
api project(":servicetalk-concurrent-api")
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
api project(":servicetalk-concurrent-api")
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
api project(":servicetalk-concurrent")
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
api project(":servicetalk-concurrent")
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
api project(":servicetalk-concurrent-api")
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
implementation project(":servicetalk-annotations")
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
implementation project(":servicetalk-annotations")
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
api "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
@@ -20,7 +20,7 @@ buildscript {
}
}

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"
apply plugin: "com.google.protobuf"

ideaModule.dependsOn "generateTestProto"
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
api project(":servicetalk-client-api")
@@ -15,7 +15,7 @@
*/

apply plugin: "java"
apply plugin: "servicetalk-grpc"
apply plugin: "io.servicetalk.servicetalk-grpc-gradle-plugin"
apply from: "../../gradle/idea.gradle"

dependencies {
@@ -15,7 +15,7 @@
*/

apply plugin: "java"
apply plugin: "servicetalk-grpc"
apply plugin: "io.servicetalk.servicetalk-grpc-gradle-plugin"
apply from: "../../gradle/idea.gradle"

dependencies {
@@ -16,7 +16,7 @@

io.servicetalk.gradle.plugin.internal.ProjectUtils.inheritRepositoriesFromBuildscript(project)

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"
apply plugin: "groovy"
apply plugin: "java-gradle-plugin"
apply from: "plugin-config.gradle"
@@ -28,15 +28,15 @@ dependencies {
gradlePlugin {
plugins {
serviceTalkCorePlugin {
id = "servicetalk-core"
id = "io.servicetalk.servicetalk-gradle-plugin-internal-core"
implementationClass = "io.servicetalk.gradle.plugin.internal.ServiceTalkCorePlugin"
}
serviceTalkRootPlugin {
id = "servicetalk-root"
id = "io.servicetalk.servicetalk-gradle-plugin-internal-root"
implementationClass = "io.servicetalk.gradle.plugin.internal.ServiceTalkRootPlugin"
}
serviceTalkLibraryPlugin {
id = "servicetalk-library"
id = "io.servicetalk.servicetalk-gradle-plugin-internal-library"
implementationClass = "io.servicetalk.gradle.plugin.internal.ServiceTalkLibraryPlugin"
}
}
@@ -43,8 +43,8 @@ class ServiceTalkCorePlugin implements Plugin<Project> {
applyIdeaPlugin project

if (publishesArtifacts) {
applyMavenPublishPlugin project
applyBintrayPlugin project
applyMavenPublishPlugin project // Sign & Publish to Maven Central
// applyBintrayPlugin project // Publish to Bintray, depends on applyMavenPublishPlugin
}
}

@@ -19,6 +19,7 @@ import com.github.spotbugs.SpotBugsTask
import org.gradle.api.Project
import org.gradle.api.plugins.quality.Pmd
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven

import static io.servicetalk.gradle.plugin.internal.ProjectUtils.addManifestAttributes
import static io.servicetalk.gradle.plugin.internal.ProjectUtils.addQualityTask
@@ -43,6 +44,8 @@ final class ServiceTalkLibraryPlugin extends ServiceTalkCorePlugin {
}

private static void applyJavaLibraryPlugin(Project project) {


project.configure(project) {
pluginManager.apply("java-library")

@@ -74,8 +77,61 @@ final class ServiceTalkLibraryPlugin extends ServiceTalkCorePlugin {
from components.java
artifact(javadocJar)
artifact(sourcesJar)
pom {
name = project.name
description = 'A networking framework that evolves with your application'
url = 'https://servicetalk.io'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'servicetalk-project-authors'
name = 'ServiceTalk project authors'
email = 'servicetalk-oss@group.apple.com'
}
}
scm {
connection = 'scm:git:git://github.com/apple/servicetalk.git'
developerConnection = 'scm:git:ssh://github.com:apple/servicetalk.git'
url = 'https://github.com/apple/servicetalk'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = project.isReleaseBuild ? releasesRepoUrl : snapshotsRepoUrl
credentials {
username = System.getenv("SONATYPE_USER")
password = System.getenv("SONATYPE_TOKEN")
}
}
}
}

if (!!findProperty("signingKey") && !!findProperty("signingPassword")) {
pluginManager.apply("signing")
signing {
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.mavenJava
}
}

tasks.withType(AbstractPublishToMaven) {
onlyIf {
// Disable all tasks that try to publish something else, expect defined "mavenJava" publication.
// That could be automatically configured "pluginMaven" publication for gradle plugins that are required
// only for Gradle Plugin Portal and should not be published to Maven Central
publication == publishing.publications.mavenJava
}
}
}
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
api project(":servicetalk-concurrent-api")
@@ -19,7 +19,7 @@ buildscript {
}
apply plugin: "java"
apply plugin: "servicetalk-grpc"
apply plugin: "io.servicetalk.servicetalk-grpc-gradle-plugin"
serviceTalkGrpc {
protobufVersion = "3.10.0"
@@ -16,7 +16,7 @@

io.servicetalk.gradle.plugin.internal.ProjectUtils.inheritRepositoriesFromBuildscript(project)

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"
apply plugin: "groovy"
apply plugin: "java-gradle-plugin"
apply from: "plugin-config.gradle"
@@ -27,7 +27,7 @@ dependencies {
gradlePlugin {
plugins {
serviceTalkGrpcPlugin {
id = "servicetalk-grpc"
id = "io.servicetalk.servicetalk-grpc-gradle-plugin"
implementationClass = "io.servicetalk.grpc.gradle.plugin.ServiceTalkGrpcPlugin"
}
}
@@ -14,8 +14,8 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "servicetalk-grpc"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"
apply plugin: "io.servicetalk.servicetalk-grpc-gradle-plugin"

dependencies {
api project(":servicetalk-grpc-api")
@@ -20,7 +20,7 @@ buildscript {
}
}

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"
apply plugin: "com.google.protobuf"

ideaModule.dependsOn "generateTestProto"
@@ -20,7 +20,7 @@ buildscript {
}
}

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "com.google.protobuf"

@@ -14,7 +14,7 @@
* limitations under the License.
*/

apply plugin: "servicetalk-library"
apply plugin: "io.servicetalk.servicetalk-gradle-plugin-internal-library"

dependencies {
api project(":servicetalk-buffer-api")

0 comments on commit f67ce6f

Please sign in to comment.
You can’t perform that action at this time.