-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathbuild.gradle
More file actions
142 lines (124 loc) · 4.46 KB
/
build.gradle
File metadata and controls
142 lines (124 loc) · 4.46 KB
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
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 'java-library'
id 'jacoco'
id 'me.champeau.gradle.japicmp' version '0.4.6'
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
}
repositories {
mavenCentral()
}
apply from: rootProject.file('gradle/versioning.gradle')
version = getVersionFromFile()
group = GROUP
logger.lifecycle("Using version ${version} for ${name} group $group")
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.from(files(getBaselineJar(project, baselineVersion)))
newClasspath.from(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
}
}
ext {
baselineCompareVersion = '1.5.0'
testInJavaVersions = [8, 11, 17, 21]
}
jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
// Needed because of broken gradle metadata, see https://github.com/google/guava/issues/6612#issuecomment-1614992368
sourceSets.all {
configurations.getByName(runtimeClasspathConfigurationName) {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
configurations.getByName(compileClasspathConfigurationName) {
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
}
}
}
compileJava {
sourceCompatibility '1.8'
targetCompatibility '1.8'
}
test {
useJUnitPlatform()
testLogging {
events "skipped", "failed"
exceptionFormat "short"
}
}
dependencies {
implementation 'javax.servlet:javax.servlet-api:3.1.0'
implementation 'org.apache.commons:commons-lang3:3.20.0'
implementation 'com.google.guava:guava-annotations:r03'
implementation 'commons-codec:commons-codec:1.21.0'
api 'com.auth0:auth0:1.45.1'
api 'com.auth0:java-jwt:3.19.4'
api 'com.auth0:jwks-rsa:0.23.0'
testImplementation 'org.bouncycastle:bcprov-jdk15on:1.70'
testImplementation 'org.hamcrest:java-hamcrest:2.0.0.0'
testImplementation 'org.hamcrest:hamcrest-core:1.3'
testImplementation 'org.mockito:mockito-core:2.28.2'
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
testImplementation 'org.springframework:spring-test:4.3.30.RELEASE'
testImplementation 'com.squareup.okhttp3:okhttp:4.12.0'
}
apply from: rootProject.file('gradle/maven-publish.gradle')