-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle.kts
261 lines (230 loc) · 8.84 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
import com.diffplug.gradle.spotless.SpotlessApply
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
repositories {
mavenCentral()
}
}
plugins {
java
signing
`maven-publish`
alias(libs.plugins.kotlin)
alias(libs.plugins.spotless)
alias(libs.plugins.license.report)
alias(libs.plugins.versions)
}
val descriptions: Map<String, String> = mapOf(
"idscp2-api" to "IDSCP2 Protocol API",
"idscp2-core" to "IDSCP2 Protocol Implementation",
"idscp2-app-layer" to "IDSCP2 Application Layer Implementation",
"idscp2-daps-aisec" to "IDSCP2 AISEC DAPS Driver",
"camel-idscp2" to "Camel IDSCP2 Component Implementation",
"infomodel" to "Legacy IAIS Infomodel Classes"
)
allprojects {
group = "de.fhg.aisec.ids"
repositories {
mavenCentral()
// Legacy IAIS Infomodel artifact repo
maven("https://gitlab.cc-asp.fraunhofer.de/api/v4/projects/55371/packages/maven")
}
val versionRegex = ".*(rc|beta|alpha)-?[0-9]*$".toRegex(RegexOption.IGNORE_CASE)
tasks.withType<DependencyUpdatesTask> {
rejectVersionIf {
// Reject release candidates and betas and pin Apache Camel to 3.18 LTS version
versionRegex.matches(candidate.version)
|| (candidate.group in setOf("org.apache.camel", "org.apache.camel.springboot")
&& !candidate.version.startsWith("3.18"))
|| candidate.group == "com.google.protobuf" && !candidate.version.startsWith("3.")
}
}
}
// Create and register ExecutionService which enforces serial execution of assigned tasks
abstract class SerialExecutionService : BuildService<BuildServiceParameters.None>
val serialExecutionService =
gradle.sharedServices.registerIfAbsent("serialExecution", SerialExecutionService::class.java) {
this.maxParallelUsages.set(1)
}
val spotlessApplyAll: Task by tasks.creating
subprojects {
apply(plugin = "java")
apply(plugin = "kotlin")
tasks.withType<Javadoc> {
exclude("de/fhg/aisec/ids/idscp2/messages/**", "de/fhg/aisec/ids/idscp2/applayer/messages/**")
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
withSourcesJar()
withJavadocJar()
}
tasks.test {
exclude("**/*IT.*")
}
val integrationTest = tasks.register<Test>("integrationTest") {
include("**/*IT.*")
systemProperty("project.version", "$project.version")
}
tasks.withType<Test> {
testLogging {
events("failed")
exceptionFormat = TestExceptionFormat.FULL
}
}
tasks.check {
dependsOn(integrationTest)
}
// define some Bill of Materials (BOM) for all subprojects
dependencies {
// Logging API
api(rootProject.libs.slf4j.api)
dependencies {
val versions = rootProject.libs.versions
// Some versions are downgraded for unknown reasons, fix this here
val groupPins = mapOf(
"org.jetbrains.kotlin" to mapOf(
"*" to versions.kotlin.get()
),
"com.google.guava" to mapOf(
"guava" to versions.guava.get()
)
)
// We need to explicitly specify the kotlin version for all kotlin dependencies,
// because otherwise something (maybe a plugin) downgrades the kotlin version,
// which produces errors in the kotlin compiler. This is really nasty.
configurations.all {
resolutionStrategy.eachDependency {
groupPins[requested.group]?.let { pins ->
pins["*"]?.let {
// Pin all names when asterisk is set
useVersion(it)
} ?: pins[requested.name]?.let { pin ->
// Pin only for specific names given in map
useVersion(pin)
}
}
}
}
}
}
tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
// options.compilerArgs.add("-Xlint:unchecked")
// options.isDeprecation = true
}
tasks.jar {
manifest {
attributes(
"Bundle-Vendor" to "Fraunhofer AISEC",
"-noee" to true
)
}
}
apply(plugin = "maven-publish")
apply(plugin = "signing")
if (project.name in descriptions.keys) {
publishing {
publications {
register("idscp2Library", MavenPublication::class) {
from(components["java"])
pom {
name.set(project.name)
description.set(descriptions[project.name])
url.set("https://github.com/industrial-data-space/idscp2-jvm")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
name.set("Michael Lux")
email.set("michael.lux@aisec.fraunhofer.de")
organization.set("Fraunhofer AISEC")
organizationUrl.set("aisec.fraunhofer.de")
}
}
scm {
connection.set("scm:git:git://github.com:industrial-data-space/idscp2-jvm.git")
developerConnection.set("scm:git:ssh://github.com:industrial-data-space/idscp2-jvm.git")
url.set("https://github.com/industrial-data-space/idscp2-jvm")
}
}
}
}
repositories {
if (project.hasProperty("publishLocal")) {
mavenLocal()
} else {
maven {
url = uri(
if (version.toString().endsWith("SNAPSHOT")) {
"https://oss.sonatype.org/content/repositories/snapshots"
} else {
"https://oss.sonatype.org/service/local/staging/deploy/maven2"
}
)
credentials {
username = project.findProperty("deployUsername") as? String
password = project.findProperty("deployPassword") as? String
}
}
// Prevent parallel publishing
tasks.withType<PublishToMavenRepository> {
usesService(serialExecutionService)
}
}
}
}
if (!project.hasProperty("publishLocal")) {
signing {
useGpgCmd()
sign(publishing.publications.getByName("idscp2Library"))
}
}
}
apply(plugin = "com.github.jk1.dependency-license-report")
apply(plugin = "com.diffplug.spotless")
spotless {
kotlin {
target("src/*/kotlin/**/*.kt")
ktlint(libs.versions.ktlint.get()).editorConfigOverride(mapOf(
"ktlint_code_style" to "intellij_idea"
))
licenseHeader(
"""/*-
* ========================LICENSE_START=================================
* ${project.name}
* %%
* Copyright (C) ${"$"}YEAR Fraunhofer AISEC
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://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.
* =========================LICENSE_END==================================
*/"""
).yearSeparator(" - ")
}
}
tasks.withType<SpotlessApply> {
spotlessApplyAll.dependsOn(this.path)
}
}