-
Notifications
You must be signed in to change notification settings - Fork 130
/
build.gradle
154 lines (129 loc) · 4.27 KB
/
build.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
buildscript {
repositories {
jcenter()
}
dependencies {
// https://github.com/melix/japicmp-gradle-plugin/issues/36
classpath 'com.google.guava:guava:31.1-jre'
}
}
plugins {
id 'java'
id 'jacoco'
id 'me.champeau.gradle.japicmp' version '0.2.9'
}
repositories {
mavenCentral()
}
apply from: rootProject.file('gradle/versioning.gradle')
version = getVersionFromFile()
group = GROUP
logger.lifecycle("Using version ${version} for ${name} group $group")
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}
compileJava {
sourceCompatibility '1.8'
targetCompatibility '1.8'
options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked" << "-Werror"
}
compileTestJava {
options.compilerArgs << "-Xlint:deprecation" << "-Werror"
}
import me.champeau.gradle.japicmp.JapicmpTask
project.afterEvaluate {
def versions = project.ext.testInJavaVersions
for (pluginJavaTestVersion in versions) {
def taskName = "testInJava-${pluginJavaTestVersion}"
tasks.register(taskName, Test) {
def versionToUse = taskName.split("-").getAt(1) as Integer
description = "Runs unit tests on Java version ${versionToUse}."
project.logger.quiet("Test will be running in ${versionToUse}")
group = 'verification'
javaLauncher.set(javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(versionToUse)
})
shouldRunAfter(tasks.named('test'))
}
tasks.named('check') {
dependsOn(taskName)
}
}
project.configure(project) {
def baselineVersion = project.ext.baselineCompareVersion
task('apiDiff', type: JapicmpTask, dependsOn: 'jar') {
oldClasspath = files(getBaselineJar(project, baselineVersion))
newClasspath = files(jar.archiveFile)
onlyModified = true
failOnModification = true
ignoreMissingClasses = true
htmlOutputFile = file("$buildDir/reports/apiDiff/apiDiff.html")
txtOutputFile = file("$buildDir/reports/apiDiff/apiDiff.txt")
doLast {
project.logger.quiet("Comparing against baseline version ${baselineVersion}")
}
}
}
}
private static File getBaselineJar(Project project, String baselineVersion) {
// Use detached configuration: https://github.com/square/okhttp/blob/master/build.gradle#L270
def group = project.group
try {
def baseline = "${project.group}:${project.name}:$baselineVersion"
project.group = 'virtual_group_for_japicmp'
def dependency = project.dependencies.create(baseline + "@jar")
return project.configurations.detachedConfiguration(dependency).files.find {
it.name == "${project.name}-${baselineVersion}.jar"
}
} finally {
project.group = group
}
}
test {
testLogging {
events "skipped", "failed"
exceptionFormat "short"
}
useJUnitPlatform()
}
ext {
okhttpVersion = '4.11.0'
hamcrestVersion = '2.2'
jupiterVersion = '5.9.3'
baselineCompareVersion = '2.0.0'
testInJavaVersions = [8, 11, 17, 21]
}
dependencies {
// TODO remove direct dependency when OkHttp 4.12.0 is released
implementation ("com.squareup.okhttp3:okhttp:${okhttpVersion}") {
exclude group: 'com.squareup.okhttp3', module: 'okio'
}
implementation "com.squareup.okio:okio:3.5.0"
implementation "com.squareup.okhttp3:logging-interceptor:${okhttpVersion}"
implementation "com.fasterxml.jackson.core:jackson-databind:2.15.0"
implementation "com.auth0:java-jwt:4.4.0"
implementation "net.jodah:failsafe:2.4.4"
testImplementation "org.bouncycastle:bcprov-jdk15on:1.70"
testImplementation "org.mockito:mockito-core:4.8.1"
testImplementation "com.squareup.okhttp3:mockwebserver:${okhttpVersion}"
testImplementation "org.hamcrest:hamcrest:${hamcrestVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-api:${jupiterVersion}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${jupiterVersion}"
// Override MockWebServer's junit transitive dependency to latest v4
constraints {
testImplementation( group: 'junit', name: 'junit'){
version{
strictly "[4.13.2]"
}
}
}
}
apply from: rootProject.file('gradle/maven-publish.gradle')