forked from eclipse-edc/Connector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
413 lines (370 loc) · 14.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
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
/*
* 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
*
*/
import org.hidetake.gradle.swagger.generator.GenerateSwaggerUI
plugins {
`java-library`
`maven-publish`
checkstyle
jacoco
signing
id("com.rameshkp.openapi-merger-gradle-plugin") version "1.0.4"
id("org.eclipse.dataspaceconnector.module-names")
id("com.autonomousapps.dependency-analysis") version "1.13.1" apply (false)
id("org.gradle.crypto.checksum") version "1.4.0"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("org.hidetake.swagger.generator") version "2.19.2"
}
repositories {
mavenCentral()
}
dependencies {
"swaggerCodegen"("org.openapitools:openapi-generator-cli:6.2.0")
"swaggerUI"("org.webjars:swagger-ui:4.14.0")
}
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 edcDeveloperId: String by project
val edcDeveloperName: String by project
val edcDeveloperEmail: String by project
val edcScmConnection: String by project
val edcWebsiteUrl: String by project
val edcScmUrl: String by project
val groupId: String by project
val defaultVersion: String by project
val metaModelVersion: String by project
val annotationProcessorVersion: String by project
// where our SNAPSHOT versions are published to and resolved from
val snapshotUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
// where our release versions are published to (staging)
val releaseUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
// required by the nexus publishing plugin
val projectVersion: String = (project.findProperty("edcVersion") ?: defaultVersion) as String
var deployUrl = releaseUrl
if (projectVersion.contains("SNAPSHOT")) {
deployUrl = snapshotUrl
}
subprojects {
repositories {
maven {
url = uri(snapshotUrl)
}
mavenCentral()
maven {
url = uri("https://maven.iais.fraunhofer.de/artifactory/eis-ids-public/")
}
mavenLocal()
}
tasks.register<DependencyReportTask>("allDependencies") {}
// (re-)create a file that contains all maven publications
val f = File("${project.rootDir.absolutePath}/docs/developer/modules.md")
if (f.exists()) {
f.delete()
}
afterEvaluate {
publishing {
publications.forEach { i ->
val mp = (i as MavenPublication)
mp.pom {
name.set(project.name)
description.set("edc :: ${project.name}")
url.set(edcWebsiteUrl)
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
developers {
developer {
id.set(edcDeveloperId)
name.set(edcDeveloperName)
email.set(edcDeveloperEmail)
}
}
scm {
connection.set(edcScmConnection)
url.set(edcScmUrl)
}
}
}
f.appendText("\n${mp.groupId}:${mp.artifactId}:${mp.version}")
}
}
}
}
buildscript {
repositories {
maven {
// can't use the snapshotUrl variable here, because buildscript has a different scope
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
mavenLocal()
}
dependencies {
val swagger: String by project
val autodocPluginVersion: String by project
classpath("io.swagger.core.v3:swagger-gradle-plugin:${swagger}")
classpath("org.eclipse.dataspaceconnector.autodoc:org.eclipse.dataspaceconnector.autodoc.gradle.plugin:${autodocPluginVersion}")
}
}
allprojects {
repositories {
maven {
url = uri(snapshotUrl)
}
}
apply(plugin = "maven-publish")
apply(plugin = "checkstyle")
apply(plugin = "java")
apply(plugin = "${groupId}.autodoc")
// configure which version of the annotation processor to use. defaults to the same version as the plugin
configure<org.eclipse.dataspaceconnector.plugins.autodoc.AutodocExtension> {
processorVersion.set(annotationProcessorVersion)
outputDirectory.set(project.buildDir)
}
apply(plugin = "org.eclipse.dataspaceconnector.test-summary")
if (System.getenv("JACOCO") == "true") {
apply(plugin = "jacoco")
}
checkstyle {
toolVersion = "9.0"
configFile = rootProject.file("resources/edc-checkstyle-config.xml")
configDirectory.set(rootProject.file("resources"))
maxErrors = 0 // does not tolerate errors
}
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())
}
withJavadocJar()
withSourcesJar()
}
// 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 = projectVersion
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}")
api("${groupId}:runtime-metamodel:${metaModelVersion}")
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}")
}
if (!project.hasProperty("skip.signing")) {
apply(plugin = "signing")
publishing {
repositories {
maven {
name = "OSSRH"
setUrl(deployUrl)
credentials {
username = System.getenv("OSSRH_USER") ?: return@credentials
password = System.getenv("OSSRH_PASSWORD") ?: return@credentials
}
}
}
signing {
useGpgCmd()
sign(publishing.publications)
}
}
}
}
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
sortOutput = true
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(true)
}
}
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
"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",
"dev.failsafe:failsafe",
)
}
onUsedTransitiveDependencies {
severity("ignore")
}
}
}
abi {
exclusions {
excludeAnnotations(
"io\\.opentelemetry\\.extension\\.annotations\\.WithSpan",
)
}
}
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri(snapshotUrl))
username.set(System.getenv("OSSRH_USER") ?: return@sonatype)
password.set(System.getenv("OSSRH_PASSWORD") ?: return@sonatype)
}
}
}
swaggerSources {
create("edc").apply {
setInputFile(file("./resources/openapi/openapi.yaml"))
ui(closureOf<GenerateSwaggerUI> {
outputDir = file("docs/swaggerui")
wipeOutputDir = true
})
}
}