-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathbuild.gradle
129 lines (102 loc) · 4.39 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
plugins {
id 'com.github.ben-manes.versions' version '0.44.0'
id 'com.palantir.docker' version '0.34.0' apply false
id 'com.palantir.docker-run' version '0.34.0' apply false
id 'com.intershop.gradle.jaxb' version '5.2.1' apply false
id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
}
allprojects {
// Define repositorie to get dependencies
repositories {
mavenCentral()
// Public Spring artifacts snapshots
maven { url 'https://repo.spring.io/snapshot' }
maven { url 'https://repo.spring.io/milestone' }
// Snapshots for AspectJ
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
configurations {
all {
exclude group: 'commons-logging', module: 'commons-logging'
// We want only to use JUnit Jupiter, so exclude JUnit4 artifacts
exclude group: 'junit', module: 'junit'
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
resolutionStrategy.cacheChangingModulesFor 0, "minutes"
}
dependencyManagement {
canBeConsumed = false
canBeResolved = false
visible = false
}
matching {
it.name.endsWith('Classpath') || it.name.contains('providedCompile')
}.all { it.extendsFrom(dependencyManagement) }
}
}
subprojects { subproject ->
if (subproject.name != 'spring-6-recipes-dependencies') {
apply plugin: 'java'
defaultTasks 'build'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(19)
}
}
tasks {
withType(JavaCompile).configureEach {
options.compilerArgs.add('-Xlint:all')
options.compilerArgs.add('-Xlint:-processing')
options.compilerArgs.add('--enable-preview')
options.compilerArgs.add('-parameters')
}
withType(Test).configureEach {
useJUnitPlatform()
jvmArgs.add('--enable-preview')
systemProperty("java.awt.headless", "true")
}
withType(JavaExec).configureEach {
jvmArgs.add('--enable-preview')
systemProperty("java.awt.headless", "true")
}
withType(Jar).configureEach {
duplicatesStrategy = DuplicatesStrategy.WARN
}
}
dependencies {
if (subproject.name.contains('recipe')) {
dependencyManagement(enforcedPlatform(dependencies.project(path: ':spring-6-recipes-dependencies')))
implementation project(':shared-resources')
// Logging, route everything through SLF4J
implementation group: 'org.slf4j', name: 'slf4j-api'
runtimeOnly group: 'org.slf4j', name: 'slf4j-simple'
runtimeOnly group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j'
// To suppress compiler warnings.
implementation group: 'jakarta.annotation', name: 'jakarta.annotation-api'
compileOnly group: 'jakarta.inject', name: 'jakarta.inject-api'
compileOnly group: 'jakarta.validation', name: 'jakarta.validation-api'
// Add dependencies for testing (these will only be used for the testing phase)
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter'
testImplementation group: 'org.mockito', name: 'mockito-core'
testImplementation group: 'org.mockito', name: 'mockito-junit-jupiter'
testImplementation group: 'org.springframework', name: 'spring-test'
}
}
tasks.register('uberJar', Jar) {
archiveClassifier = 'all'
from sourceSets.main.output
dependsOn configurations.runtimeClasspath
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from {
configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) }
}
}
}
}
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
dependencyUpdates.rejectVersionIf {
isNonStable(it.candidate.version)
}