build.gradle: Modernize japicmp confiuration

Even though we don't really use japicmp, the configuration was resolving
artifacts even when the task was not executed. After some clean up, the
configuration looks more ordinary.
This commit is contained in:
Eric Anderson 2023-08-11 20:46:04 -07:00
parent 849186ac35
commit 9585bc948a
1 changed files with 10 additions and 18 deletions

View File

@ -417,31 +417,25 @@ subprojects {
def baselineGrpcVersion = '1.6.1' def baselineGrpcVersion = '1.6.1'
// Get the baseline version's jar for this subproject // Get the baseline version's jar for this subproject
File baselineArtifact = null configurations {
// Use a detached configuration, otherwise the current version's jar will take precedence baselineArtifact
// over the baseline jar. }
// A necessary hack, the intuitive thing does NOT work: // A necessary hack, the intuitive thing does NOT work:
// https://discuss.gradle.org/t/is-the-default-configuration-leaking-into-independent-configurations/2088/6 // https://discuss.gradle.org/t/is-the-default-configuration-leaking-into-independent-configurations/2088/6
def oldGroup = project.group def oldGroup = project.group
try { try {
project.group = 'virtual_group_for_japicmp' project.group = 'virtual_group_for_japicmp'
String depModule = "io.grpc:${project.name}:${baselineGrpcVersion}@jar" dependencies {
String depJar = "${project.name}-${baselineGrpcVersion}.jar" baselineArtifact "io.grpc:${project.name}:${baselineGrpcVersion}@jar"
Configuration configuration = configurations.detachedConfiguration( }
dependencies.create(depModule)
)
baselineArtifact = files(configuration.files).filter {
it.name.equals(depJar)
}.singleFile
} finally { } finally {
project.group = oldGroup project.group = oldGroup
} }
// Add a japicmp task that compares the current .jar with baseline .jar // Add a japicmp task that compares the current .jar with baseline .jar
tasks.register("japicmp", me.champeau.gradle.japicmp.JapicmpTask) { tasks.register("japicmp", me.champeau.gradle.japicmp.JapicmpTask) {
dependsOn jar oldClasspath.from configurations.baselineArtifact
oldClasspath.from baselineArtifact newClasspath.from tasks.named("jar")
newClasspath.from jar.archiveFile
onlyBinaryIncompatibleModified = false onlyBinaryIncompatibleModified = false
// Be quiet about things that did not change // Be quiet about things that did not change
onlyModified = true onlyModified = true
@ -454,12 +448,10 @@ subprojects {
// Also break on source incompatible changes, not just binary. // Also break on source incompatible changes, not just binary.
// Eg adding abstract method to public class. // Eg adding abstract method to public class.
// TODO(zpencer): enable after japicmp-gradle-plugin/pull/14 failOnSourceIncompatibility = true
// breakOnSourceIncompatibility = true
// Ignore any classes or methods marked @ExperimentalApi // Ignore any classes or methods marked @ExperimentalApi
// TODO(zpencer): enable after japicmp-gradle-plugin/pull/15 annotationExcludes = ['@io.grpc.ExperimentalApi']
// annotationExcludes = ['@io.grpc.ExperimentalApi']
} }
} }
} }