forked from eclipse-edc/Connector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
295 lines (262 loc) · 10.2 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
/*
* Copyright (c) 2022 Microsoft Corporation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Microsoft Corporation - initial API and implementation
*
*/
plugins {
`java-library`
`maven-publish`
checkstyle
jacoco
id("com.rameshkp.openapi-merger-gradle-plugin") version "1.0.4"
id ("org.eclipse.dataspaceconnector.dependency-rules") apply(false)
id("com.autonomousapps.dependency-analysis") version "1.0.0-rc05" apply (false)
}
repositories {
mavenCentral()
}
val jetBrainsAnnotationsVersion: String by project
val jacksonVersion: String by project
val javaVersion: String by project
val jupiterVersion: String by project
val mockitoVersion: String by project
val assertj: String by project
val rsApi: String by project
val swagger: String by project
val faker: String by project
val groupId: String = "org.eclipse.dataspaceconnector"
var edcVersion: String = "0.0.1-SNAPSHOT"
if (project.version == "unspecified") {
logger.warn("No version was specified, setting default 0.0.1-SNAPSHOT")
logger.warn("If you want to change this, supply the -Pversion=X.Y.Z parameter")
logger.warn("")
} else {
edcVersion = project.version as String
}
subprojects {
repositories {
mavenCentral()
maven {
url = uri("https://maven.iais.fraunhofer.de/artifactory/eis-ids-public/")
}
}
tasks.register<DependencyReportTask>("allDependencies") {}
}
buildscript {
dependencies {
classpath("io.swagger.core.v3:swagger-gradle-plugin:2.1.13")
}
}
allprojects {
apply(plugin = "maven-publish")
apply(plugin = "checkstyle")
apply(plugin = "java")
if (System.getenv("JACOCO") == "true") {
apply(plugin = "jacoco")
}
checkstyle {
toolVersion = "9.0"
configFile = rootProject.file("resources/edc-checkstyle-config.xml")
maxErrors = 0 // does not tolerate errors ...
maxWarnings = 0 // ... or warnings
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(javaVersion))
}
tasks.withType(JavaCompile::class.java) {
// making sure the code does not use any APIs from a more recent version.
// Ref: https://docs.gradle.org/current/userguide/building_java_projects.html#sec:java_cross_compilation
options.release.set(javaVersion.toInt())
}
}
// EdcRuntimeExtension uses this to determine the runtime classpath of the module to run.
tasks.register("printClasspath") {
doLast {
println(sourceSets["main"].runtimeClasspath.asPath)
}
}
pluginManager.withPlugin("java-library") {
group = groupId
version = edcVersion
dependencies {
api("org.jetbrains:annotations:${jetBrainsAnnotationsVersion}")
api("com.fasterxml.jackson.core:jackson-core:${jacksonVersion}")
api("com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}")
api("com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}")
api("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jacksonVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-api:${jupiterVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-params:${jupiterVersion}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${jupiterVersion}")
testImplementation("org.mockito:mockito-core:${mockitoVersion}")
testImplementation("org.assertj:assertj-core:${assertj}")
testImplementation("com.github.javafaker:javafaker:${faker}")
}
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/eclipse-dataspaceconnector/DataSpaceConnector")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
}
pluginManager.withPlugin("io.swagger.core.v3.swagger-gradle-plugin") {
dependencies {
// this is used to scan the classpath and generate an openapi yaml file
implementation("io.swagger.core.v3:swagger-jaxrs2-jakarta:${swagger}")
implementation("jakarta.ws.rs:jakarta.ws.rs-api:${rsApi}")
}
// this is used to scan the classpath and generate an openapi yaml file
tasks.withType<io.swagger.v3.plugins.gradle.tasks.ResolveTask> {
outputFileName = project.name
outputFormat = io.swagger.v3.plugins.gradle.tasks.ResolveTask.Format.YAML
prettyPrint = true
classpath = java.sourceSets["main"].runtimeClasspath
buildClasspath = classpath
resourcePackages = setOf("org.eclipse.dataspaceconnector")
outputDir = file("${rootProject.projectDir.path}/resources/openapi/yaml")
}
configurations {
all {
exclude(group = "com.fasterxml.jackson.jaxrs", module = "jackson-jaxrs-json-provider")
}
}
}
tasks.withType<Test> {
// Target all type of test e.g. -DrunAllTests="true"
val runAllTests: String = System.getProperty("runAllTests", "false");
if (runAllTests == "true") {
useJUnitPlatform()
} else {
// Target specific set of tests by specifying junit tags on command-line e.g. -DincludeTags="tag-name1,tag-name2"
val includeTagProperty = System.getProperty("includeTags");
val includeTags: Array<String> = includeTagProperty?.split(",")?.toTypedArray() ?: emptyArray();
if (includeTags.isNotEmpty()) {
useJUnitPlatform {
includeTags(*includeTags)
}
} else {
useJUnitPlatform {
excludeTags("IntegrationTest")
}
}
}
testLogging {
if (project.hasProperty("verboseTest")) {
events("started", "passed", "skipped", "failed", "standard_out", "standard_error")
} else {
events("failed")
}
showStackTraces = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
tasks.withType<Checkstyle> {
reports {
// lets not generate any reports because that is done from within the Github Actions workflow
html.required.set(false)
xml.required.set(false)
}
}
tasks.jar {
metaInf {
from("${rootProject.projectDir.path}/LICENSE")
from("${rootProject.projectDir.path}/NOTICE.md")
}
}
// Generate XML reports for Codecov
if (System.getenv("JACOCO") == "true") {
tasks.jacocoTestReport {
reports {
xml.required.set(true)
}
}
}
}
openApiMerger {
val yamlDirectory = file("${rootProject.projectDir.path}/resources/openapi/yaml")
inputDirectory.set(yamlDirectory)
output {
directory.set(file("${rootProject.projectDir.path}/resources/openapi/"))
fileName.set("openapi")
fileExtension.set("yaml")
}
openApi {
openApiVersion.set("3.0.1")
info {
title.set("EDC REST API")
description.set("All files merged by open api merger")
version.set("1.0.0-SNAPSHOT")
license {
name.set("Apache License v2.0")
url.set("http://apache.org/v2")
}
}
}
}
// Dependency analysis active if property "dependency.analysis" is set. Possible values are <'fail'|'warn'|'ignore'>.
if (project.hasProperty("dependency.analysis")) {
apply(plugin = "org.eclipse.dataspaceconnector.dependency-rules")
configure<org.eclipse.dataspaceconnector.gradle.DependencyRulesPluginExtension> {
severity.set(project.property("dependency.analysis").toString())
}
apply(plugin = "com.autonomousapps.dependency-analysis")
configure<com.autonomousapps.DependencyAnalysisExtension> {
// See https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin
issues {
all { // all projects
onAny {
severity(project.property("dependency.analysis").toString())
exclude(
// dependencies declared at the root level for all modules
"org.jetbrains:annotations",
"com.fasterxml.jackson.datatype:jackson-datatype-jsr310",
"com.fasterxml.jackson.core:jackson-core",
"com.fasterxml.jackson.core:jackson-annotations",
"com.fasterxml.jackson.core:jackson-databind",
)
}
onUnusedDependencies {
exclude(
// dependencies declared at the root level for all modules
"com.github.javafaker:javafaker",
"org.assertj:assertj-core",
"org.junit.jupiter:junit-jupiter-api",
"org.junit.jupiter:junit-jupiter-params",
"org.mockito:mockito-core",
)
}
onIncorrectConfiguration {
exclude(
// some common dependencies are intentionally exported by core:base for simplicity
"com.squareup.okhttp3:okhttp",
"net.jodah:failsafe",
)
}
onUsedTransitiveDependencies {
severity("ignore")
}
}
}
abi {
exclusions {
excludeAnnotations(
"io\\.opentelemetry\\.extension\\.annotations\\.WithSpan",
)
}
}
}
}