forked from openrewrite/rewrite-spring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
387 lines (333 loc) · 15.6 KB
/
build.gradle.kts
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
import com.github.jk1.license.LicenseReportExtension
import nebula.plugin.contacts.Contact
import nebula.plugin.contacts.ContactsExtension
import nl.javadude.gradle.plugins.license.LicenseExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.*
buildscript {
repositories {
gradlePluginPortal()
}
}
plugins {
`java-library`
`maven-publish`
signing
id("org.jetbrains.kotlin.jvm") version "1.6.21"
id("nebula.maven-resolved-dependencies") version "17.3.2"
id("nebula.release") version "15.3.1"
id("io.github.gradle-nexus.publish-plugin") version "1.0.0"
id("com.github.hierynomus.license") version "0.16.1"
id("com.github.jk1.dependency-license-report") version "1.16"
id("org.owasp.dependencycheck") version "latest.release"
id("nebula.maven-publish") version "17.3.2"
id("nebula.contacts") version "5.1.0"
id("nebula.info") version "11.1.0"
id("nebula.javadoc-jar") version "17.3.2"
id("nebula.source-jar") version "17.3.2"
id("nebula.maven-apache-license") version "17.3.2"
id("org.openrewrite.rewrite") version "latest.release"
}
apply(plugin = "nebula.publish-verification")
rewrite {
activeRecipe("org.openrewrite.java.format.AutoFormat", "org.openrewrite.java.cleanup.Cleanup")
}
configure<nebula.plugin.release.git.base.ReleasePluginExtension> {
defaultVersionStrategy = nebula.plugin.release.NetflixOssStrategies.SNAPSHOT(project)
}
dependencyCheck {
analyzers.nodeAuditEnabled = false
analyzers.nodeEnabled = false
analyzers.assemblyEnabled = false
failBuildOnCVSS = 9.0F
suppressionFile = "suppressions.xml"
format = org.owasp.dependencycheck.reporting.ReportGenerator.Format.valueOf(project.properties["dependencyCheckFormat"] as String? ?: "HTML")
}
group = "org.openrewrite.recipe"
description = "Eliminate legacy Spring patterns and migrate between major Spring Boot versions. Automatically."
val springBoot2Versions: List<String> = listOf("1_5", "2_1", "2_2", "2_3", "2_4", "2_5")
val springDataVersions: List<String> = listOf("2_1", "2_3")
val springFrameworkVersions: List<String> = listOf("5_1", "5_2", "5_3")
sourceSets {
springBoot2Versions.forEach { version ->
create("testWithSpringBoot_${version}") {
java {
compileClasspath += sourceSets.getByName("main").output
runtimeClasspath += sourceSets.getByName("main").output
}
}
}
springDataVersions.forEach { version ->
create("testWithSpringData_${version}") {
java {
compileClasspath += sourceSets.getByName("main").output
runtimeClasspath += sourceSets.getByName("main").output
}
}
}
springFrameworkVersions.forEach { version ->
create("testWithSpringFramework_${version}") {
java {
compileClasspath += sourceSets.getByName("main").output
runtimeClasspath += sourceSets.getByName("main").output
}
}
}
}
repositories {
if(!project.hasProperty("releasing")) {
mavenLocal()
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
}
mavenCentral()
}
nexusPublishing {
repositories {
sonatype()
}
}
val signingKey: String? by project
val signingPassword: String? by project
val requireSigning = project.hasProperty("forceSigning") || project.hasProperty("releasing")
if(signingKey != null && signingPassword != null) {
signing {
isRequired = requireSigning
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["nebula"])
}
} else if(requireSigning) {
throw RuntimeException("Artifact signing is required, but signingKey and/or signingPassword are null")
}
configurations {
springBoot2Versions.forEach { version ->
getByName("testWithSpringBoot_${version}RuntimeOnly") {
isCanBeResolved = true
extendsFrom(getByName("testImplementation"))
}
getByName("testWithSpringBoot_${version}Implementation") {
isCanBeResolved = true
extendsFrom(getByName("testImplementation"))
}
}
springDataVersions.forEach { version ->
getByName("testWithSpringData_${version}RuntimeOnly") {
isCanBeResolved = true
extendsFrom(getByName("testImplementation"))
}
getByName("testWithSpringData_${version}Implementation") {
isCanBeResolved = true
extendsFrom(getByName("testImplementation"))
}
}
springFrameworkVersions.forEach { version ->
getByName("testWithSpringFramework_${version}RuntimeOnly") {
isCanBeResolved = true
extendsFrom(getByName("testImplementation"))
}
getByName("testWithSpringFramework_${version}Implementation") {
isCanBeResolved = true
extendsFrom(getByName("testImplementation"))
}
}
all {
resolutionStrategy {
cacheChangingModulesFor(0, TimeUnit.SECONDS)
cacheDynamicVersionsFor(0, TimeUnit.SECONDS)
}
}
}
var rewriteVersion = if(project.hasProperty("releasing")) {
"latest.release"
} else {
"latest.integration"
}
dependencies {
compileOnly("org.projectlombok:lombok:latest.release")
annotationProcessor("org.projectlombok:lombok:latest.release")
implementation("org.openrewrite:rewrite-java:${rewriteVersion}")
implementation("org.openrewrite:rewrite-xml:${rewriteVersion}")
implementation("org.openrewrite:rewrite-properties:${rewriteVersion}")
implementation("org.openrewrite:rewrite-yaml:${rewriteVersion}")
implementation("org.openrewrite:rewrite-maven:${rewriteVersion}")
runtimeOnly("org.openrewrite.recipe:rewrite-testing-frameworks:${rewriteVersion}")
runtimeOnly("org.openrewrite.recipe:rewrite-migrate-java:${rewriteVersion}")
runtimeOnly("org.openrewrite:rewrite-java-17:$rewriteVersion")
testImplementation(platform(kotlin("bom", "1.6.21")))
testImplementation(kotlin("reflect"))
testImplementation(kotlin("stdlib"))
testImplementation("org.junit.jupiter:junit-jupiter-api:latest.release")
testImplementation("org.junit.jupiter:junit-jupiter-params:latest.release")
testImplementation("org.junit.jupiter:junit-jupiter-engine:latest.release")
testImplementation("org.openrewrite:rewrite-test:${rewriteVersion}")
testImplementation("org.openrewrite:rewrite-java-tck:${rewriteVersion}")
testImplementation("org.assertj:assertj-core:latest.release")
testImplementation("com.github.marschall:memoryfilesystem:latest.release")
// for generating properties migration configurations
testImplementation("com.fasterxml.jackson.core:jackson-databind:2.13.4")
testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4")
testImplementation("io.github.classgraph:classgraph:latest.release")
testImplementation("org.openrewrite:rewrite-java-17:${rewriteVersion}")
testImplementation("org.openrewrite:rewrite-maven:${rewriteVersion}")
testImplementation("org.openrewrite.recipe:rewrite-testing-frameworks:${rewriteVersion}")
"testWithSpringBoot_1_5RuntimeOnly"("org.springframework:spring-web:4.+")
"testWithSpringBoot_1_5RuntimeOnly"("org.springframework.boot:spring-boot:1.5.+")
"testWithSpringBoot_1_5RuntimeOnly"("org.springframework.boot:spring-boot-autoconfigure:1.5.+")
"testWithSpringBoot_1_5RuntimeOnly"("org.springframework.boot:spring-boot-test:1.5.+")
"testWithSpringBoot_1_5RuntimeOnly"("org.hamcrest:hamcrest:2.2")
"testWithSpringBoot_1_5RuntimeOnly"("junit:junit:latest.release")
"testWithSpringBoot_2_1RuntimeOnly"("org.springframework:spring-web:5.1.+")
"testWithSpringBoot_2_1RuntimeOnly"("org.springframework.boot:spring-boot:2.1.+")
"testWithSpringBoot_2_1RuntimeOnly"("org.springframework.boot:spring-boot-actuator:2.1.0.RELEASE")
"testWithSpringBoot_2_2RuntimeOnly"("org.springframework.boot:spring-boot:2.2.+")
"testWithSpringBoot_2_3RuntimeOnly"("org.springframework:spring-test:5.3.+")
"testWithSpringBoot_2_3RuntimeOnly"("junit:junit:latest.release")
"testWithSpringBoot_2_3RuntimeOnly"("org.hamcrest:hamcrest:2.2")
"testWithSpringBoot_2_3RuntimeOnly"("org.springframework.boot:spring-boot-test:1.5.+")
"testWithSpringBoot_2_3RuntimeOnly"("org.springframework.boot:spring-boot-autoconfigure:2.3.+")
"testWithSpringBoot_2_3RuntimeOnly"("org.springframework:spring-web:5.2.+")
"testWithSpringData_2_1RuntimeOnly"("org.springframework.data:spring-data-jpa:2.1.0.RELEASE")
"testWithSpringData_2_1RuntimeOnly"("javax.persistence:javax.persistence-api:2.2")
"testWithSpringData_2_3RuntimeOnly"("org.springframework.data:spring-data-jpa:2.3.0.RELEASE")
"testWithSpringData_2_3RuntimeOnly"("javax.persistence:javax.persistence-api:2.2")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework.boot:spring-boot:2.4.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework.boot:spring-boot-actuator:2.4.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.jooq:jooq:3.14.15")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework:spring-context:5.3.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework:spring-orm:5.3.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework:spring-web:5.3.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework:spring-webmvc:5.3.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework.security:spring-security-core:5.5.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework.security:spring-security-config:5.5.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework.security:spring-security-web:5.5.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework.security:spring-security-ldap:5.5.+")
"testWithSpringBoot_2_4RuntimeOnly"("jakarta.persistence:jakarta.persistence-api:2.2.3")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework.data:spring-data-jpa:2.4.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework.data:spring-data-jdbc:2.1.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework:spring-test:5.3.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework.boot:spring-boot-test:2.4.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework.boot:spring-boot-test-autoconfigure:2.4.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.apache.tomcat.embed:tomcat-embed-core:9.0.+")
"testWithSpringBoot_2_4RuntimeOnly"("org.springframework.batch:spring-batch-test:4.3.+")
"testWithSpringFramework_5_1RuntimeOnly"("org.springframework:spring-core:5.1.+")
"testWithSpringFramework_5_2RuntimeOnly"("org.springframework:spring-web:5.2.+")
"testWithSpringFramework_5_2RuntimeOnly"("org.springframework:spring-core:5.2.+")
"testWithSpringFramework_5_3RuntimeOnly"("org.springframework:spring-core:5.3.+")
"testWithSpringFramework_5_3RuntimeOnly"("org.springframework:spring-beans:5.3.+")
"testWithSpringFramework_5_3RuntimeOnly"("org.springframework:spring-tx:5.3.+")
"testWithSpringFramework_5_3RuntimeOnly"("org.springframework:spring-jdbc:5.3.+")
"testWithSpringFramework_5_3RuntimeOnly"("org.springframework:spring-web:5.3.+")
"testWithSpringBoot_2_5RuntimeOnly"("org.springframework.boot:spring-boot:2.5.+")
}
tasks.named<Test>("test") {
useJUnitPlatform()
jvmArgs = listOf("-XX:+UnlockDiagnosticVMOptions", "-XX:+ShowHiddenFrames")
}
springBoot2Versions.forEach { version ->
val sourceSetName = "testWithSpringBoot_${version}"
val sourceSetReference = project.sourceSets.getByName(sourceSetName)
val testTask = tasks.register<Test>(sourceSetName) {
description = "Runs the unit tests for ${sourceSetName}."
group = "verification"
useJUnitPlatform()
jvmArgs = listOf("-XX:+UnlockDiagnosticVMOptions", "-XX:+ShowHiddenFrames")
testClassesDirs = sourceSetReference.output.classesDirs
classpath = sourceSetReference.runtimeClasspath
shouldRunAfter(tasks.test)
}
tasks.test {
dependsOn(testTask)
}
}
springDataVersions.forEach { version ->
val sourceSetName = "testWithSpringData_${version}"
val sourceSetReference = project.sourceSets.getByName(sourceSetName)
val testTask = tasks.register<Test>(sourceSetName) {
description = "Runs the unit tests for ${sourceSetName}."
group = "verification"
useJUnitPlatform()
jvmArgs = listOf("-XX:+UnlockDiagnosticVMOptions", "-XX:+ShowHiddenFrames")
testClassesDirs = sourceSetReference.output.classesDirs
classpath = sourceSetReference.runtimeClasspath
shouldRunAfter(tasks.test)
}
tasks.test {
dependsOn(testTask)
}
}
springFrameworkVersions.forEach { version ->
val sourceSetName = "testWithSpringFramework_${version}"
val sourceSetReference = project.sourceSets.getByName(sourceSetName)
val testTask = tasks.register<Test>(sourceSetName) {
description = "Runs the unit tests for ${sourceSetName}."
group = "verification"
useJUnitPlatform()
jvmArgs = listOf("-XX:+UnlockDiagnosticVMOptions", "-XX:+ShowHiddenFrames")
testClassesDirs = sourceSetReference.output.classesDirs
classpath = sourceSetReference.runtimeClasspath
shouldRunAfter(tasks.test)
}
tasks.test {
dependsOn(testTask)
}
}
tasks.named<JavaCompile>("compileJava") {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
options.isFork = true
options.compilerArgs.addAll(listOf("--release", "8"))
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")
}
tasks.withType(KotlinCompile::class.java).configureEach {
kotlinOptions {
jvmTarget = "1.8"
}
doFirst {
destinationDir.mkdirs()
}
}
configure<ContactsExtension> {
val j = Contact("jkschneider@gmail.com")
j.moniker("Jonathan Schneider")
people["jkschneider@gmail.com"] = j
}
configure<LicenseExtension> {
ext.set("year", Calendar.getInstance().get(Calendar.YEAR))
skipExistingHeaders = true
header = project.rootProject.file("gradle/licenseHeader.txt")
mapping(mapOf("kt" to "SLASHSTAR_STYLE", "java" to "SLASHSTAR_STYLE"))
// exclude JavaTemplate shims from license check
exclude("src/main/resources/META-INF/rewrite/*.java")
strictCheck = true
}
configure<LicenseReportExtension> {
renderers = arrayOf(com.github.jk1.license.render.CsvReportRenderer())
}
configure<PublishingExtension> {
publications {
named("nebula", MavenPublication::class.java) {
suppressPomMetadataWarningsFor("runtimeElements")
pom.withXml {
(asElement().getElementsByTagName("dependencies").item(0) as org.w3c.dom.Element).let { dependencies ->
dependencies.getElementsByTagName("dependency").let { dependencyList ->
var i = 0
var length = dependencyList.length
while (i < length) {
(dependencyList.item(i) as org.w3c.dom.Element).let { dependency ->
if ((dependency.getElementsByTagName("scope")
.item(0) as org.w3c.dom.Element).textContent == "provided") {
dependencies.removeChild(dependency)
i--
length--
}
}
i++
}
}
}
}
}
}
}