-
Notifications
You must be signed in to change notification settings - Fork 98
/
binary_compatibility.gradle
49 lines (43 loc) · 1.61 KB
/
binary_compatibility.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// code from: https://github.com/Visistema/Groovy1/blob/ba5eb9b2f19ca0cc8927359ce414c4e1974b7016/gradle/binarycompatibility.gradle#L48
import me.champeau.gradle.japicmp.JapicmpTask
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
// explicitly depending on guava here because of https://github.com/melix/japicmp-gradle-plugin/issues/36
classpath "com.google.guava:guava:${versions.guava}"
classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.4.2'
}
}
File baselineJar = null
def baselineVersion = "2.0.0"
def projectGroup = project.group
def projectName = project.name
try {
String dependency = "$projectGroup:$projectName:$baselineVersion@jar"
String jarFile = "$projectName-${baselineVersion}.jar"
project.group = 'group_that_does_not_exist'
baselineJar = files(configurations.detachedConfiguration(
dependencies.create(dependency)
).files).filter {
it.name.equals(jarFile)
}.singleFile
} catch (org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException e) {
// Skip if there is no baseline version
} finally {
project.group = projectGroup
}
if (baselineJar != null) {
task japicmp(type: JapicmpTask, dependsOn: jar) {
oldClasspath.from(files(baselineJar))
newArchives.from(files(jar.archivePath))
newClasspath.from(configurations.runtimeClasspath)
onlyModified = true
failOnModification = true
ignoreMissingClasses = true
htmlOutputFile = file("$buildDir/reports/japi.html")
}
}