-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle
More file actions
327 lines (276 loc) · 10.5 KB
/
build.gradle
File metadata and controls
327 lines (276 loc) · 10.5 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
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
plugins {
id 'com.github.ben-manes.versions' version '0.53.0' apply false // ./gradlew dependencyUpdates
id "org.sonarqube" version "7.2.3.7755"
id 'org.jreleaser' version '1.23.0' apply false
}
// Define version variables at root level so they're available everywhere
ext {
springBootVersion = '4.0.4' // https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/
// The following versions are managed by Spring Boot BOM (no need to define here):
// junitJupiterVersion, mockitoVersion, slf4jVersion, logbackVersion,
// jacksonVersion, jacksonDatabindVersion, micrometerVersion, janinoVersion,
// servletVersion (jakarta-servlet), annotationApiVersion (jakarta-annotation),
// nettyVersion, jsonPathVersion
// Versions NOT in Spring Boot BOM - we manage these ourselves:
googleTruthVersion = '1.4.5'
logbackLogstashVersion = '9.0'
logbookVersion = '4.0.3'
jacksonSyntaxHighlightVersion = '2.0.0'
logbackLogstashSyntaxHighlightingDecoratorsVersion = '2.0.0'
commonsIoVersion = '2.21.0'
commonsTextVersion = '1.15.0'
nettyTcnativeBoringsslStaticVersion = '2.0.75.Final'
grpcNettyVersion = '1.80.0'
grpcVersion = '1.80.0'
grpcCommonsVersion = '2.67.0'
grpcProtobufVersion = '4.34.0'
springGrpcVersion = '1.0.2'
jsonAssertVersion = '0.8.0'
}
// Split projects into buildable: examples and libraries.
// This omits 'wrapper' directories. See also settings.gradle
def buildProjects() {
subprojects.findAll { new File(it.projectDir, 'build.gradle').file }
}
def platformProjects() {
buildProjects().findAll { it.name.equals("bom") }
}
def exampleProjects() {
buildProjects().findAll { it.name.endsWith("-example") }
}
def libraryProjects() {
buildProjects().findAll { !exampleProjects().contains(it) && !platformProjects().contains(it) }
}
def jvmProjects() {
buildProjects().findAll { !platformProjects().contains(it) }
}
configure(exampleProjects()) {
apply plugin: 'java'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25) // Specify desired Java version (e.g., Java 17)
}
}
dependencies {
// Use Spring Boot BOM for dependency management
implementation platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
}
}
configure(libraryProjects()) {
apply plugin: 'java-library'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17) // Specify desired Java version (e.g., Java 17)
}
}
dependencies {
// Use api(platform(...)) to enforce Spring Boot BOM versions for all dependency configurations
// This ensures both api and implementation dependencies get pinned versions
api(platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}"))
}
}
configure(jvmProjects()) {
apply plugin: 'com.github.ben-manes.versions'
test {
useJUnitPlatform {
includeEngines 'junit-jupiter'
}
}
dependencies {
components.all(LogbackAlignmentRule)
components.all(GrpcAlignmentRule)
components.all(ProtobufAlignmentRule)
components.all(JunitAlignmentRule)
// JUnit Jupiter API and TestEngine implementation - versions managed by BOM
testImplementation("org.junit.jupiter:junit-jupiter")
// https://stackoverflow.com/questions/79640685/cannot-build-project-after-upgrading-spring-boot-to-3-5
testRuntimeOnly "org.junit.platform:junit-platform-launcher"
testImplementation("org.mockito:mockito-core")
testImplementation("com.google.truth:truth:${googleTruthVersion}")
testImplementation("com.google.truth.extensions:truth-java8-extension:${googleTruthVersion}")
}
// from https://github.com/ben-manes/gradle-versions-plugin?tab=readme-ov-file#rejectversionsif-and-componentselection
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { ita -> version.toUpperCase().contains(ita) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
isNonStable(it.candidate.version)
}
}
}
ext.stagingRepositoryPath = "${rootDir.getCanonicalFile()}/build/staging-deploy"
System.out.println("Staging repository is " + ext.stagingRepositoryPath)
// projects which should be published
configure(libraryProjects()) {
apply plugin: 'maven-publish'
java {
withSourcesJar()
withJavadocJar()
}
publishing {
publications {
maven(MavenPublication) {
from components.java
groupId = "$group"
artifactId = project.name
if(project.ext.has('artifactId')) {
System.out.println("Publishing " + project.name + " with artifact-id " + project.ext.artifactId)
}
pom {
name = "${!project.ext.has('artifactId') ? project.name : project.ext.artifactId}"
url = 'https://github.com/entur/cloud-logging'
packaging = 'jar'
inceptionYear = '2023'
description = project.name
licenses {
license {
name = 'European Union Public Licence v1.2'
url = 'https://www.eupl.eu/'
distribution = 'repo'
}
}
developers {
developer {
id = "skjolber"
name = "Thomas Skjølberg"
email = "thomas.rorvik.skjolberg@entur.org"
}
}
scm {
url = 'https://github.com/entur/cloud-logging'
connection = 'git@github.com:entur/cloud-logging.git'
}
// Resolve and add versions from platform to all dependencies
withXml {
// Remove the dependencyManagement section since we're adding explicit versions
def dependencyManagement = asNode().dependencyManagement
if (dependencyManagement) {
asNode().remove(dependencyManagement[0])
}
// Add explicit versions to all dependencies
def dependenciesNode = asNode().dependencies[0]
if (dependenciesNode) {
dependenciesNode.dependency.each { dep ->
if (!dep.version) {
def group = dep.groupId.text()
def artifact = dep.artifactId.text()
def resolvedVersion = project.configurations.runtimeClasspath.resolvedConfiguration
.resolvedArtifacts.find { it.moduleVersion.id.group == group && it.moduleVersion.id.name == artifact }
?.moduleVersion?.id?.version
if (resolvedVersion) {
dep.appendNode('version', resolvedVersion)
}
}
}
}
}
}
}
}
repositories {
maven {
url = stagingRepositoryPath
}
}
}
}
allprojects {
apply plugin: 'eclipse'
apply plugin: 'idea'
eclipse {
classpath {
downloadSources = true
downloadJavadoc = true
}
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
repositories {
mavenLocal()
mavenCentral()
}
}
abstract class LogbackAlignmentRule implements ComponentMetadataRule {
void execute(ComponentMetadataContext ctx) {
ctx.details.with {
if (id.group.startsWith("ch.qos.logback")) {
belongsTo("ch.qos.logback:logback-virtual-platform:${id.version}")
}
}
}
}
abstract class GrpcAlignmentRule implements ComponentMetadataRule {
void execute(ComponentMetadataContext ctx) {
ctx.details.with {
if (id.group.startsWith("io.grpc")) {
belongsTo("io.grpc:grpc-virtual-platform:${id.version}")
}
}
}
}
abstract class ProtobufAlignmentRule implements ComponentMetadataRule {
void execute(ComponentMetadataContext ctx) {
ctx.details.with {
if (id.group.startsWith("com.google.protobuf")) {
belongsTo("com.google.protobuf:protobuf-virtual-platform:${id.version}")
}
}
}
}
abstract class JunitAlignmentRule implements ComponentMetadataRule {
void execute(ComponentMetadataContext ctx) {
ctx.details.with {
if (id.group.startsWith("org.junit.jupiter ")) {
belongsTo("org.junit.jupiter:junit-virtual-platform:${id.version}")
}
}
}
}
task clean {
//project.delete(files(getBuildDir()) {
//})
}
apply plugin: 'org.jreleaser'
jreleaser {
signing {
active = 'ALWAYS'
armored = true
}
deploy {
maven {
mavenCentral {
release {
active = 'RELEASE'
url = 'https://central.sonatype.com/api/v1/publisher'
stagingRepository(stagingRepositoryPath)
}
}
nexus2 {
snapshot {
active = 'SNAPSHOT'
applyMavenCentralRules = true
snapshotSupported = true
closeRepository = true
releaseRepository = true
url = "https://ossrh-staging-api.central.sonatype.com/service/local"
snapshotUrl = 'https://central.sonatype.com/repository/maven-snapshots/'
stagingRepository(stagingRepositoryPath)
}
}
}
}
release {
github {
skipTag = false // Skip creating a new github tag?
skipRelease = true // Skip creating a new github release?
tagName = "v${version}"
}
}
}