@@ -6,6 +6,7 @@ import junitbuild.compatibility.japicmp.AcceptedViolationsPostProcessRule
66import junitbuild.compatibility.japicmp.BreakingSuperClassChangeRule
77import junitbuild.compatibility.japicmp.InternalApiFilter
88import junitbuild.compatibility.japicmp.SourceIncompatibleRule
9+ import junitbuild.extensions.dependencyFromLibs
910import junitbuild.extensions.javaModuleName
1011import me.champeau.gradle.japicmp.JapicmpTask
1112import me.champeau.gradle.japicmp.report.stdrules.BinaryIncompatibleRule
@@ -17,6 +18,14 @@ plugins {
1718 id(" me.champeau.gradle.japicmp" )
1819}
1920
21+ val roseauDependencies = configurations.dependencyScope(" roseau" )
22+ val roseauClasspath = configurations.resolvable(" roseauClasspath" ) {
23+ extendsFrom(roseauDependencies.get())
24+ }
25+ dependencies {
26+ roseauDependencies(dependencyFromLibs(" roseau-cli" ))
27+ }
28+
2029val extension = extensions.create<BackwardCompatibilityChecksExtension >(" backwardCompatibilityChecks" ).apply {
2130 enabled.convention(true )
2231 acceptedIncompatibilities.apply {
@@ -49,11 +58,49 @@ val downloadPreviousReleaseJar by tasks.registering(Download::class) {
4958 outputs.cacheIf { true }
5059}
5160
52- val checkBackwardCompatibility by tasks.registering(JapicmpTask ::class ) {
61+ val roseauCsvFile = layout.buildDirectory.file(" reports/roseau/breaking-changes.csv" )
62+
63+ val roseau by tasks.registering(JavaExec ::class ) {
5364 if (gradle.startParameter.isOffline) {
5465 enabled = false
5566 }
5667 onlyIf { extension.enabled.get() }
68+
69+ mainClass = " io.github.alien.roseau.cli.RoseauCLI"
70+ classpath = files(roseauClasspath)
71+
72+ inputs.files(configurations.compileClasspath).withNormalizer(CompileClasspathNormalizer ::class ).withPropertyName(" apiClasspath" )
73+
74+ val v1Jar = downloadPreviousReleaseJar.map { it.outputFiles.single() }
75+ inputs.file(v1Jar).withNormalizer(CompileClasspathNormalizer ::class ).withPropertyName(" v1" )
76+
77+ val v2Jar = tasks.jar.flatMap { it.archiveFile}.map { it.asFile }
78+ inputs.file(v2Jar).withNormalizer(CompileClasspathNormalizer ::class ).withPropertyName(" v2" )
79+
80+ outputs.file(roseauCsvFile).withPropertyName(" report" )
81+
82+ argumentProviders.add(CommandLineArgumentProvider {
83+ listOf (
84+ " --classpath" , configurations.compileClasspath.get().files.joinToString(" :" ) { file -> file.absolutePath },
85+ " --v1" , v1Jar.get().absolutePath,
86+ " --v2" , v2Jar.get().absolutePath,
87+ " --diff" ,
88+ " --report" , roseauCsvFile.get().asFile.absolutePath,
89+ )
90+ })
91+
92+ doFirst {
93+ roseauCsvFile.get().asFile.parentFile.mkdirs()
94+ }
95+ }
96+
97+ val japicmp by tasks.registering(JapicmpTask ::class ) {
98+ if (gradle.startParameter.isOffline) {
99+ enabled = false
100+ }
101+ onlyIf { extension.enabled.get() }
102+ shouldRunAfter(roseau)
103+
57104 oldClasspath.from(downloadPreviousReleaseJar.map { it.outputFiles })
58105 newClasspath.from(tasks.jar)
59106 onlyModified = true
@@ -73,6 +120,10 @@ val checkBackwardCompatibility by tasks.registering(JapicmpTask::class) {
73120 }
74121}
75122
123+ val checkBackwardCompatibility by tasks.registering {
124+ dependsOn(roseau, japicmp)
125+ }
126+
76127tasks.check {
77128 dependsOn(checkBackwardCompatibility)
78129}
@@ -81,7 +132,7 @@ afterEvaluate {
81132 val params = mapOf (
82133 " acceptedIncompatibilities" to extension.acceptedIncompatibilities.get().joinToString(" ," )
83134 )
84- checkBackwardCompatibility {
135+ japicmp {
85136 richReport {
86137 addViolationTransformer(AcceptedViolationSuppressor ::class .java, params)
87138 addPostProcessRule(AcceptedViolationsPostProcessRule ::class .java, params)
0 commit comments