-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
227 lines (209 loc) · 8.55 KB
/
build.gradle
File metadata and controls
227 lines (209 loc) · 8.55 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
import me.champeau.gradle.japicmp.JapicmpTask
import net.ltgt.gradle.errorprone.CheckSeverity
plugins {
id 'base'
alias(libs.plugins.japicmp) apply false
alias(libs.plugins.errorprone) apply false
}
allprojects {
repositories {
mavenCentral()
}
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'net.ltgt.errorprone'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
withSourcesJar()
withJavadocJar()
}
dependencies {
if (project.name != 'jsonrpc-core') {
implementation platform(libs.spring.boot.bom)
testImplementation platform(libs.spring.boot.bom)
annotationProcessor platform(libs.spring.boot.bom)
}
testImplementation libs.junit.jupiter
testRuntimeOnly libs.junit.platform.launcher
compileOnly libs.jspecify
errorprone libs.errorprone.core
errorprone libs.nullaway
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.compilerArgs += ['-parameters']
def isTestCompile = name.toLowerCase().contains('test')
options.errorprone.enabled = !isTestCompile
options.errorprone.disableWarningsInGeneratedCode = true
if (!isTestCompile) {
options.errorprone.disableAllChecks = true
options.errorprone.check('NullAway', CheckSeverity.ERROR)
options.errorprone.option('NullAway:AnnotatedPackages', 'com.limehee.jsonrpc')
options.errorprone.option('NullAway:JSpecifyMode', 'true')
}
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
}
def hasIntegrationTestSources = file('src/integrationTest/java').exists() || file('src/integrationTest/resources').exists()
if (hasIntegrationTestSources) {
def integrationTestSourceSet = sourceSets.create('integrationTest') {
java.srcDir file('src/integrationTest/java')
resources.srcDir file('src/integrationTest/resources')
compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath
runtimeClasspath += output + compileClasspath
}
configurations {
integrationTestImplementation.extendsFrom(testImplementation)
integrationTestRuntimeOnly.extendsFrom(testRuntimeOnly)
}
tasks.register('integrationTest', Test) {
description = 'Runs integration tests.'
group = 'verification'
testClassesDirs = integrationTestSourceSet.output.classesDirs
classpath = integrationTestSourceSet.runtimeClasspath
shouldRunAfter(tasks.named('test'))
}
tasks.named('check') {
dependsOn(tasks.named('integrationTest'))
}
}
def hasE2eTestSources = file('src/e2eTest/java').exists() || file('src/e2eTest/resources').exists()
if (hasE2eTestSources) {
def e2eTestSourceSet = sourceSets.create('e2eTest') {
java.srcDir file('src/e2eTest/java')
resources.srcDir file('src/e2eTest/resources')
compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath
runtimeClasspath += output + compileClasspath
}
configurations {
e2eTestImplementation.extendsFrom(testImplementation)
e2eTestRuntimeOnly.extendsFrom(testRuntimeOnly)
}
tasks.register('e2eTest', Test) {
description = 'Runs end-to-end tests.'
group = 'verification'
testClassesDirs = e2eTestSourceSet.output.classesDirs
classpath = e2eTestSourceSet.runtimeClasspath
if (hasIntegrationTestSources) {
shouldRunAfter(tasks.named('integrationTest'))
} else {
shouldRunAfter(tasks.named('test'))
}
}
tasks.named('check') {
dependsOn(tasks.named('e2eTest'))
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = project.name
description = 'JSON-RPC 2.0 library and Spring Boot starter'
url = 'https://github.com/limehee/jsonrpc-spring-boot-starter'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'limehee'
name = 'limehee'
}
}
scm {
url = 'https://github.com/limehee/jsonrpc-spring-boot-starter'
connection = 'scm:git:git://github.com/limehee/jsonrpc-spring-boot-starter.git'
developerConnection = 'scm:git:ssh://github.com/limehee/jsonrpc-spring-boot-starter.git'
}
}
}
}
repositories {
maven {
name = 'central'
def releasesRepoUrl = uri('https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/')
def snapshotsRepoUrl = uri('https://central.sonatype.com/repository/maven-snapshots/')
url = version.toString().endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username = findProperty('ossrhUsername') ?: System.getenv('OSSRH_USERNAME')
password = findProperty('ossrhPassword') ?: System.getenv('OSSRH_PASSWORD')
}
}
}
}
signing {
def signingKey = findProperty('signingKey') ?: System.getenv('SIGNING_KEY')
def signingPassword = findProperty('signingPassword') ?: System.getenv('SIGNING_PASSWORD')
if (signingKey && signingPassword) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
def publishRequested = gradle.startParameter.taskNames.any { taskName ->
def lower = taskName.toLowerCase()
lower.contains('publish') && !lower.contains('mavenlocal')
}
required = !version.toString().endsWith('SNAPSHOT') && publishRequested
sign publishing.publications
}
}
def publishedApiModules = [
project(':jsonrpc-core'),
project(':jsonrpc-spring-webmvc'),
project(':jsonrpc-spring-boot-autoconfigure'),
project(':jsonrpc-spring-boot-starter')
]
def apiBaselineVersionProvider = providers.gradleProperty('apiBaselineVersion')
configure(publishedApiModules) {
apply plugin: 'me.champeau.gradle.japicmp'
configurations {
apiCompatBaseline
}
if (apiBaselineVersionProvider.present) {
dependencies {
apiCompatBaseline("${project.group}:${project.name}:${apiBaselineVersionProvider.get()}") {
transitive = false
}
}
}
tasks.register('apiCompatCheck', JapicmpTask) {
group = 'verification'
description = "Checks binary API compatibility for ${project.path} against -PapiBaselineVersion"
dependsOn tasks.named('jar')
dependsOn publishedApiModules.collect { it.tasks.named('jar') }
onlyIf { apiBaselineVersionProvider.present }
oldClasspath.from(configurations.apiCompatBaseline)
newClasspath.from(tasks.named('jar').flatMap { it.archiveFile })
onlyModified = true
onlyBinaryIncompatibleModified = true
ignoreMissingClasses = true
failOnModification = true
txtOutputFile = layout.buildDirectory.file("reports/japicmp/${project.name}.txt").get().asFile
}
}
tasks.register('apiCompat') {
group = 'verification'
description = 'Runs binary API compatibility checks for all published modules (requires -PapiBaselineVersion).'
dependsOn publishedApiModules.collect { it.tasks.named('apiCompatCheck') }
doFirst {
if (!apiBaselineVersionProvider.present) {
logger.lifecycle('Skipping apiCompat: set -PapiBaselineVersion=x.y.z to enable compatibility checks.')
}
}
}