Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Linkage Checker to examine linkage error at artifact level #1032

Merged
merged 10 commits into from May 26, 2020
5 changes: 5 additions & 0 deletions .kokoro/linkage-monitor.sh
Expand Up @@ -23,6 +23,7 @@ cd github/gax-java/
java -version
echo ${JOB_TYPE}

# Linkage Monitor checks the compatibility of GAX BOM
# Using Gradle's maven-publish plugin. No need to sign the JAR.
./gradlew build publishToMavenLocal -x test -x signMavenJavaPublication

Expand All @@ -32,3 +33,7 @@ curl -v -O "https://storage.googleapis.com/cloud-opensource-java-linkage-monitor

# Fails if there's new linkage errors compared with baseline
java -jar ${JAR} com.google.cloud:libraries-bom


# Linkage Checker looks for linkage errors at artifact level: gax, gax-grpc, and gax-httpjson
./gradlew checkJavaLinkage
20 changes: 20 additions & 0 deletions build.gradle
Expand Up @@ -141,6 +141,7 @@ subprojects {

configurations {
shadowNoGuava
linkageChecker
}

jacocoTestReport {
Expand Down Expand Up @@ -233,6 +234,9 @@ subprojects {
dependencies {
codeGeneration libraries['maven.com_google_auto_value_auto_value'],
libraries['maven.com_google_code_findbugs_jsr305']

// Separate configuration (class path) for Linkage Checker
linkageChecker "com.google.cloud.tools:dependencies:1.4.0"
}

compileJava.classpath += configurations.codeGeneration
Expand Down Expand Up @@ -336,6 +340,22 @@ subprojects {
}
}
}

task checkJavaLinkage(type: JavaExec) {
// Example invocation:
// ./gradlew gax-httpjson:checkJavaLinkage
dependsOn project.getTasksByName('publishMavenJavaPublicationToMavenLocal', true)
classpath = configurations.linkageChecker
main = 'com.google.cloud.tools.opensource.classpath.LinkageCheckerMain'

def arguments = ['-a', "com.google.api:${project.name}:${project.version}"]
if (project.name == 'gax-grpc') {
// The exclusion file can be regenerated by '-o' option. See its Wiki for details:
// https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/LinkageCheckerMain#exclusion-files
arguments += ['--exclusion-file', 'linkage-checker-exclusion.xml']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me wonder if we really need to set the name and have a command line argument at all. Does it make sense to have a standard filename and location where the linkage checker looks?

}
args arguments
}
}

signing {
Expand Down