Apply maven-publish plugin explicitly when needed

This commit is contained in:
Eric Anderson 2019-09-07 09:27:32 -07:00
parent 55ac6f08af
commit 5b838e5284
22 changed files with 131 additions and 84 deletions

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "com.github.kt3k.coveralls" id "com.github.kt3k.coveralls"
} }

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "com.github.johnrengelman.shadow" id "com.github.johnrengelman.shadow"
id "com.google.protobuf" id "com.google.protobuf"
} }

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "me.champeau.gradle.jmh" id "me.champeau.gradle.jmh"
} }

View File

@ -1,3 +1,7 @@
plugins {
id "maven-publish"
}
description = "gRPC: Auth" description = "gRPC: Auth"
dependencies { dependencies {
compile project(':grpc-api'), compile project(':grpc-api'),

View File

@ -1,5 +1,6 @@
plugins { plugins {
id "application" id "application"
id "maven-publish"
id "com.google.protobuf" id "com.google.protobuf"
id "me.champeau.gradle.jmh" id "me.champeau.gradle.jmh"

View File

@ -1,3 +1,7 @@
plugins {
id "maven-publish"
}
description = 'gRPC: BOM' description = 'gRPC: BOM'
publishing { publishing {

View File

@ -11,7 +11,6 @@ subprojects {
apply plugin: "checkstyle" apply plugin: "checkstyle"
apply plugin: "java" apply plugin: "java"
apply plugin: "maven" apply plugin: "maven"
apply plugin: "maven-publish"
apply plugin: "idea" apply plugin: "idea"
apply plugin: "signing" apply plugin: "signing"
apply plugin: "jacoco" apply plugin: "jacoco"
@ -305,109 +304,107 @@ subprojects {
} }
} }
task javadocJar(type: Jar) { plugins.withId("maven-publish") {
classifier = 'javadoc' task javadocJar(type: Jar) {
from javadoc classifier = 'javadoc'
} from javadoc
}
task sourcesJar(type: Jar) { task sourcesJar(type: Jar) {
classifier = 'sources' classifier = 'sources'
from sourceSets.main.allSource from sourceSets.main.allSource
} }
publishing { publishing {
publications { publications {
// do not use mavenJava, as java plugin will modify it via "magic" // do not use mavenJava, as java plugin will modify it via "magic"
maven(MavenPublication) { maven(MavenPublication) {
if (project.name != 'grpc-netty-shaded') { if (project.name != 'grpc-netty-shaded') {
from components.java from components.java
}
artifact javadocJar
artifact sourcesJar
pom {
name = project.group + ":" + project.name
url = 'https://github.com/grpc/grpc-java'
afterEvaluate {
// description is not available until evaluated.
description = project.description
} }
scm { artifact javadocJar
connection = 'scm:git:https://github.com/grpc/grpc-java.git' artifact sourcesJar
developerConnection = 'scm:git:git@github.com:grpc/grpc-java.git'
pom {
name = project.group + ":" + project.name
url = 'https://github.com/grpc/grpc-java' url = 'https://github.com/grpc/grpc-java'
} afterEvaluate {
// description is not available until evaluated.
licenses { description = project.description
license {
name = 'Apache 2.0'
url = 'https://opensource.org/licenses/Apache-2.0'
} }
}
developers { scm {
developer { connection = 'scm:git:https://github.com/grpc/grpc-java.git'
id = "grpc.io" developerConnection = 'scm:git:git@github.com:grpc/grpc-java.git'
name = "gRPC Contributors" url = 'https://github.com/grpc/grpc-java'
email = "grpc-io@googlegroups.com"
url = "https://grpc.io/"
organization = "gRPC Authors"
organizationUrl = "https://www.google.com"
} }
}
withXml { licenses {
if (!(project.name in license {
[ name = 'Apache 2.0'
"grpc-stub", url = 'https://opensource.org/licenses/Apache-2.0'
"grpc-protobuf", }
"grpc-protobuf-lite", }
])) {
asNode().dependencies.'*'.findAll() { dep -> developers {
dep.artifactId.text() in ['grpc-api', 'grpc-core'] developer {
}.each() { core -> id = "grpc.io"
core.version*.value = "[" + core.version.text() + "]" name = "gRPC Contributors"
email = "grpc-io@googlegroups.com"
url = "https://grpc.io/"
organization = "gRPC Authors"
organizationUrl = "https://www.google.com"
}
}
withXml {
if (!(project.name in
[
"grpc-stub",
"grpc-protobuf",
"grpc-protobuf-lite",
])) {
asNode().dependencies.'*'.findAll() { dep ->
dep.artifactId.text() in ['grpc-api', 'grpc-core']
}.each() { core ->
core.version*.value = "[" + core.version.text() + "]"
}
} }
} }
} }
} }
} }
} repositories {
repositories { maven {
maven { if (rootProject.hasProperty('repositoryDir')) {
if (rootProject.hasProperty('repositoryDir')) { url = new File(rootProject.repositoryDir).toURI()
url = new File(rootProject.repositoryDir).toURI()
} else {
String stagingUrl
if (rootProject.hasProperty('repositoryId')) {
stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
rootProject.repositoryId
} else { } else {
stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' String stagingUrl
} if (rootProject.hasProperty('repositoryId')) {
credentials { stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) { rootProject.repositoryId
username = rootProject.ossrhUsername } else {
password = rootProject.ossrhPassword stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
} }
credentials {
if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
username = rootProject.ossrhUsername
password = rootProject.ossrhPassword
}
}
def releaseUrl = stagingUrl
def snapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
url = version.endsWith('SNAPSHOT') ? snapshotUrl : releaseUrl
} }
def releaseUrl = stagingUrl }
def snapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
url = version.endsWith('SNAPSHOT') ? snapshotUrl : releaseUrl
}
} }
} }
}
signing { signing {
required false required false
sign publishing.publications.maven sign publishing.publications.maven
} }
[publishMavenPublicationToMavenRepository, publishMavenPublicationToMavenLocal]*.onlyIf {
!name.contains("grpc-gae-interop-testing") && !name.contains("grpc-xds")
} }
// At a test failure, log the stack trace to the console so that we don't // At a test failure, log the stack trace to the console so that we don't

View File

@ -1,5 +1,6 @@
plugins { plugins {
id "cpp" id "cpp"
id "maven-publish"
id "com.google.protobuf" id "com.google.protobuf"
} }

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "me.champeau.gradle.jmh" id "me.champeau.gradle.jmh"
} }

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "me.champeau.gradle.jmh" id "me.champeau.gradle.jmh"
} }

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "com.google.protobuf" id "com.google.protobuf"
} }

