-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.gradle
323 lines (271 loc) · 8.32 KB
/
build.gradle
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
/*
* Copyright © 2017-2024 Kynetics, Inc.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*/
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.8.10'
id 'io.gitlab.arturbosch.detekt' version '1.17.1'
id 'jacoco'
id 'java'
id 'com.github.jk1.dependency-license-report' version '1.16'
id("org.jetbrains.dokka") version "1.6.10"
id "org.sonarqube" version "4.4.1.3373"
}
repositories {
mavenCentral()
mavenLocal()
}
final def deps = gradle.settings.app_dependencies
final def tdeps = gradle.settings.test_dependencies
final def app_version = '2.0.0'
ext.keep_test_container_alive = project.hasProperty('keep_test_container_alive') ? project.getProperty('keep_test_container_alive').toBoolean() : false
def sonarProjectKey = System.getenv("SONAR_CLOUD_PROJECT_KEY")
def sonarProjectName = System.getenv("SONAR_CLOUD_PROJECT_NAME")
def sonarProjectOrganization = System.getenv("SONAR_CLOUD_ORGANIZATION")
sonar {
properties {
property "sonar.projectKey", sonarProjectKey
property "sonar.projectName", sonarProjectName
property "sonar.organization", sonarProjectOrganization
property "sonar.sourceEncoding", "UTF-8"
property "sonar.host.url", "https://sonarcloud.io"
}
}
allprojects {
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'maven-publish'
apply from: "$rootDir/ktlint.gradle"
apply plugin: 'java'
apply plugin: "org.jetbrains.dokka"
apply plugin: "org.sonarqube"
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation deps.kotlin_stdlib
implementation deps.kotlin_x
implementation deps.joda
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
vendor = JvmVendorSpec.ADOPTOPENJDK
}
}
}
project(':ddi-consumer') {
group 'org.eclipse.hara.hara-ddiclient'
version app_version
final def subprj = ':ddi-consumer:ddi-api'
dependencies {
implementation project(subprj)
implementation project(':hara-ddiclient-api')
implementation deps.retrofit_converter
}
allprojects {
dependencies {
implementation deps.okhttp
implementation deps.retrofit
implementation deps.slf4j_api
}
}
project(subprj) {
dependencies {
implementation deps.gson
testImplementation tdeps.testng
}
test {
useTestNG()
}
}
}
project(':ddi-consumer:ddi-api') {
group 'org.eclipse.hara.hara-ddiclient.ddi-consumer'
version app_version
dependencies {
}
}
project(':hara-ddiclient-api') {
group 'org.eclipse.hara.hara-ddiclient.api'
version app_version
dependencies {
implementation deps.okhttp
}
}
project(':virtual-device'){
group 'org.eclipse.hara.hara-virtual-device'
version app_version
apply plugin: 'application'
apply plugin: 'jacoco'
dependencies {
implementation rootProject
implementation project(':hara-ddiclient-api')
implementation project(':ddi-consumer')
implementation project(':ddi-consumer:ddi-api')
implementation deps.slf4j_simple
implementation deps.okhttp
testImplementation deps.kotlin_stdlib
testImplementation deps.kotlin_x
testImplementation tdeps.testng
testImplementation tdeps.mockk
testImplementation deps.retrofit
testImplementation deps.okhttp
testImplementation deps.okhttp_logging
testImplementation deps.retrofit_converter
}
jacocoTestReport {
dependsOn test
sourceSets sourceSets.main
reports {
xml.required = true
html.required = true
}
}
test {
dependsOn ':waitingHawkbitServer'
useTestNG()
afterTest { desc, result ->
logger.quiet "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
}
finalizedBy jacocoTestReport
}
mainClassName = 'org.eclipse.hara.ddiclient.virtualdevice.MainKt'
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions.freeCompilerArgs += ["-opt-in=kotlin.RequiresOptIn"]
}
}
boolean doHead(url) {
def connection = new URL(url).openConnection()
connection.requestMethod = 'HEAD'
try {
connection.responseCode == 200
} catch (IOException error) {
false
}
}
detekt {
toolVersion = "1.17.1"
config = files("$rootDir/default-detekt-config.yml", "$rootDir/detekt-config.yml")
input = files("$projectDir")
buildUponDefaultConfig = true
}
jacocoTestReport {
dependsOn tasks.withType(Test)
sourceSets sourceSets.main
subprojects.each {
sourceSets it.sourceSets.main
}
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/test.exec")
classDirectories.setFrom(files(sourceSets.main.output) +
files(subprojects.sourceSets.main.output))
sourceDirectories.setFrom(files(sourceSets.main.allSource.srcDirs) +
files(subprojects.sourceSets.main.allSource.srcDirs))
additionalSourceDirs.setFrom(files(sourceSets.main.allSource.srcDirs) +
files(subprojects.sourceSets.main.allSource.srcDirs))
reports {
xml.required = true
html.required = true
}
}
def dockerClientDir = new File(project.buildDir, "docker-client")
task makeDockerContex(type: Copy) {
group "Docker"
dependsOn ":virtual-device:installDist"
from new File(project.projectDir, "virtual-device/build/install").getAbsolutePath()
from new File(project.projectDir, "docker/client").getAbsolutePath()
into dockerClientDir.getAbsolutePath()
}
task buildImage(){
group "Docker"
dependsOn makeDockerContex
doLast{
exec {
workingDir dockerClientDir
commandLine "docker", "build", ".", "--tag", "hara-virtual-device:$app_version"
}
}
}
task stopHawkbitServer() {
group 'testing'
doFirst {
if (!keep_test_container_alive) {
exec {
workingDir 'docker/test/'
commandLine 'docker', 'compose', 'down'
}
}
}
}
task restartHawkbitServer() {
group 'testing'
doFirst {
exec {
workingDir 'docker/test/'
commandLine 'docker', 'compose', 'down'
}
}
doLast{
exec {
workingDir 'docker/test/'
commandLine 'docker', 'compose', 'up', '--detach'
}
}
}
task waitingHawkbitServer(){
group 'testing'
dependsOn 'restartHawkbitServer'
doFirst {
def url = 'http://localhost:8081/UI/login'
println "Waiting for ${url} ..."
while (!doHead(url)) {
sleep(5000)
println "Waiting for ${url} ..."
}
println "${url} is up!"
}
}
test.dependsOn waitingHawkbitServer
test.dependsOn cleanTest
test.finalizedBy stopHawkbitServer
group 'org.eclipse.hara.hara-ddiclient'
version app_version
test {
systemProperty("LOG_HTTP", project.findProperty("logHttp") ?: "false")
systemProperty("LOG_INTERNAL", project.findProperty("logInternal") ?: "false")
systemProperty("BACKOFF_INTERVAL_SECONDS", 45)
dependsOn ':virtual-device:test'
useTestNG()
afterTest { desc, result ->
logger.quiet "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
}
finalizedBy jacocoTestReport
}
dependencies{
implementation project(':hara-ddiclient-api')
implementation project(':ddi-consumer')
implementation project(':ddi-consumer:ddi-api')
implementation deps.slf4j_api
implementation deps.joda
implementation deps.gson
implementation deps.retrofit_converter
testImplementation tdeps.testng
testImplementation deps.kotlin_stdlib
testImplementation deps.kotlin_x
testImplementation deps.joda
testImplementation deps.okhttp
testImplementation deps.okhttp_logging
testImplementation deps.retrofit
}