-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle
More file actions
442 lines (381 loc) · 14.5 KB
/
Copy pathbuild.gradle
File metadata and controls
442 lines (381 loc) · 14.5 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
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
plugins {
id 'java'
id 'application'
id("com.gradleup.shadow") version "9.3.1"
id 'org.openjfx.javafxplugin' version '0.1.0'
id 'edu.sc.seis.launch4j' version '4.0.0'
}
def windowsZipDir = layout.buildDirectory.dir("windowsZip")
def buildTime = new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
def buildUser = System.getProperty("user.name")
def buildJdk = System.getProperty("java.version")
def buildVendor = System.getProperty("java.vendor")
def buildOs = "${System.getProperty("os.name")} ${System.getProperty("os.arch")} ${System.getProperty("os.version")}"
def appName = "CVC-Viewer"
def mainClassName = "io.github.realmoieen.cvcviewer.app.Launcher"
def windowsLogo = "${projectDir}/icons/cvc-logo.ico"
def macLogo = "${projectDir}/icons/cvc-logo.icns"
def linuxLogo = "${projectDir}/icons/cvc-logo.png"
def vendor = "Moieen Abbas"
def description = "The Utility to view CV Certificate.Card Verifiable Certificates (CVC) are digital certificates that are designed to be processed by devices."
def copyright = "Open-source software"
def uuid="62d77761-3da1-4efc-a865-0cafa56aef7d"
def outputDir = layout.buildDirectory.dir("installer").get().asFile
group = 'io.github.realmoieen.cvcviewer'
version = '4.0'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
application {
mainClass = mainClassName
}
javafx {
// Pinned to 21.0.5 (Java 17 bytecode) rather than latest: javafx-controls 23+ requires a
// Java 21+ runtime to even load, which would silently break the Java 17 baseline.
version = "21.0.5"
modules = ['javafx.controls', 'javafx.fxml', 'javafx.web']
}
repositories {
mavenCentral()
maven {
url = 'https://jitpack.io/'
}
}
configurations.all {
exclude group: "org.apache.logging.log4j", module: "log4j-core"
}
dependencies {
// System-scope dependencies (local JARs)
implementation('com.github.realmoieen.common-testbed-utilities:testbedutils-CVC:v1.4-rc1') {
exclude(group: "org.bouncycastle", module: "bcutil-jdk18on")
exclude(group: "org.bouncycastle", module: "bcpkix-jdk18on")
exclude(group: "org.bouncycastle", module: "bctls-jdk18on")
exclude(group: "org.apache.logging.log4j", module: "log4j-core")
}
implementation 'org.json:json:20240303'
// implementation 'com.github.Keyfactor:ejbca-cert-cvc:v1.6.1'
// Pinned to 2.0.1 rather than latest 2.1.0: 2.1.0 compiles to Java 21 bytecode,
// 2.0.1 is the newest release still targeting Java 17 bytecode.
implementation 'io.github.mkpaz:atlantafx-base:2.0.1'
// Renders GitHub release-note markdown in the update dialog. Core module only, no transitive deps.
implementation 'org.commonmark:commonmark:0.29.0'
// Windows-only: calls DwmSetWindowAttribute so the native title bar actually goes dark
// in dark theme (AtlantaFX/JavaFX CSS only styles window content, not OS-drawn chrome).
implementation 'net.java.dev.jna:jna:5.19.1'
implementation 'net.java.dev.jna:jna-platform:5.19.1'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
// JUnit 5 API + Engine
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
// REQUIRED: JUnit Platform Launcher (fixes your error)
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.10.2'
}
tasks.named("test") {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
jar {
archiveBaseName = project.name
manifest {
attributes(
// Standard
'Manifest-Version': '1.0',
'Created-By': "Gradle ${gradle.gradleVersion}",
// Main class
'Main-Class': mainClassName,
// Specification
'Specification-Title': project.name,
'Specification-Version': project.version,
'Specification-Vendor': 'io.github.realmoieen',
// Implementation
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': 'io.github.realmoieen',
'Implementation-Vendor-Id': 'io.github.realmoieen',
// Build Information
'Built-By': buildUser,
'Build-Time': buildTime,
'Build-Jdk': buildJdk,
'Build-Jdk-Vendor': buildVendor,
'Build-OS': buildOs,
'Gradle-Version': gradle.gradleVersion,
// Project Info
'Project-Name': project.name,
'Project-Version': project.version,
'Project-URL': 'https://realmoieen.github.io/CVC-Viewer/',
// Java Module (optional but recommended)
'Automatic-Module-Name': 'io.github.realmoieen'
)
}
}
// Encoding configuration
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
shadowJar {
archiveFileName = "${project.name}-${project.version}.jar"
}
launch4j {
mainClassName = mainClassName
icon = "${project.rootDir}/icons/cvc-logo.ico"
classpath = []
jarTask = project.tasks.shadowJar
errTitle = "Error CVC-Viewer"
version = project.version
textVersion = "$project.version"
description = "The Utility to view CV Certificate.Card Verifiable Certificates (CVC) are digital certificates that are designed to be processed by devices."
copyright = "Copyright (c) 2026 - Moieen Abbas"
companyName = "Moieen Abbas - https://github.com/realmoieen"
jreMinVersion = '17'
supportUrl = "https://github.com/realmoieen/CVC-Viewer/issues"
outfile = "${project.name}-${project.version}-portable.exe"
}
createExe {
dependsOn test
}
tasks.register('preparePortableWindows') {
group = 'portable'
dependsOn 'createExe'
doLast {
copy {
from(projectDir) {
include "install.bat"
filter { line ->
line.replaceAll("%VERSION%", project.version.toString())
}
}
// Launch4j exe + its dependency jars (kept alongside, not embedded)
from(layout.buildDirectory.dir('launch4j')) {
include "*.exe"
include "lib/**"
}
from(projectDir) {
include 'icons/*.png'
include 'icons/*.ico'
include 'README.md'
include 'LICENSE'
}
into windowsZipDir.get().asFile
}
}
}
tasks.register('portableWindows', Zip) {
group = 'portable'
description = 'Packages the Launch4j EXE (no bundled JRE, requires system Java 17+) into a portable Windows ZIP'
dependsOn preparePortableWindows
archiveBaseName = "${project.name}"
archiveClassifier = 'windows-portable'
archiveExtension = 'zip'
destinationDirectory = layout.buildDirectory.dir('distributions')
from windowsZipDir
}
def macAppDir = layout.buildDirectory.dir("portableMac/CVC-Viewer.app")
tasks.register('preparePortableMac') {
group = 'portable'
description = 'Assembles a minimal .app bundle wrapping the shadow jar (no bundled JRE, requires system Java 17+)'
dependsOn shadowJar
doLast {
def appDir = macAppDir.get().asFile
delete appDir
def contentsDir = new File(appDir, 'Contents')
def macosDir = new File(contentsDir, 'MacOS')
def resourcesDir = new File(contentsDir, 'Resources')
def appJarDir = new File(resourcesDir, 'app')
[contentsDir, macosDir, resourcesDir, appJarDir].each { it.mkdirs() }
copy {
from("${projectDir}/packaging/macos/Info.plist.template")
into contentsDir
rename { 'Info.plist' }
filter { line -> line.replaceAll('%VERSION%', project.version.toString()) }
}
copy {
from("${projectDir}/packaging/macos/launcher.sh")
into macosDir
rename { 'CVC-Viewer' }
}
new File(macosDir, 'CVC-Viewer').setExecutable(true, false)
copy {
from(macLogo)
into resourcesDir
}
copy {
from(shadowJar.archiveFile)
into appJarDir
rename { 'CVC-Viewer.jar' }
}
}
}
tasks.register('portableMac', Zip) {
group = 'portable'
description = 'Packages the .app bundle into a portable macOS ZIP (build/on macOS CI only - not runnable on Windows)'
dependsOn preparePortableMac
archiveBaseName = "${project.name}"
archiveClassifier = 'macos-portable'
archiveExtension = 'zip'
destinationDirectory = layout.buildDirectory.dir('distributions')
from(layout.buildDirectory.dir('portableMac'))
}
def linuxPortableDir = layout.buildDirectory.dir("portableLinux/CVC-Viewer")
tasks.register('preparePortableLinux') {
group = 'portable'
description = 'Assembles a shell launcher + desktop entry wrapping the shadow jar (no bundled JRE, requires system Java 17+)'
dependsOn shadowJar
doLast {
def dir = linuxPortableDir.get().asFile
delete dir
dir.mkdirs()
copy {
from(shadowJar.archiveFile)
into dir
rename { 'CVC-Viewer.jar' }
}
copy {
from("${projectDir}/packaging/linux/cvc-viewer.sh")
into dir
}
new File(dir, 'cvc-viewer.sh').setExecutable(true, false)
copy {
from("${projectDir}/packaging/linux/cvc-viewer.desktop.template")
into dir
rename { 'cvc-viewer.desktop' }
filter { line -> line.replaceAll('%INSTALL_DIR%', '.') }
}
copy {
from(linuxLogo)
into dir
rename { 'cvc-logo.png' }
}
copy {
from("${projectDir}/README.md", "${projectDir}/LICENSE")
into dir
}
}
}
tasks.register('portableLinux', Tar) {
group = 'portable'
description = 'Packages the shell launcher into a portable Linux tar.gz (no bundled JRE, requires system Java 17+)'
dependsOn preparePortableLinux
archiveBaseName = "${project.name}"
archiveClassifier = 'linux-portable'
compression = Compression.GZIP
archiveExtension = 'tar.gz'
destinationDirectory = layout.buildDirectory.dir('distributions')
from(linuxPortableDir)
}
tasks.register("verifyWix") {
group 'jpackage'
doLast {
def candle = "candle".execute()
if (candle.waitFor() != 0) {
throw new GradleException("WiX Toolset not found in PATH")
}
}
}
tasks.register("jpackageWindows", Exec) {
dependsOn shadowJar
group 'jpackage'
doFirst {
outputDir.mkdirs()
}
commandLine = [
"${javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}.get().metadata.installationPath}/bin/jpackage",
"--type", "msi", // or msi
"--name", appName,
"--input", shadowJar.archiveFile.get().asFile.parent,
"--main-jar", shadowJar.archiveFile.get().asFile.name,
"--main-class", mainClassName,
"--dest", outputDir,
"--app-version", project.version,
"--icon", windowsLogo,
"--win-menu",
"--win-shortcut",
"--win-dir-chooser",
"--win-shortcut-prompt",
"--win-per-user-install",
"--win-menu-group","CVC-Viewer",
"--win-upgrade-uuid", uuid,
"--vendor", vendor,
"--description", description,
"--copyright", copyright,
"--about-url", "https://realmoieen.github.io/CVC-Viewer/",
"--file-associations", "${projectDir}/packaging/cvcert.properties",
"--file-associations", "${projectDir}/packaging/cvreq.properties",
"--java-options", "-Dfile.encoding=UTF-8",
"--verbose"
]
}
tasks.register("jpackageMac", Exec) {
dependsOn shadowJar
group 'jpackage'
commandLine = [
"${javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}.get().metadata.installationPath}/bin/jpackage",
"--type", "dmg", // or msi
"--name", appName,
"--input", shadowJar.archiveFile.get().asFile.parent,
"--main-jar", shadowJar.archiveFile.get().asFile.name,
"--main-class", mainClassName,
"--dest", outputDir,
"--app-version", project.version,
"--mac-package-name", appName,
"--mac-package-identifier", "io.github.realmoieen.cvcviewer",
"--icon", macLogo,
"--vendor", vendor,
"--description", description,
"--copyright", copyright,
"--about-url", "https://realmoieen.github.io/CVC-Viewer/",
"--file-associations", "${projectDir}/packaging/cvcert.properties",
"--file-associations", "${projectDir}/packaging/cvreq.properties",
"--verbose"
]
}
tasks.register("jpackageLinux", Exec) {
dependsOn shadowJar
group 'jpackage'
commandLine = [
"${javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}.get().metadata.installationPath}/bin/jpackage",
"--type", "deb",
"--name", appName,
"--input", shadowJar.archiveFile.get().asFile.parent,
"--main-jar", shadowJar.archiveFile.get().asFile.name,
"--main-class", mainClassName,
"--dest", outputDir,
"--app-version", project.version,
"--icon", linuxLogo,
"--linux-app-category","Utility",
"--linux-menu-group", "Utilities",
"--linux-shortcut",
"--vendor", vendor,
"--description", description,
"--copyright", copyright,
"--about-url", "https://realmoieen.github.io/CVC-Viewer/",
"--file-associations", "${projectDir}/packaging/cvcert-linux.properties",
"--file-associations", "${projectDir}/packaging/cvreq-linux.properties",
"--verbose"
]
}
import org.gradle.internal.os.OperatingSystem
tasks.register("jpackageNative") {
group = "jpackage"
def os = OperatingSystem.current()
if (os.isWindows()) {
dependsOn jpackageWindows
}
else if (os.isMacOsX()) {
dependsOn jpackageMac
}
else if (os.isLinux()) {
dependsOn jpackageLinux
}
}