View File

@ -1,5 +1,6 @@
plugins { plugins {
id "application" id "application"
id "maven-publish"
id "com.google.protobuf" id "com.google.protobuf"
} }

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "me.champeau.gradle.jmh" id "me.champeau.gradle.jmh"
} }

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "com.github.johnrengelman.shadow" id "com.github.johnrengelman.shadow"
} }

View File

@ -1,3 +1,7 @@
plugins {
id "maven-publish"
}
description = "gRPC: OkHttp" description = "gRPC: OkHttp"
dependencies { dependencies {

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "com.google.protobuf" id "com.google.protobuf"
} }

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "com.google.protobuf" id "com.google.protobuf"
} }

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "com.google.protobuf" id "com.google.protobuf"
} }

View File

@ -1,3 +1,7 @@
plugins {
id "maven-publish"
}
description = "gRPC: Stub" description = "gRPC: Stub"
dependencies { dependencies {
compile project(':grpc-api') compile project(':grpc-api')

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "com.google.protobuf" id "com.google.protobuf"
} }

View File

@ -1,3 +1,7 @@
plugins {
id "maven-publish"
}
description = "gRPC: Testing" description = "gRPC: Testing"
dependencies { dependencies {

View File

@ -1,4 +1,6 @@
plugins { plugins {
id "maven-publish"
id "com.github.johnrengelman.shadow" id "com.github.johnrengelman.shadow"
id "com.google.protobuf" id "com.google.protobuf"
} }
@ -68,3 +70,4 @@ publishing {
} }
} }
} }
[publishMavenPublicationToMavenRepository, publishMavenPublicationToMavenLocal]*.onlyIf { false }