diff --git a/.kokoro/linkage-monitor.sh b/.kokoro/linkage-monitor.sh index e0ed52cc2..2a1d36554 100755 --- a/.kokoro/linkage-monitor.sh +++ b/.kokoro/linkage-monitor.sh @@ -25,6 +25,7 @@ cd ${scriptDir}/.. 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 @@ -34,3 +35,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 diff --git a/build.gradle b/build.gradle index 3c281b13b..822c63d67 100644 --- a/build.gradle +++ b/build.gradle @@ -141,6 +141,7 @@ subprojects { configurations { shadowNoGuava + linkageChecker } jacocoTestReport { @@ -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 @@ -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'] + } + args arguments + } } signing { diff --git a/gax-grpc/linkage-checker-exclusion.xml b/gax-grpc/linkage-checker-exclusion.xml new file mode 100644 index 000000000..40c0c838a --- /dev/null +++ b/gax-grpc/linkage-checker-exclusion.xml @@ -0,0 +1,587 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +