forked from eclipse-hara/hara-ddiclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
324 lines (265 loc) · 8.18 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
324
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
/*
* 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 'java'
id 'jacoco'
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.license.report) apply true
alias(libs.plugins.dokka) apply false
alias(libs.plugins.sonarqube) apply true
}
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 plugin: 'java'
apply plugin: "org.sonarqube"
apply from: "$rootDir/ktlint.gradle"
dependencies {
implementation libs.kotlin.stdlib
implementation libs.kotlin.coroutines.jdk8
implementation libs.joda.time
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
jacocoTestReport {
mustRunAfter test
sourceSets sourceSets.main
reports {
xml.required = true
html.required = true
}
}
}
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 libs.retrofit.converter.gson
}
allprojects {
dependencies {
implementation libs.okhttp
implementation libs.retrofit
implementation libs.slf4j.api
}
}
project(subprj) {
dependencies {
implementation libs.gson
testImplementation libs.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 libs.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 libs.okhttp
implementation libs.slf4j.simple
testImplementation libs.kotlin.stdlib
testImplementation libs.kotlin.coroutines.jdk8
testImplementation libs.testng
testImplementation libs.mockk
testImplementation libs.retrofit
testImplementation libs.okhttp
testImplementation libs.okhttp.logging
testImplementation libs.retrofit.converter.gson
}
jacocoTestReport {
mustRunAfter 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}"
}
}
mainClassName = 'org.eclipse.hara.ddiclient.virtualdevice.MainKt'
tasks.withType(KotlinCompile).configureEach {
kotlinOptions.freeCompilerArgs += ["-opt-in=kotlin.RequiresOptIn"]
}
tasks.withType(JavaCompile).configureEach {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
}
boolean doHead(url) {
def connection = new URL(url).openConnection()
connection.requestMethod = 'HEAD'
try {
connection.responseCode == 200
} catch (IOException error) {
false
}
}
jacocoTestReport {
mustRunAfter 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:8080/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)
systemProperty("FREQUENT_POLLING_WHILE_UPDATING", false)
dependsOn ':virtual-device:test'
useTestNG()
afterTest { desc, result ->
logger.quiet "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
}
}
dependencies{
implementation project(':hara-ddiclient-api')
implementation project(':ddi-consumer')
implementation project(':ddi-consumer:ddi-api')
implementation libs.slf4j.api
implementation libs.joda.time
implementation libs.gson
implementation libs.retrofit.converter.gson
testImplementation libs.testng
testImplementation libs.kotlin.stdlib
testImplementation libs.kotlin.coroutines.jdk8
testImplementation libs.joda.time
testImplementation libs.okhttp
testImplementation libs.okhttp.logging
testImplementation libs.retrofit
}