-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
280 lines (229 loc) · 8.08 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
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
import com.vanniktech.maven.publish.*
import org.jetbrains.kotlin.gradle.tasks.*
val GARBAGE_COLLECTOR = "-XX:+UseParallelGC"
val PROJECT_VERSION =
try {
providers.gradleProperty("projectVersion").get()
} catch (e: Exception) {
println("ERROR - Unable to find version: ${e.message}")
"0.1.0-SNAPSHOT"
}
val PROJECT_GROUP: String = providers.gradleProperty("project.group").get()
group = PROJECT_GROUP
plugins {
// Environment
id("me.filippov.gradle.jvm.wrapper") version "0.14.0"
kotlin("jvm") version "2.0.0"
// GUI
id("org.openjfx.javafxplugin") version "0.1.0"
// Code quality, testing & documentation
jacoco
// id("org.jlleitschuh.gradle.ktlint") version "12.1.0"
id("org.sonarqube") version "5.0.0.4638"
id("org.jetbrains.dokka") version "1.9.20"
id("com.github.ben-manes.versions") version "0.51.0"
// Modularization & packaging
application
id("org.javamodularity.moduleplugin") version ("1.8.15") apply false
id("org.panteleyev.jpackageplugin") version "1.6.0"
// Releases & publishing
id("it.nicolasfarabegoli.conventional-commits") version "3.1.3"
id("com.vanniktech.maven.publish") version "0.28.0"
}
repositories {
mavenCentral()
}
java {
// withJavadocJar()
// withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
mavenPublishing {
coordinates(PROJECT_GROUP, rootProject.name, PROJECT_VERSION)
publishToMavenCentral(SonatypeHost.S01, automaticRelease = true)
signAllPublications()
pom {
name.set(rootProject.name)
description.set("A formal approach to monitoring web pages as spatio-temporal traces.")
url.set("https://enniovisco.github.io/webmonitor/")
licenses {
license {
name.set("MIT License")
url.set("https://raw.githubusercontent.com/ennioVisco/webmonitor/master/LICENSE")
}
}
developers {
developer {
id.set("ennioVisco")
name.set("Ennio Visconti")
email.set("ennio.visconti@gmail.com")
}
}
scm {
connection.set("scm:git:git://github.com/enniovisco/webmonitor.git")
developerConnection.set("scm:git:ssh://github.com/enniovisco/webmonitor.git")
url.set("https://github.com/enniovisco/webmonitor")
}
}
}
afterEvaluate {
tasks.named("generateMetadataFileForMavenPublication") {
dependsOn("kotlinSourcesJar", "dokkaJavadocJar")
}
}
sonar {
properties {
property("sonar.projectKey", "ennioVisco_${rootProject.name}")
property("sonar.organization", "enniovisco")
property("sonar.host.url", "https://sonarcloud.io")
}
}
javafx {
version = "21"
modules =
listOf("javafx.base", "javafx.controls", "javafx.swing", "javafx.web")
}
dependencies {
// Configuration files
// testImplementation(kotlin("stdlib"))
implementation(kotlin("script-runtime"))
runtimeOnly(kotlin("scripting-jsr223"))
// testImplementation(kotlin("compiler-embeddable"))
testImplementation(kotlin("script-runtime"))
testRuntimeOnly(kotlin("scripting-jsr223"))
// Moonlight
implementation("io.github.moonlightsuite:moonlight-engine:0.3.0")
// Selenium
implementation("org.seleniumhq.selenium:selenium-java:4.23.1")
// implementation("org.seleniumhq.selenium:selenium-http-jdk-client:4.13.0")
testImplementation("org.seleniumhq.selenium:selenium-java:4.23.1")
// implementation("io.github.bonigarcia:webdrivermanager:5.8.0")
// TestFX (headless GUI)
implementation("org.testfx:testfx-core:4.0.18")
implementation("org.testfx:testfx-junit5:4.0.18")
implementation("org.testfx:openjfx-monocle:21.0.2")
// Dokka
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20")
// Charts
implementation("eu.hansolo.fx:charts:21.0.7")
// Logging
implementation("io.github.oshai:kotlin-logging-jvm:7.0.0")
runtimeOnly("org.slf4j:slf4j-api:2.0.7")
implementation("ch.qos.logback:logback-classic:1.5.6")
// Pretty printing (debug)
implementation("com.tylerthrailkill.helpers:pretty-print:2.0.2")
// Tests
testImplementation(kotlin("test"))
testImplementation(kotlin("test-junit5"))
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
testImplementation("io.mockk:mockk:1.13.11")
testImplementation("com.github.stefanbirkner:system-lambda:1.2.1")
testImplementation(kotlin("reflect"))
}
fun runtimeArgs(exec: Any) {
val arguments =
listOf(
GARBAGE_COLLECTOR,
"--add-exports",
"javafx.graphics/com.sun.glass.ui=ALL-UNNAMED",
"--add-exports",
"javafx.graphics/com.sun.glass.utils=ALL-UNNAMED",
"--add-exports",
"javafx.graphics/com.sun.javafx.util=ALL-UNNAMED",
"--add-exports",
"javafx.base/com.sun.javafx.logging=ALL-UNNAMED",
"--add-opens",
"javafx.graphics/com.sun.glass.ui=ALL-UNNAMED",
"--add-opens",
"javafx.graphics/com.sun.glass.utils=ALL-UNNAMED"
)
when (exec) {
is JavaExec -> exec.jvmArgs(arguments)
is Test -> exec.jvmArgs(arguments)
else -> throw IllegalArgumentException("Unknown exec type: $exec")
}
}
tasks tasks@{
// withType<JavaCompile> {
// options.compilerArgs.add(ENABLE_PREVIEW)
// }
dokkaHtml.configure {
outputDirectory.set(layout.buildDirectory.dir("dokka"))
}
test {
useJUnitPlatform()
runtimeArgs(this)
finalizedBy(this@tasks.jacocoTestReport) // report is always generated after tests run
}
withType<JavaExec> {
val headlessJavaFXSettings =
mapOf(
// "java.awt.headless" to true,
"testfx.robot" to "glass",
"testfx.headless" to true,
"glass.platform" to "Monocle",
"monocle.platform" to "Headless",
"headless.geometry" to "1920x1080-32",
// "prism.order" to "sw"
)
runtimeArgs(this)
systemProperties = headlessJavaFXSettings
System.setProperty("webdriver.http.factory", "jdk-http-client")
}
jacocoTestReport {
dependsOn(this@tasks.test) // tests are required to run before generating the report
reports {
xml.required.set(true)
}
}
withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
}
}
// withType<Test>().configureEach {
// maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)
// }
}
fun pkg(name: String) = "${group}.${name}Kt"
application {
// applicationDefaultJvmArgs = listOf(ENABLE_PREVIEW)
// println("Current exec dir: $executableDir")
mainClass.set(pkg("Main"))
// mainModule.set("com.enniovisco.webmonitor") // TODO: investigate, this seems to brake javafx deps
}
val jarsDir: Provider<Directory> = layout.buildDirectory.dir("jars")
task("copyDependencies", Copy::class) {
from(configurations.runtimeClasspath).into(jarsDir)
}
task("copyJar", Copy::class) {
from(tasks.jar).into(jarsDir)
}
tasks.jpackage {
dependsOn("build", "copyDependencies", "copyJar")
// App Info
appName = "WebMonitor"
vendor = "enniovisco.com"
appVersion = PROJECT_VERSION
copyright = "Copyright (c) 2023 Vendor"
// App settings (non-modular)
mainJar = tasks.jar.get().archiveFileName.get()
mainClass = pkg("Main")
input = jarsDir.toString()
// App settings (modular)
// runtimeImage = System.getProperty("java.home")
// module = pkg("Main")
// modulePaths = listOf(File("$buildDir/jmods").toString())
// Build destination
destination = layout.buildDirectory.dir("dist").toString()
// Java Options
javaOptions = listOf("-Dfile.encoding=UTF-8")
windows {
winMenu = true
winDirChooser = true
winConsole = true
}
}