-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
219 lines (192 loc) · 7.4 KB
/
build.gradle
File metadata and controls
219 lines (192 loc) · 7.4 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
buildscript {
ext {
springCloudAzureVersion = "5.23.0"
// set gradle properties regarding nexus
nexus_url = project.findProperty('nexus_url') ?: System.getenv('NEXUS_HOST')
nexus_user = project.findProperty('nexus_user') ?: System.getenv('NEXUS_USERNAME')
nexus_pw = project.findProperty('nexus_pw') ?: System.getenv('NEXUS_PASSWORD')
no_nexus = (project.findProperty('no_nexus') ?: System.getenv('NO_NEXUS') ?: false).toBoolean()
if (!no_nexus && (nexus_url == null || nexus_user == null || nexus_pw == null)) {
throw new GradleException("property 'no_nexus' is set to false, but neither " +
"'nexus_url', 'nexus_user' nor 'nexus_pw' is configured. You can do so " +
"by e.g. creating a gradle.properties file in your 'GRADLE_USER_HOME' " +
"(by default '~/.gradle') folder and setting the nexus properties there.")
}
nexusFolderReleases = project.findProperty('nexus_folder_releases')
?: System.getenv('NEXUS_FOLDER_RELEASES') ?: "maven-releases"
nexusFolderSnapshots = project.findProperty('nexus_folder_snapshots')
?: System.getenv('NEXUS_FOLDER_SNAPSHOTS') ?: "maven-snapshots"
}
}
plugins {
id 'jacoco'
id 'maven-publish'
id 'java'
id 'org.springframework.boot' version '3.5.9'
id 'io.spring.dependency-management' version '1.1.7'
id "com.gorylenko.gradle-git-properties" version "2.5.3" // Adds git info on /actuator/info endpoint
id "org.openapi.generator" version "7.10.0"
}
group = 'opendevstack'
version = '0.0.1-SNAPSHOT'
description = 'OpenDevStack Project to retrieve projects and azure groups for an authenticated user'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
if (!no_nexus) {
def nexusMaven = { repoUrl ->
println("Setting up Nexus (${repoUrl}) as repo")
maven {
credentials {
username = "${nexus_user}"
password = "${nexus_pw}"
}
url repoUrl
}
}
nexusMaven("${nexus_url}/repository/maven-public/")
nexusMaven("${nexus_url}/repository/atlassian_public/")
} else {
println("Setting up mavenCentral as repo")
mavenCentral()
}
}
dependencyManagement {
imports {
mavenBom "com.azure.spring:spring-cloud-azure-dependencies:$springCloudAzureVersion"
}
}
dependencies {
// Release dependencies
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-cache'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-aop'
implementation 'com.microsoft.azure:msal4j:1.17.2'
implementation('com.azure.spring:spring-cloud-azure-starter-actuator') {
exclude group: 'org.springframework.boot', module: 'spring-boot-autoconfigure'
}
implementation 'com.azure.spring:spring-cloud-azure-starter-active-directory'
implementation 'com.microsoft.graph:microsoft-graph:6.51.0'
implementation 'com.github.ben-manes.caffeine:caffeine:3.2.2'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.11'
implementation 'org.openapitools:jackson-databind-nullable:0.2.7'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
// Development dependencies
implementation 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
// Testing dependencies
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'me.paulschwarz:spring-dotenv:4.0.0' // Required to override environment variables from .env file in spring context tests
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.named('test') {
useJUnitPlatform()
finalizedBy jacocoTestReport
}
// Git properties to show on /actuator/info endpoint
gitProperties {
keys = [
'git.branch',
'git.closest.tag.name',
'git.build.version',
'git.commit.message.full',
'git.commit.time',
'git.commit.id.abbrev',
]
}
bootJar {
archiveFileName = "app.jar"
destinationDirectory = file("$buildDir/../docker")
// TODO Verify if this is the right approach - Download dependencies for SonarQube analysis
doLast {
configurations.runtimeClasspath.resolvedConfiguration.resolvedArtifacts.each { artifact ->
copy {
from artifact.file
into 'build/dependencies'
}
}
}
}
jacocoTestReport {
reports {
xml.required = true
}
}
openApiGenerate {
generatorName = "spring"
outputDir = "$projectDir/target/generated-sources/openapi-server-projects-info-service"
inputSpec = "$projectDir/openapi/openapi-projects-info-service-v1.0.0.yaml"
library = "spring-boot"
globalProperties = [
generateAliasAsModel: "true",
apiDocs : "true",
modelDocs : "true",
apiTests : "true",
modelTests : "true"
]
additionalProperties = [
useTags : "true",
interfaceOnly : "true",
groupId : "projects-info-service",
artifactId : "projects-info-service-v0-server",
artifactVersion : "0.0.0-SNAPSHOT",
apiPackage : "org.opendevstack.projects_info_service.server.api",
modelPackage : "org.opendevstack.projects_info_service.server.dto",
configPackage : "org.opendevstack.projects_info_service.config",
documentationProvider: "springdoc",
generateBuilders : "true",
useSpringBoot3 : "true",
useSpringController : "true",
useSwaggerUI : "true",
hideGenerationTimestamp: "true"
]
}
// Ensure code generation runs before Java compilation
tasks.named("compileJava") {
dependsOn(tasks.named("openApiGenerate"))
}
tasks.named("clean").configure {
doLast {
delete("$projectDir/target")
}
}
sourceSets {
main {
java {
srcDirs = [
"src/main/java",
"$projectDir/target/generated-sources/openapi-server-projects-info-service/src/main/java"
]
}
resources {
srcDirs = ["src/main/resources"]
}
}
}
publishing {
repositories {
maven {
url = "${nexus_url}/repository/" + (version.endsWith('SNAPSHOT') ? nexusFolderSnapshots : nexusFolderReleases)
credentials {
username = "${nexus_user}"
password = "${nexus_pw}"
}
}
}
publications {
create("mavenJava", MavenPublication) {
artifactId = rootProject.name
groupId = project.group
version = project.version
from components.java
}
}
}