/
build.gradle.kts
191 lines (166 loc) · 7.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
import com.google.cloud.tools.jib.gradle.PlatformParameters
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType
buildscript {
dependencies {
classpath("com.google.cloud.tools:jib-spring-boot-extension-gradle:0.1.0")
}
}
extra["springCloudVersion"] = "2021.0.3"
extra["testcontainersVersion"] = "1.16.2"
plugins {
java // why did I have to add that ?!
// only apply the plugin in the subprojects requiring it because it expects a Spring Boot app
// and the shared lib is obviously not one
id("org.springframework.boot") version "2.7.1" apply false
id("io.spring.dependency-management") version "1.0.11.RELEASE" apply false
kotlin("jvm") version "1.6.21" apply false
kotlin("plugin.spring") version "1.7.0" apply false
id("org.jlleitschuh.gradle.ktlint") version "10.3.0"
id("com.google.cloud.tools.jib") version "3.2.1" apply false
id("io.gitlab.arturbosch.detekt") version "1.20.0" apply false
id("org.sonarqube") version "3.3"
jacoco
}
subprojects {
repositories {
mavenCentral()
}
apply(plugin = "io.spring.dependency-management")
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jetbrains.kotlin.plugin.spring")
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "io.gitlab.arturbosch.detekt")
apply(plugin = "jacoco")
java.sourceCompatibility = JavaVersion.VERSION_17
the<DependencyManagementExtension>().apply {
imports {
mavenBom("org.testcontainers:testcontainers-bom:${property("testcontainersVersion")}")
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
}
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
implementation("org.springframework.boot:spring-boot-starter-security")
// it provides support for JWT decoding and verification
implementation("org.springframework.security:spring-security-oauth2-jose")
implementation("org.springframework.kafka:spring-kafka")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("com.github.jsonld-java:jsonld-java:0.13.4")
implementation("io.arrow-kt:arrow-fx-coroutines:1.1.2")
implementation("org.locationtech.jts.io:jts-io-common:1.19.0")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
runtimeOnly("de.siegmar:logback-gelf:4.0.2")
runtimeOnly("io.micrometer:micrometer-registry-prometheus")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
// to ensure we are using mocks and spies from springmockk lib instead
exclude(module = "mockito-core")
}
testImplementation("com.ninja-squad:springmockk:3.1.1")
testImplementation("io.mockk:mockk:1.12.4")
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "17"
}
}
tasks.withType<Test> {
environment("SPRING_PROFILES_ACTIVE", "test")
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
ktlint {
disabledRules.set(setOf("experimental:multiline-if-else", "no-wildcard-imports"))
reporters {
reporter(ReporterType.CHECKSTYLE)
reporter(ReporterType.PLAIN)
}
}
tasks.withType<Detekt>().configureEach {
config.setFrom(files("$rootDir/config/detekt/detekt.yml"))
buildUponDefaultConfig = true
baseline.set(file("$projectDir/config/detekt/baseline.xml"))
reports {
xml.required.set(true)
txt.required.set(false)
html.required.set(true)
}
}
tasks.withType<DetektCreateBaselineTask>().configureEach {
config.setFrom(files("$rootDir/config/detekt/detekt.yml"))
buildUponDefaultConfig.set(true)
baseline.set(file("$projectDir/config/detekt/baseline.xml"))
}
// see https://docs.gradle.org/current/userguide/jacoco_plugin.html for configuration instructions
jacoco {
toolVersion = "0.8.7"
}
tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
}
tasks.withType<JacocoReport> {
dependsOn(tasks.test) // tests are required to run before generating the report
reports {
xml.required.set(true)
html.required.set(true)
}
}
project.ext.set("jibFromImage", "eclipse-temurin:17-jre")
project.ext.set(
"jibFromPlatforms",
listOf(
PlatformParameters().apply { os = "linux"; architecture = "arm64" },
PlatformParameters().apply { os = "linux"; architecture = "amd64" }
)
)
project.ext.set("jibContainerJvmFlags", listOf("-Xms256m", "-Xmx768m"))
project.ext.set("jibContainerCreationTime", "USE_CURRENT_TIMESTAMP")
project.ext.set(
"jibContainerLabels",
mapOf(
"maintainer" to "EGM",
"org.opencontainers.image.authors" to "EGM",
"org.opencontainers.image.documentation" to "https://stellio.readthedocs.io/",
"org.opencontainers.image.vendor" to "EGM",
"org.opencontainers.image.licenses" to "Apache-2.0",
"org.opencontainers.image.title" to "Stellio context broker",
"org.opencontainers.image.description" to
"""
Stellio is an NGSI-LD compliant context broker developed by EGM.
NGSI-LD is an Open API and data model specification for context management published by ETSI.
""".trimIndent(),
"org.opencontainers.image.source" to "https://github.com/stellio-hub/stellio-context-broker",
"com.java.version" to "${JavaVersion.VERSION_17}"
)
)
}
allprojects {
group = "com.egm.stellio"
version = "1.4.0-dev"
repositories {
mavenCentral()
maven { url = uri("https://repo.spring.io/milestone") }
}
sonarqube {
properties {
property("sonar.projectKey", "stellio-hub_stellio-context-broker")
property("sonar.organization", "stellio-hub")
property("sonar.host.url", "https://sonarcloud.io")
}
}
}