@@ -6,6 +6,7 @@ import junitbuild.compatibility.japicmp.AcceptedViolationsPostProcessRule
6
6
import junitbuild.compatibility.japicmp.BreakingSuperClassChangeRule
7
7
import junitbuild.compatibility.japicmp.InternalApiFilter
8
8
import junitbuild.compatibility.japicmp.SourceIncompatibleRule
9
+ import junitbuild.extensions.dependencyFromLibs
9
10
import junitbuild.extensions.javaModuleName
10
11
import me.champeau.gradle.japicmp.JapicmpTask
11
12
import me.champeau.gradle.japicmp.report.stdrules.BinaryIncompatibleRule
@@ -17,6 +18,14 @@ plugins {
17
18
id(" me.champeau.gradle.japicmp" )
18
19
}
19
20
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
+
20
29
val extension = extensions.create<BackwardCompatibilityChecksExtension >(" backwardCompatibilityChecks" ).apply {
21
30
enabled.convention(true )
22
31
acceptedIncompatibilities.apply {
@@ -49,11 +58,49 @@ val downloadPreviousReleaseJar by tasks.registering(Download::class) {
49
58
outputs.cacheIf { true }
50
59
}
51
60
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 ) {
53
64
if (gradle.startParameter.isOffline) {
54
65
enabled = false
55
66
}
56
67
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
+
57
104
oldClasspath.from(downloadPreviousReleaseJar.map { it.outputFiles })
58
105
newClasspath.from(tasks.jar)
59
106
onlyModified = true
@@ -73,6 +120,10 @@ val checkBackwardCompatibility by tasks.registering(JapicmpTask::class) {
73
120
}
74
121
}
75
122
123
+ val checkBackwardCompatibility by tasks.registering {
124
+ dependsOn(roseau, japicmp)
125
+ }
126
+
76
127
tasks.check {
77
128
dependsOn(checkBackwardCompatibility)
78
129
}
@@ -81,7 +132,7 @@ afterEvaluate {
81
132
val params = mapOf (
82
133
" acceptedIncompatibilities" to extension.acceptedIncompatibilities.get().joinToString(" ," )
83
134
)
84
- checkBackwardCompatibility {
135
+ japicmp {
85
136
richReport {
86
137
addViolationTransformer(AcceptedViolationSuppressor ::class .java, params)
87
138
addPostProcessRule(AcceptedViolationsPostProcessRule ::class .java, params)
0 commit comments