mirror of https://github.com/grpc/grpc-java.git
android: Convert to maven-publish
com.github.dcendents:android-maven-gradle-plugin is incompatible with Gradle 5 and the project hasn't seen any activity in over a year, so it seems unlikely to get fixed. We want to use maven-publish anyway, since that's what we use elsewhere.
This commit is contained in:
parent
8536832232
commit
be819fa3fd
|
|
@ -14,12 +14,13 @@ buildscript {
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.3.0'
|
classpath 'com.android.tools.build:gradle:3.3.0'
|
||||||
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.6"
|
classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.6"
|
||||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
|
classpath "digital.wup:android-maven-publish:3.6.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply plugin: "maven-publish"
|
||||||
apply plugin: "net.ltgt.errorprone"
|
apply plugin: "net.ltgt.errorprone"
|
||||||
apply plugin: 'com.github.dcendents.android-maven'
|
apply plugin: "digital.wup.android-maven-publish"
|
||||||
apply plugin: "signing"
|
apply plugin: "signing"
|
||||||
|
|
||||||
android {
|
android {
|
||||||
|
|
@ -54,11 +55,6 @@ dependencies {
|
||||||
testImplementation 'com.google.truth:truth:0.45'
|
testImplementation 'com.google.truth:truth:0.45'
|
||||||
}
|
}
|
||||||
|
|
||||||
signing {
|
|
||||||
required false
|
|
||||||
sign configurations.archives
|
|
||||||
}
|
|
||||||
|
|
||||||
task javadocs(type: Javadoc) {
|
task javadocs(type: Javadoc) {
|
||||||
source = android.sourceSets.main.java.srcDirs
|
source = android.sourceSets.main.java.srcDirs
|
||||||
// TODO(ericgribkoff) Fix javadoc errors
|
// TODO(ericgribkoff) Fix javadoc errors
|
||||||
|
|
@ -71,7 +67,7 @@ task javadocs(type: Javadoc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task javadocsJar(type: Jar, dependsOn: javadocs) {
|
task javadocJar(type: Jar, dependsOn: javadocs) {
|
||||||
classifier = 'javadoc'
|
classifier = 'javadoc'
|
||||||
from javadocs.destinationDir
|
from javadocs.destinationDir
|
||||||
}
|
}
|
||||||
|
|
@ -81,69 +77,83 @@ task sourcesJar(type: Jar) {
|
||||||
from android.sourceSets.main.java.srcDirs
|
from android.sourceSets.main.java.srcDirs
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts {
|
publishing {
|
||||||
archives sourcesJar
|
publications {
|
||||||
archives javadocsJar
|
maven(MavenPublication) {
|
||||||
}
|
from components.android
|
||||||
|
|
||||||
uploadArchives.repositories.mavenDeployer {
|
artifact javadocJar
|
||||||
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
artifact sourcesJar
|
||||||
if (rootProject.hasProperty('repositoryDir')) {
|
|
||||||
repository(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 {
|
|
||||||
stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
|
|
||||||
}
|
|
||||||
def configureAuth = {
|
|
||||||
if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
|
|
||||||
authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
repository(url: stagingUrl, configureAuth)
|
|
||||||
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[
|
pom {
|
||||||
install.repositories.mavenInstaller,
|
name = project.group + ":" + project.name
|
||||||
uploadArchives.repositories.mavenDeployer,
|
url = 'https://github.com/grpc/grpc-java'
|
||||||
]*.pom*.whenConfigured { pom ->
|
afterEvaluate {
|
||||||
pom.project {
|
// description is not available until evaluated.
|
||||||
name "$project.group:$project.name"
|
description = project.description
|
||||||
description project.description
|
}
|
||||||
url 'https://conscrypt.org/'
|
|
||||||
|
|
||||||
scm {
|
scm {
|
||||||
connection 'scm:git:https://github.com/grpc/grpc-java.git'
|
connection = 'scm:git:https://github.com/grpc/grpc-java.git'
|
||||||
developerConnection 'scm:git:git@github.com:grpc/grpc-java.git'
|
developerConnection = 'scm:git:git@github.com:grpc/grpc-java.git'
|
||||||
url 'https://github.com/grpc/grpc-java'
|
url = 'https://github.com/grpc/grpc-java'
|
||||||
}
|
}
|
||||||
|
|
||||||
licenses {
|
licenses {
|
||||||
license {
|
license {
|
||||||
name 'Apache 2.0'
|
name = 'Apache 2.0'
|
||||||
url 'https://opensource.org/licenses/Apache-2.0'
|
url = 'https://opensource.org/licenses/Apache-2.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
developers {
|
developers {
|
||||||
developer {
|
developer {
|
||||||
id "grpc.io"
|
id = "grpc.io"
|
||||||
name "gRPC Contributors"
|
name = "gRPC Contributors"
|
||||||
email "grpc-io@googlegroups.com"
|
email = "grpc-io@googlegroups.com"
|
||||||
url "https://grpc.io/"
|
url = "https://grpc.io/"
|
||||||
organization = "gRPC Authors"
|
organization = "gRPC Authors"
|
||||||
organizationUrl "https://www.google.com"
|
organizationUrl = "https://www.google.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
withXml {
|
||||||
|
asNode().dependencies.'*'.findAll() { dep ->
|
||||||
|
dep.artifactId.text() in ['grpc-api', 'grpc-core']
|
||||||
|
}.each() { core ->
|
||||||
|
core.version*.value = "[" + core.version.text() + "]"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def core = pom.dependencies.find {dep -> dep.artifactId == 'grpc-core'}
|
repositories {
|
||||||
if (core != null) {
|
maven {
|
||||||
// Depend on specific version of grpc-core because internal package is unstable
|
if (rootProject.hasProperty('repositoryDir')) {
|
||||||
core.version = "[" + core.version + "]"
|
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 {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signing {
|
||||||
|
required false
|
||||||
|
sign publishing.publications.maven
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ readonly GRPC_JAVA_DIR="$(cd "$(dirname "$0")"/../.. && pwd)"
|
||||||
echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"
|
echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"
|
||||||
LOCAL_MVN_TEMP=$(mktemp -d)
|
LOCAL_MVN_TEMP=$(mktemp -d)
|
||||||
pushd "$GRPC_JAVA_DIR/android"
|
pushd "$GRPC_JAVA_DIR/android"
|
||||||
../gradlew uploadArchives \
|
../gradlew publish \
|
||||||
--include-build "$GRPC_JAVA_DIR" \
|
--include-build "$GRPC_JAVA_DIR" \
|
||||||
-Dorg.gradle.parallel=false \
|
-Dorg.gradle.parallel=false \
|
||||||
-PskipCodegen=true \
|
-PskipCodegen=true \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue