forked from eclipse-tractusx/bpn-did-resolution-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
118 lines (105 loc) · 4.82 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
/*
*
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* 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
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
*
*/
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin
plugins {
`java-library`
id("com.bmuschko.docker-remote-api") version "9.4.0"
id("com.github.johnrengelman.shadow") version "8.1.1"
}
buildscript {
dependencies {
val edcGradlePluginsVersion: String by project
classpath("org.eclipse.edc.edc-build:org.eclipse.edc.edc-build.gradle.plugin:${edcGradlePluginsVersion}")
}
}
val metaModelVersion: String by project
val annotationProcessorVersion: String by project
allprojects {
apply(plugin = "org.eclipse.edc.edc-build")
// configure which version of the annotation processor to use. defaults to the same version as the plugin
configure<org.eclipse.edc.plugins.autodoc.AutodocExtension> {
outputDirectory.set(project.buildDir)
processorVersion.set(annotationProcessorVersion)
}
configure<org.eclipse.edc.plugins.edcbuild.extensions.BuildExtension> {
versions {
// override default dependency versions here
metaModel.set(metaModelVersion)
}
swagger {
title.set((project.findProperty("apiTitle") ?: "Tractus-X BDRS Server REST API") as String)
description =
(project.findProperty("apiDescription")
?: "Tractus-X REST APIs - merged by OpenApiMerger") as String
outputFilename.set(project.name)
outputDirectory.set(file("${rootProject.projectDir.path}/resources/openapi/yaml"))
resourcePackages = setOf("org.eclipse.tractusx.bdrs")
}
}
// EdcRuntimeExtension uses this to determine the runtime classpath of the module to run.
tasks.register("printClasspath") {
doLast {
println(sourceSets["main"].runtimeClasspath.asPath)
}
}
}
// the "dockerize" task is added to all projects that use the `shadowJar` plugin, e.g. runtimes
subprojects {
afterEvaluate {
if (project.plugins.hasPlugin("com.github.johnrengelman.shadow") &&
file("${project.projectDir}/src/main/docker/Dockerfile").exists()
) {
// this task copies some legal docs into the build folder, so we can easily copy them into the docker images
val copyLegalDocs = tasks.create("copyLegalDocs", Copy::class) {
into("${project.layout.buildDirectory.asFile.get()}")
into("legal") {
from("${project.rootProject.projectDir}/SECURITY.md")
from("${project.rootProject.projectDir}/NOTICE.md")
from("${project.rootProject.projectDir}/DEPENDENCIES")
from("${project.rootProject.projectDir}/LICENSE")
from("${projectDir}/notice.md")
}
mustRunAfter(tasks.named(ShadowJavaPlugin.SHADOW_JAR_TASK_NAME))
mustRunAfter(tasks.named(JavaPlugin.JAR_TASK_NAME))
}
//actually apply the plugin to the (sub-)project
apply(plugin = "com.bmuschko.docker-remote-api")
// configure the "dockerize" task
val dockerTask: DockerBuildImage = tasks.create("dockerize", DockerBuildImage::class) {
val dockerContextDir = project.projectDir
dockerFile.set(file("$dockerContextDir/src/main/docker/Dockerfile"))
images.add("${project.name}:${project.version}")
images.add("${project.name}:latest")
// specify platform with the -Dplatform flag:
if (System.getProperty("platform") != null)
platform.set(System.getProperty("platform"))
buildArgs.put("JAR", "build/libs/${project.name}.jar")
buildArgs.put("ADDITIONAL_FILES", "build/legal/*")
inputDir.set(file(dockerContextDir))
}
// make sure always runs after "dockerize" and after "copyOtel"
dockerTask
.dependsOn(tasks.named(ShadowJavaPlugin.SHADOW_JAR_TASK_NAME))
.dependsOn(copyLegalDocs)
}
}
}