forked from eclipse-tractusx/managed-identity-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
272 lines (240 loc) · 11 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
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
plugins {
id 'java'
id 'org.springframework.boot' version "${springBootVersion}"
id 'io.spring.dependency-management' version "${springDependencyVersion}"
id "jacoco"
id 'project-report'
// used to download the 'dash.jar' for license checks
// docs: https://github.com/michel-kraemer/gradle-download-task
id "de.undercouch.download" version "5.5.0"
}
group = "${groupName}"
version = "${applicationVersion}"
sourceCompatibility = JavaVersion.VERSION_17
// alias for Project.getConfigurations()
configurations {
// add a custom config to avoid applying the dev-tools to a production app
developmentOnly
runtimeClasspath.extendsFrom(developmentOnly)
// adding a configuration 'compileOnly' which extends from annotationProcessor
compileOnly.extendsFrom(annotaionProcessor)
}
// this needs to be done, as we're using the org.springframework.boot plugin
// with native Gradle bom resolution
// docs: https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#managing-dependencies.gradle-bom-support.customizing
// docs: https://docs.gradle.org/7.6/dsl/org.gradle.api.artifacts.ResolutionStrategy.html
configurations.configureEach {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'ch.qos.logback') {
details.useVersion '1.4.12'
}
// avoid a license issue
if (details.requested.name == 'spring-boot-devtools') {
details.useVersion '3.1.5'
}
}
}
repositories {
// delegate is RepositoryHandler
// docs: https://docs.gradle.org/7.6/dsl/org.gradle.api.artifacts.dsl.RepositoryHandler.html
mavenLocal()
mavenCentral()
maven {
url = uri("https://repo.danubetech.com/repository/maven-public")
}
maven { url 'https://jitpack.io' }
maven {
// Used to resolve Dash License Tool
// Dash has a maven plugin, BUT is not resolvable through mavenCentral()
url = uri("https://repo.eclipse.org/content/repositories/dash-licenses/")
}
}
ext {
}
// comes from gradle directly
dependencies {
// 'implementation', 'testImplementation', 'runtimeOnly', 'compileOnly', 'annotationProcessor' and
// 'testAnnotationProcessor' configuration come from the java-plugin
// docs: https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_plugin_and_dependency_management
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.security:spring-security-oauth2-resource-server'
implementation 'org.springframework.security:spring-security-oauth2-jose'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation "org.springdoc:springdoc-openapi-starter-common:${openApiVersion}"
implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:${openApiVersion}"
implementation group: 'com.smartsensesolutions', name: 'commons-dao', version: '0.0.5'
implementation 'org.liquibase:liquibase-core'
implementation 'org.eclipse.tractusx.ssi:cx-ssi-lib:0.0.18'
//Added explicitly to mitigate CVE 2022-1471
implementation group: 'org.yaml', name: 'snakeyaml', version: '2.0'
//Added explicitly to mitigate CVE 2023-24998
implementation group: 'commons-fileupload', name: 'commons-fileupload', version: '1.5'
runtimeOnly 'org.postgresql:postgresql'
compileOnly 'org.projectlombok:lombok'
// custom 'developmentOnly' config
// https://docs.spring.io/spring-boot/docs/2.0.6.RELEASE/reference/html/using-boot-devtools.html#using-boot-devtools
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.projectlombok:lombok:1.18.28'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation "org.testcontainers:testcontainers"
testImplementation 'com.h2database:h2:2.2.220'
testImplementation "org.testcontainers:junit-jupiter"
testImplementation group: 'com.github.dasniko', name: 'testcontainers-keycloak', version: '2.5.0'
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '5.2.0'
testImplementation group: 'org.json', name: 'json', version: '20230227'
testImplementation group: 'com.github.curious-odd-man', name: 'rgxgen', version: '1.4'
}
// uses the 'download' plugin
// docs: https://plugins.gradle.org/plugin/de.undercouch.download
tasks.register('dashDownload', Download) {
description = 'Download the Dash License Tool standalone jar'
group = 'License'
src 'https://repo.eclipse.org/service/local/artifact/maven/redirect?r=dash-licenses&g=org.eclipse.dash&a=org.eclipse.dash.licenses&v=LATEST'
dest layout.projectDirectory.file('dash.jar')
// will not replace an existing file. If you know you need a new version
// then manually delete the file yourself, or run `dashClean`
overwrite false
}
// This task is primarily used by CIs
tasks.register('dashClean') {
description = "Clean all files used by the 'License' group"
group = 'License'
logger.lifecycle("Removing 'dash.jar'")
file('dash.jar').delete()
logger.lifecycle("Removing 'deps.txt'")
file('deps.txt').delete()
}
// Usage: in the root of the project: `./gradlew -q dashDependencies`
// The `-q` option is important if you want to use the output in a pipe.
tasks.register('dashDependencies') { dashDependencies ->
description = "Output all project dependencies as a flat list and save an intermediate file 'deps.txt'."
group = 'License'
dashDependencies.dependsOn('dashDownload')
doLast {
def deps = []
project.configurations.each { conf ->
// resolving 'archives' or 'default' is deprecated
if (conf.canBeResolved && conf.getName() != 'archives' && conf.getName() != 'default') {
deps.addAll(conf.incoming.resolutionResult.allDependencies
// the 'allDependencies' method return a 'DependencyResult'
// we're only interested in the 'ResolvedDependencyResult' sub-interface
// docs: https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/result/ResolutionResult.html#allDependencies-groovy.lang.Closure-
// docs: https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/result/DependencyResult.html
// docs: https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/result/ResolvedDependencyResult.html
.findAll({ it instanceof ResolvedDependencyResult })
.collect { ResolvedDependencyResult dep ->
"${dep.selected}"
})
}
}
def uniqueSorted = deps.unique().sort()
uniqueSorted.each { logger.quiet("{}", it) }
file("deps.txt").write(uniqueSorted.join('\n'))
}
}
tasks.register('dashLicenseCheck', JavaExec) { dashLicenseCheck ->
description = "Run the Dash License Tool and save the summary in the 'DEPENDENCIES' file"
group = 'License'
dashLicenseCheck.dependsOn('dashDownload')
dashLicenseCheck.dependsOn('dashDependencies')
doFirst {
classpath = files('dash.jar')
// docs: https://eclipse-tractusx.github.io/docs/release/trg-7/trg-7-04
args('-project', 'automotive.tractusx', '-summary', 'DEPENDENCIES', 'deps.txt')
}
doLast {
logger.lifecycle("Removing 'deps.txt' now.")
file('deps.txt').delete()
}
}
// 'dependencyManagement' comes from the 'io.spring.dependency-management' plugin
// docs: https://docs.spring.io/dependency-management-plugin/docs/current/reference/html/
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
mavenBom "org.testcontainers:testcontainers-bom:${testContainerVersion}"
}
}
// 'build' task comes from the 'java' plugin
// docs: https://docs.gradle.org/current/userguide/java_plugin.html
build {
archivesBaseName = "miw"
version = "latest"
}
// 'bootJar' comes from the 'org.springframework.boot' plugin
// 'bootJar' is a subclass of the 'jar' task type
// docs: https://docs.gradle.org/current/dsl/org.gradle.jvm.tasks.Jar.html#org.gradle.jvm.tasks.Jar
bootJar {
metaInf {
from 'DEPENDENCIES'
from 'SECURITY.md'
from 'NOTICE.md'
from 'LICENSE'
}
}
// 'test' comes from the 'java' plugin
// docs: https://docs.gradle.org/current/userguide/java_plugin.html
test {
useJUnitPlatform()
finalizedBy jacocoTestReport
}
// standard gradle class
// docs: https://docs.gradle.org/current/dsl/org.gradle.api.reporting.dependencies.HtmlDependencyReportTask.html
htmlDependencyReport {
projects = project.allprojects
}
// 'jacocoTestReport' is provided by the 'jacoco' plugin
// docs: https://docs.gradle.org/current/userguide/jacoco_plugin.html
jacocoTestReport {
reports {
xml.enabled true
xml.outputLocation = file("./build/reports/xml/jacoco.xml")
csv.enabled false
html.enabled true
html.outputLocation = file("./build/reports/html/jacoco")
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"org/eclipse/tractusx/managedidentitywallets/dto/*",
"org/eclipse/tractusx/managedidentitywallets/dao/entity/*",
"org/eclipse/tractusx/managedidentitywallets/constant/*",
"org/eclipse/tractusx/managedidentitywallets/exception/*"
])
}))
}
}
// 'jacoco' is provided by the 'jacoco' plugin
// docs: https://docs.gradle.org/current/userguide/jacoco_plugin.html#sec:configuring_the_jacoco_plugin
jacoco {
toolVersion = "${jacocoVersion}"
}
// 'jacocoTestCoverageVerification' is provided by the 'jacoco' plugin
// docs: https://docs.gradle.org/current/userguide/jacoco_plugin.html#sec:jacoco_report_violation_rules
jacocoTestCoverageVerification {
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"org/eclipse/tractusx/managedidentitywallets/dto/*",
"org/eclipse/tractusx/managedidentitywallets/dao/entity/*",
"org/eclipse/tractusx/managedidentitywallets/constant/*",
"org/eclipse/tractusx/managedidentitywallets/exception/*"
])
}))
}
violationRules {
rule {
limit {
// disabled for now
minimum = 0.00
}
}
}
}
check.dependsOn jacocoTestCoverageVerification