-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
199 lines (173 loc) · 7.68 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
199 lines (173 loc) · 7.68 KB
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
/*
* build.gradle.kts (root aggregator)
*
* Thin aggregator for interlockSim multi-module project.
* Application code lives in :desktop-ui, domain code in :core.
* This file owns: SonarQube config, checkKdisco, and delegation tasks.
*/
plugins {
// Declare versions for subprojects (apply false — subprojects opt in).
// kotlin/ktlint/detekt/burst/mokkery versions all come from gradle.properties
// via pluginManagement in settings.gradle.kts.
kotlin("jvm") apply false
kotlin("multiplatform") apply false
id("com.gradleup.shadow") version "8.3.8" apply false
id("org.jlleitschuh.gradle.ktlint") apply false
id("io.gitlab.arturbosch.detekt") apply false
id("me.champeau.jmh") version "0.7.2" apply false
id("app.cash.burst") apply false
id("dev.mokkery") apply false
id("org.sonarqube") version "6.2.0.5505"
jacoco
}
// Load versions from gradle.properties
val kdiscoVersion: String by project
val slf4jVersion: String by project
val logbackVersion: String by project
val kotlinLoggingVersion: String by project
val junitPlatformVersion: String by project
val junitJupiterVersion: String by project
val assertkVersion: String by project
val mockkVersion: String by project
val koinVersion: String by project
val javaVersion: String by project
val kotlinVersion: String by project
group = "cz.vutbr.fit"
version = "1.0"
// ===========================================
// checkKdisco — must live here so both subprojects can depend on it
// ===========================================
val checkKdisco by tasks.registering {
group = "verification"
description = "Verify kDisco library is installed in Maven local repository"
doLast {
val kdiscoJar =
file(
"${System.getProperty("user.home")}/.m2/repository/cz/hovorka/kdisco/kdisco-core-jvm/$kdiscoVersion/kdisco-core-jvm-$kdiscoVersion.jar",
)
if (kdiscoJar.exists()) {
println("✓ kDisco $kdiscoVersion found in mavenLocal: ${kdiscoJar.absolutePath}")
} else {
println("⚠ kDisco $kdiscoVersion not found in mavenLocal")
println(" To install: cd ~/work/kdisco && ./gradlew :kdisco-core:publishToMavenLocal")
}
}
}
// ===========================================
// Lifecycle delegation tasks
// ===========================================
tasks.register("test") {
dependsOn(":core:jvmTest", ":desktop-ui:test")
}
tasks.register("integrationTest") {
dependsOn(":core:integrationTest", ":desktop-ui:integrationTest")
}
listOf(
"runSim", "runEditor", "runExample", "runExampleGui", "runSimFromXml",
"shadowJar", "verifyKoinConfiguration", "koinStatus", "printConfig",
).forEach { name ->
tasks.register(name) { dependsOn(":desktop-ui:$name") }
}
// :fast-sim and native subprojects are only included on Linux hosts; guard lifecycle tasks accordingly.
// Defined in settings.gradle.kts and shared via gradle.extra.
val isLinuxHost: Boolean by gradle.extra
if (isLinuxHost) {
tasks.register("buildFastSim") { dependsOn(":fast-sim:linkReleaseExecutableLinuxX64") }
tasks.register("runFastSim") { dependsOn(":fast-sim:runDebugExecutableLinuxX64") }
tasks.register("buildFastSimRelease") { dependsOn(":fast-sim:linkReleaseExecutableLinuxX64") }
tasks.register("runFastSimRelease") { dependsOn(":fast-sim:runReleaseExecutableLinuxX64") }
}
// ===========================================
// SonarQube Configuration
// ===========================================
sonar {
properties {
property("sonar.projectKey", "bedaHovorka_interlockSim")
property("sonar.projectName", "interlockSim - Railway Interlocking Simulator")
property("sonar.projectVersion", version.toString())
// Source and test paths (desktop-ui + :core KMP subproject).
// Kept in sync with sonar-project.properties (used for local sonar-scanner runs).
property(
"sonar.sources",
"desktop-ui/src/main/kotlin,core/src/commonMain/kotlin," +
"core/src/jvmMain/kotlin,core/src/nativeMain/kotlin",
)
property(
"sonar.tests",
"desktop-ui/src/test/kotlin,core/src/commonTest/kotlin,core/src/jvmTest/kotlin",
)
property("sonar.java.binaries", "desktop-ui/build/classes/kotlin/main,core/build/classes/kotlin/jvm/main")
property("sonar.java.test.binaries", "desktop-ui/build/classes/kotlin/test,core/build/classes/kotlin/jvm/test")
property("sonar.java.source", javaVersion)
property("sonar.java.target", javaVersion)
property("sonar.language", "java,kotlin")
property("sonar.kotlin.source.version", kotlinVersion)
property(
"sonar.junit.reportPaths",
"desktop-ui/build/test-results/test," +
"desktop-ui/build/test-results/integrationTest," +
"core/build/test-results/jvmTest," +
"core/build/test-results/integrationTest",
)
property(
"sonar.coverage.jacoco.xmlReportPaths",
listOf(
file("desktop-ui/build/reports/jacoco/test/jacocoTestReport.xml"),
file("core/build/reports/jacoco/jvmTest/jacocoTestReport.xml"),
).joinToString(",") { it.absolutePath },
)
property("sonar.sourceEncoding", "UTF-8")
property("sonar.qualitygate.wait", "false")
// :fast-sim and :core's nativeMain compile to linuxX64 native — JaCoCo cannot
// instrument native code (coverage comes from :core:linuxX64Test).
// :core-test is test-support infrastructure, not production code requiring coverage.
property(
"sonar.coverage.exclusions",
"fast-sim/**,core-test/**,core/src/nativeMain/**," +
"desktop-ui/src/main/kotlin/**/gui/MenuBar.kt," +
"desktop-ui/src/main/kotlin/**/gui/Frame.kt," +
"desktop-ui/src/main/kotlin/**/gui/RailwayNetGridCanvas.kt," +
"desktop-ui/src/main/kotlin/**/gui/ToolBar.kt," +
"desktop-ui/src/main/kotlin/**/gui/ValidationDialog.kt," +
"desktop-ui/src/main/kotlin/**/gui/RenameDialog.kt," +
"desktop-ui/src/main/kotlin/**/gui/action/**," +
"desktop-ui/src/main/kotlin/**/gui/gridcanvas/**," +
"desktop-ui/src/main/kotlin/**/gui/animation/**",
)
}
}
tasks.named("sonar") {
dependsOn(
":desktop-ui:test", ":desktop-ui:integrationTest", ":desktop-ui:jacocoTestReport",
":core:jvmTest", ":core:integrationTest", ":core:jacocoTestReport",
)
}
// ===========================================
// Aggregated JaCoCo Report (cross-module)
// ===========================================
val jacocoAggregatedReport by tasks.registering(JacocoReport::class) {
group = "verification"
description = "Generate aggregated JaCoCo coverage report across all modules"
dependsOn(
":core:jvmTest", ":core:integrationTest",
":desktop-ui:test", ":desktop-ui:integrationTest",
)
executionData.setFrom(
fileTree("core/build").include("jacoco/*.exec"),
fileTree("desktop-ui/build").include("jacoco/*.exec"),
)
sourceDirectories.setFrom(
files("core/src/commonMain/kotlin", "core/src/jvmMain/kotlin", "desktop-ui/src/main/kotlin")
)
classDirectories.setFrom(
fileTree("core/build/classes/kotlin/jvm/main"),
fileTree("desktop-ui/build/classes/kotlin/main"),
)
reports {
xml.required.set(true)
xml.outputLocation.set(file("build/reports/jacoco/aggregated/jacocoTestReport.xml"))
html.required.set(true)
html.outputLocation.set(file("build/reports/jacoco/aggregated/html"))
csv.required.set(false)
}
}