Repository navigation
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
256 lines (219 loc) · 7.73 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
256 lines (219 loc) · 7.73 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
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
import org.apache.tools.ant.filters.ReplaceTokens
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.internal.KaptTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.javamodularity.moduleplugin.extensions.TestModuleOptions
import org.gradle.internal.os.OperatingSystem
plugins {
val kotlinVersion = "1.9.24"
application
jacoco
idea
antlr
kotlin("jvm") version kotlinVersion
kotlin("kapt") version kotlinVersion
id("org.sonarqube") version "5.1.0.4882"
id("com.github.ben-manes.versions") version "0.36.0"
// JavaFX distribution and packaging
id("org.openjfx.javafxplugin") version "0.1.0"
// Java module support (required for jlink/jpackage)
id("org.javamodularity.moduleplugin") version "1.8.12"
id("org.beryx.jlink") version "3.0.1"
// Auto-versioning from git tags
//id("com.palantir.git-version") version "2.0.0"
id("com.github.jmongard.git-semver-plugin") version "0.19.5"
id("org.ajoberstar.grgit") version "5.3.0"
}
repositories {
mavenCentral()
maven("https://dl.bintray.com/spekframework/spek/")
maven("https://oss.sonatype.org/content/groups/public/")
maven("https://maven.atlassian.com/content/repositories/atlassian-public/")
}
val archivesBaseName = "STT"
semver {
createReleaseCommit = false
}
//Remember to retrieve the version after plugin has been configured
version = semver.version
application {
mainModule.set("org.stt")
mainClass.set("org.stt.StartWithJFX")
// Required so ControlsFX validation decoration can access its own internal PNG
applicationDefaultJvmArgs =
listOf("--add-opens=org.controlsfx.controls/impl.org.controlsfx.control.validation=org.stt")
}
java {
sourceCompatibility = JavaVersion.VERSION_21
}
kapt {
correctErrorTypes = true
}
configurations {
implementation {
setExtendsFrom(extendsFrom.filter { it != configurations.antlr })
}
}
val spek_version = "2.0.4"
dependencies {
val daggerVersion = "2.50" // with dagger 2.52 they introduced an incomplete usage of jakarta.inject
antlr(group = "org.antlr", name = "antlr4", version = "4.9.1")
implementation(group = "org.antlr", name = "antlr4-runtime", version = "4.9.1")
implementation(group = "org.fxmisc.richtext", name = "richtextfx", version = "0.11.0") {
exclude(group = "org.openjfx")
}
implementation("org.yaml:snakeyaml:1.27")
implementation("com.google.dagger:dagger:$daggerVersion")
implementation("javax.inject:javax.inject:1")
kapt("com.google.dagger:dagger-compiler:$daggerVersion")
implementation("net.engio:mbassador:1.3.2")
implementation("org.controlsfx:controlsfx:11.1.2")
implementation("com.jsoniter:jsoniter:0.9.23")
implementation(kotlin("stdlib-jdk8"))
// ── Test dependencies ──
testImplementation("commons-io:commons-io:2.8.0")
testImplementation("org.mockito:mockito-core:5.12.0")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.4.0")
testImplementation("org.assertj:assertj-core:3.26.3")
testImplementation("junit:junit-dep:4.11")
// TestFX for JavaFX UI end-to-end tests
testImplementation("org.testfx:testfx-core:4.0.18")
// Monocle headless platform, pinned to JDK 21.0.x to match the javafx plugin version
testRuntimeOnly("org.testfx:openjfx-monocle:21.0.2") {
exclude(group = "org.openjfx")
}
}
javafx {
version = "21.0.4"
modules("javafx.base", "javafx.controls", "javafx.fxml", "javafx.graphics")
}
sonar {
properties {
property("sonar.projectkey", "org.stt:stt")
property("sonar.projectName", "SimpleTimeTracking")
}
}
distributions.getByName("main") {
contents {
include("**/STT*")
}
}
tasks.compileJava {
// Make kapt-generated sources available to the Java module source set
sourceSets {
main {
java {
srcDir("$buildDir/generated/source/kapt/main")
}
}
}
}
tasks.test {
extensions.configure(TestModuleOptions::class) {
// Tests run on the classpath (not the module path) to avoid JPMS issues
// with test frameworks and mocking libraries
runOnClasspath = true
}
// E2E tests are excluded from the default `test` task — run them separately
// via the `testE2e` task below.
exclude("**/*E2ETest*")
}
/*
* Custom task for running TestFX end-to-end tests.
* These tests require Monocle (headless JavaFX) and are excluded from
* the regular `test` task because they are slow and need a display-less
* environment.
*
* Usage: ./gradlew testE2e
*/
tasks.register<Test>("testE2e") {
include("**/*E2ETest*")
useJUnit()
testLogging {
events("passed", "failed", "skipped")
showExceptions = true
exceptionFormat = TestExceptionFormat.FULL
}
}
tasks.withType<org.jetbrains.kotlin.gradle.internal.KaptGenerateStubsTask> {
dependsOn(tasks.withType<AntlrTask>())
}
tasks.withType<ProcessResources> {
filesMatching("version.info") {
filter<ReplaceTokens>(
"tokens" to mapOf(
"app.version" to project.version,
"app.hash" to grgit.head().abbreviatedId
)
)
}
doLast {
println("Written tokes into file version.info")
}
}
task("dist") {
dependsOn += "jpackage"
dependsOn += "jlinkZip"
}
task("release") {
dependsOn += "dist"
doLast {
println("Built release for $project.version")
}
}
tasks.withType<AntlrTask> {
maxHeapSize = "64m"
arguments = arguments + "-visitor" + "-long-messages"
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "21"
}
//tasks.named("dependencyUpdates", com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask::class.java).configure {
// val badVersions = ".*(-rc(-.*)?$|-m.*)".toRegex()
// rejectVersionIf {
// candidate.version.toLowerCase().matches(badVersions)
// }
//}
jlink {
imageZip.set(File("$buildDir/dist/zips/stt-${javafx.platform.classifier}-${version}.zip"))
addOptions("--bind-services", "--strip-debug", "--compress", "2", "--no-header-files", "--no-man-pages")
mergedModule {
excludeRequires("javafx.graphics", "javafx.controls", "javafx.base")
}
forceMerge("kotlin") // see https://stackoverflow.com/questions/74453018/jlink-package-kotlin-in-both-merged-module-and-kotlin-stdlib
launcher {
name = "stt"
jvmArgs =
application.applicationDefaultJvmArgs.plus(
listOf(
// some classes in the merged-modules (see jlink plugin) need access to javafx modules
"--add-reads=simpleTimeTracking.merged.module=javafx.graphics",
"--add-reads=simpleTimeTracking.merged.module=javafx.base",
"--add-reads=simpleTimeTracking.merged.module=javafx.controls"
)
)
}
jpackage {
installerOutputDir = File( "$buildDir/dist/installer/${javafx.platform.classifier}")
skipInstaller = false
appVersion = project.version.toString().substringBefore('-')
val os = OperatingSystem.current()
if (os.isLinux || os.isUnix) {
icon = "src/main/resources/Logo.png"
installerOptions.plus(listOf(
"--linux-menu-group", "Office",
"--linux-shortcut"))
}
if (os.isWindows) {
installerType = "exe"
icon = "src/main/resources/Logo.ico"
installerOptions.plus(listOf(
"--win-upgrade-uuid", "0e521a7f-2fe2-4d30-9065-8a6972e11b56",
"--win-shortcut"))
}
if (os.isMacOsX) {
installerType = "dmg"
icon = "src/main/resources/Logo.icns"
}
}
}