Skip to content

Linkage Checker with Gradle

Tomo Suzuki edited this page Apr 13, 2020 · 13 revisions

(This page is still in draft.)

To detect linkage errors in Maven artifacts generated by a Gradle project, you can first install the artifact in Maven local repository using Gradle's Maven Publish Plugin and then run LinkageCheckerMain with your artifact coordinates.

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

project.task('runLinkageChecker', type: JavaExec) {
  // Replace 'MavenJava' with your publication name
  dependsOn project.getTasksByName('publishMavenJavaPublicationToMavenLocal', true)
  classpath = project.configurations.linkageChecker
  main = 'com.google.cloud.tools.opensource.classpath.LinkageCheckerMain'
  args '-a', 'com.example:foo:0.1.0-SNAPSHOT' // the coordinate of the Maven artifact
}

Clone this wiki locally