Skip to content

Commit 5fdfa8d

Browse files
ejona86larry-safran
authored andcommitted
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.
1 parent f5fd74f commit 5fdfa8d

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

build.gradle

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -417,31 +417,25 @@ subprojects {
417417
def baselineGrpcVersion = '1.6.1'
418418

419419
// Get the baseline version's jar for this subproject
420-
File baselineArtifact = null
421-
// Use a detached configuration, otherwise the current version's jar will take precedence
422-
// over the baseline jar.
420+
configurations {
421+
baselineArtifact
422+
}
423423
// A necessary hack, the intuitive thing does NOT work:
424424
// https://discuss.gradle.org/t/is-the-default-configuration-leaking-into-independent-configurations/2088/6
425425
def oldGroup = project.group
426426
try {
427427
project.group = 'virtual_group_for_japicmp'
428-
String depModule = "io.grpc:${project.name}:${baselineGrpcVersion}@jar"
429-
String depJar = "${project.name}-${baselineGrpcVersion}.jar"
430-
Configuration configuration = configurations.detachedConfiguration(
431-
dependencies.create(depModule)
432-
)
433-
baselineArtifact = files(configuration.files).filter {
434-
it.name.equals(depJar)
435-
}.singleFile
428+
dependencies {
429+
baselineArtifact "io.grpc:${project.name}:${baselineGrpcVersion}@jar"
430+
}
436431
} finally {
437432
project.group = oldGroup
438433
}
439434

440435
// Add a japicmp task that compares the current .jar with baseline .jar
441436
tasks.register("japicmp", me.champeau.gradle.japicmp.JapicmpTask) {
442-
dependsOn jar
443-
oldClasspath.from baselineArtifact
444-
newClasspath.from jar.archiveFile
437+
oldClasspath.from configurations.baselineArtifact
438+
newClasspath.from tasks.named("jar")
445439
onlyBinaryIncompatibleModified = false
446440
// Be quiet about things that did not change
447441
onlyModified = true
@@ -454,12 +448,10 @@ subprojects {
454448

455449
// Also break on source incompatible changes, not just binary.
456450
// Eg adding abstract method to public class.
457-
// TODO(zpencer): enable after japicmp-gradle-plugin/pull/14
458-
// breakOnSourceIncompatibility = true
451+
failOnSourceIncompatibility = true
459452

460453
// Ignore any classes or methods marked @ExperimentalApi
461-
// TODO(zpencer): enable after japicmp-gradle-plugin/pull/15
462-
// annotationExcludes = ['@io.grpc.ExperimentalApi']
454+
annotationExcludes = ['@io.grpc.ExperimentalApi']
463455
}
464456
}
465457
}

0 commit comments

Comments
 (0)