forked from mzmine/mzmine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
568 lines (505 loc) · 24.4 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
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
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
/*
* Copyright (c) 2004-2022 The MZmine Development Team
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
import org.gradle.internal.os.OperatingSystem
import java.nio.file.FileSystems
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardCopyOption
import java.util.function.Consumer
plugins {
id "java"
id "application"
id "org.openjfx.javafxplugin" version "0.0.13"
id "org.beryx.runtime" version "1.12.7"
// versioning now in version.properties file
// https://github.com/ethauvin/semver-gradle
id "net.thauvin.erik.gradle.semver" version "1.0.4"
}
// save version to main resources
// version bump by .\gradlew incrementPatch ... incrementMinor
// gradle -Dversion.prerelease=beta incrementPatch
// version with -beta is currently not supported by jpackage (maybe windows --app-version)
// java.lang.IllegalArgumentException: "Version [3.0.0-beta] contains invalid component [0-beta]"
semver {
properties = "src/main/resources/mzmineversion.properties"
}
// version is now in version.properties
group = "io.github.mzmine"
description = "MZmine"
java {
sourceCompatibility = "19"
targetCompatibility = "19"
}
defaultTasks "test", "jpackage", "notarizeApp"
// Check the OS
project.ext.osSuffix = OperatingSystem.current().getName().replaceAll(" ", "_")
if (OperatingSystem.current().isLinux()) project.ext.osSuffix = "Linux"
if (OperatingSystem.current().isWindows()) project.ext.osSuffix = "Windows"
if (OperatingSystem.current().isMacOsX()) {
project.ext.osSuffix = "macOS"
project.ext.appName = "MZmine"
project.ext.appleID = "[email protected]"
getLogger().lifecycle('Checking macOS system variables...')
project.ext.macSigning = true
project.ext.developerID = System.getenv("MACOS_APP_IDENTITY_ID")
if (developerID == null || developerID.isBlank()) {
getLogger().warn('System variable MACOS_APP_IDENTITY_ID is not set for signing.')
project.ext.macSigning = false
}
project.ext.appleIDPassword = System.getenv("MACOS_APPLE_ID_PWD")
if (appleIDPassword == null || appleIDPassword.isBlank()) {
getLogger().warn('System variable MACOS_APPLE_ID_PWD is not set for signing.')
project.ext.macSigning = false
}
project.ext.appleTeamID = System.getenv("MACOS_APP_IDENTITY_TEAM_ID")
if (appleTeamID == null || appleTeamID.isBlank()) {
getLogger().warn('System variable MACOS_APP_IDENTITY_TEAM_ID is not set for signing.')
project.ext.macSigning = false
}
project.ext.imageDir = buildDir.toPath().resolve('jpackage').resolve('MZmine.app').toFile()
project.ext.jarsDir = imageDir.toPath().resolve('Contents').resolve('app').toFile()
}
println "OS detected as " + project.ext.osSuffix
repositories {
// TODO change to mavenCentral()
// mavenLocal()
maven { url = "https://repo.maven.apache.org/maven2" }
// local libraries
maven { url = "file://" + projectDir + "/src/main/lib" }
// For jmztab 3.0.9+ (https://github.com/PRIDE-Utilities/jmzTab)
maven { url = "https://lifstools.jfrog.io/artifactory/ebi-tools/" }
// For jmzml, etc.
maven { url = "https://www.ebi.ac.uk/Tools/maven/repos/content/groups/ebi-repo/" }
// For SIRIUS ID modules
maven { url = "https://bio.informatik.uni-jena.de/repository/libs-oss/" }
maven { url = "https://jitpack.io" }
maven { url = "https://www.xypron.de/repository/" }
// For cpdetector
maven { url = "https://nexus.nuiton.org/nexus/content/groups/releases/" }
// // For jimzml
// maven { url = "https://mvnrepository.com/artifact/com.alanmrace/jimzmlparser" }
}
ext {
msdkVersion = "0.0.27"
cdkVersion = "2.5"
jmztabVersion = "3.0.9"
swaggerVersion = "1.5.22"
okhttpVersion = "2.7.5"
guavaVersion = "30.1-jre"
slf4jVersion = '1.7.32'
poiVersion = '5.0.0'
batikVersion = '1.14'
controlsfxVersion = '11.1.1'
jmzTabmVersion = "1.0.6"
jnaVersion = '5.12.1'
junitversion = '5.9.1'
mockitoversion = '4.9.0'
jacksonVersion = '2.13.4'
// UUID for upgrades of this package on Windows. Generated by https://www.uuidgenerator.net
win_uuid = "896e9c2d-6db8-4259-a1af-1b5f8112d1e1"
}
dependencies {
// MZmine version parsing
implementation 'com.vdurmont:semver4j:3.1.0'
// implementation "org.graphstream:gs-core:2.0"
// use patched version via jitpack from https://github.com/robinschmid/gs-core/tree/patch-1
implementation "com.github.robinschmid:gs-core:45504f632f"
implementation "org.graphstream:gs-ui-javafx:2.0"
implementation "org.graphstream:gs-algo:2.0"
implementation "org.jfree:jfreechart:1.5.3"
implementation "org.jfree:org.jfree.chart.fx:2.0.1"
implementation "org.jfree:org.jfree.fxgraphics2d:2.1.1"
implementation "org.jfree:org.jfree.svg:4.1"
implementation "org.jfree:org.jfree.pdf:2.0"
implementation "com.google.guava:guava:$guavaVersion"
implementation "org.apache.commons:commons-math:2.2"
implementation "edu.ucar:netcdf4:4.5.5"
implementation "org.ostermiller:utils:1.07.00"
implementation 'org.jetbrains:annotations:22.0.0'
implementation 'nz.ac.waikato.cms.weka:weka-dev:3.9.6'
implementation 'net.sourceforge.jmol:jmol:14.31.10'
implementation "org.slf4j:slf4j-api:$slf4jVersion"
implementation "org.slf4j:slf4j-jdk14:$slf4jVersion"
implementation "org.apache.poi:poi:$poiVersion"
implementation "org.apache.poi:poi-ooxml:$poiVersion"
implementation "org.openscience.cdk:cdk-core:$cdkVersion"
implementation "org.openscience.cdk:cdk-io:$cdkVersion"
implementation "org.openscience.cdk:cdk-standard:$cdkVersion"
implementation "org.openscience.cdk:cdk-silent:$cdkVersion"
implementation "org.openscience.cdk:cdk-formula:$cdkVersion"
implementation "org.openscience.cdk:cdk-sdg:$cdkVersion"
implementation "org.openscience.cdk:cdk-renderbasic:$cdkVersion"
implementation "org.openscience.cdk:cdk-renderawt:$cdkVersion"
implementation "org.openscience.cdk:cdk-data:$cdkVersion"
implementation "org.openscience.cdk:cdk-interfaces:$cdkVersion"
implementation "org.openscience.cdk:cdk-smiles:$cdkVersion"
implementation "uk.ac.ebi.jmzml:jmzml:1.7.11"
implementation "org.postgresql:postgresql:9.3-1102-jdbc41"
implementation "mysql:mysql-connector-java:5.1.34"
implementation "org.rsc.chemspider:chemspider-api:1.0.0"
implementation "org.nuiton.thirdparty:REngine:1.8-5"
implementation "org.nuiton.thirdparty:Rserve:1.8-5"
implementation 'com.github.jbytecode:RCaller:4.0.2'
implementation "mzmine:jmprojection:1.0"
implementation "mzmine:gslibml:0.0.1"
implementation "uk.ac.ebi.pride:jmztab-modular-model:$jmztabVersion"
implementation "uk.ac.ebi.pride:jmztab-modular-util:$jmztabVersion"
implementation 'org.apache.xmlgraphics:fop:2.6'
implementation "org.freehep:freehep-graphicsio-emf:2.4"
implementation "io.github.msdk:msdk-io-mzml:$msdkVersion"
implementation "io.github.msdk:msdk-io-netcdf:$msdkVersion"
implementation "io.github.msdk:msdk-featuredetection-adap3d:$msdkVersion"
implementation group: 'net.sf.trove4j', name: 'trove4j', version: '3.0.3'
implementation 'org.eclipse.parsson:jakarta.json:1.1.0'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
implementation group: 'org.openscience.cdk', name: 'cdk-bundle', version: '2.7.1'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5'
// implementation "io.github.msdk:msdk-id-sirius:$msdkVersion"
implementation "org.du-lab.adap:adap:4.1.10"
implementation "org.xerial:sqlite-jdbc:3.40.0.0"
implementation "gnf:clustering:20210422"
implementation 'it.unimi.dsi:fastutil:8.5.6'
implementation 'com.itextpdf:itextpdf:5.5.13.2'
implementation 'org.apache.xmlgraphics:xmlgraphics-commons:2.6'
implementation "org.apache.xmlgraphics:batik-util:$batikVersion"
implementation "org.apache.xmlgraphics:batik-transcoder:$batikVersion"
implementation "org.apache.xmlgraphics:batik-codec:$batikVersion"
implementation "org.apache.xmlgraphics:batik-ext:$batikVersion"
implementation "org.apache.xmlgraphics:batik-awt-util:$batikVersion"
implementation "org.apache.xmlgraphics:batik-dom:$batikVersion"
implementation "org.apache.xmlgraphics:batik-svggen:$batikVersion"
implementation "org.apache.xmlgraphics:batik-svg-dom:$batikVersion"
implementation "org.apache.xmlgraphics:batik-anim:$batikVersion"
implementation "org.apache.xmlgraphics:batik-rasterizer:$batikVersion"
implementation "org.apache.xmlgraphics:batik-swing:$batikVersion"
implementation "org.apache.xmlgraphics:batik-gui-util:$batikVersion"
implementation "org.apache.xmlgraphics:batik-ttf2svg:$batikVersion"
implementation "org.apache.xmlgraphics:batik-parser:$batikVersion"
implementation "net.sf.epsgraphics:epsgraphics:1.2"
implementation "com.miglayout:miglayout:3.7.4"
implementation "javax.xml.bind:jaxb-api:2.3.1"
implementation "com.sun.xml.bind:jaxb-core:2.3.0.1"
implementation "com.sun.xml.bind:jaxb-impl:2.3.2"
implementation "javax.activation:javax.activation-api:1.2.0"
implementation "javax.mail:javax.mail-api:1.6.2"
implementation "io.swagger:swagger-annotations:$swaggerVersion"
implementation "com.squareup.okhttp:okhttp:$okhttpVersion"
implementation "com.squareup.okhttp:logging-interceptor:$okhttpVersion"
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'io.gsonfire:gson-fire:1.8.5'
implementation "org.threeten:threetenbp:1.3.8"
implementation 'org.kordamp.ikonli:ikonli-javafx:12.3.1'
implementation 'org.kordamp.ikonli:ikonli-bootstrapicons-pack:12.3.1'
implementation "org.controlsfx:controlsfx:$controlsfxVersion"
implementation 'org.json:json:20211205'
implementation "com.github.oshi:oshi-core:4.5.2"
// because the version that is pulled by SIRIUS crashes
implementation "de.isas.mztab:jmztabm-io:$jmzTabmVersion"
implementation 'net.java.dev.jna:jna:$jnaVersion'
implementation 'com.github.robinschmid:jimzMLParser:mzmine_local_obo-SNAPSHOT'
implementation group: 'commons-cli', name: 'commons-cli', version: '1.4'
implementation "net.csibio.aird:aird-sdk:1.1.6.1"
implementation "com.github.yannrichet:JMathPlot:1.0.1"
// jackson for json parsing
implementation "com.fasterxml.jackson.core:jackson-core:$jacksonVersion"
implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitversion"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitversion"
testImplementation "org.mockito:mockito-inline:$mockitoversion"
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoversion"
// https://blog.gradle.org/log4j-vulnerability
constraints {
implementation("org.apache.logging.log4j:log4j-core") {
version {
strictly("[2.17, 3[")
prefer("2.17.1")
}
because("CVE-2021-44228, CVE-2021-45046, CVE-2021-45105: Log4j vulnerable to remote code execution and other critical security vulnerabilities")
}
}
}
/*
* Remove the xml-apis dependencies to avoid a compilation error in Eclipse.
* The org.w3c.dom package is present in the java.xml module as well as in these dependencies.
* That is illegal (https://bugs.eclipse.org/bugs/show_bug.cgi?id=536928).
*/
configurations.all {
exclude group: "xml-apis", module: "xml-apis"
exclude group: "xml-apis", module: "xml-apis-ext"
exclude group: "xom", module: "xom"
exclude group: "ch.qos.logback", module: "logback-core"
exclude group: "ch.qos.logback", module: "logback-classic"
exclude group: "gurobi", module: "gurobi-linux64"
exclude group: "cplex", module: "cplex"
exclude group: "org.checkerframework", module: "checker-qual"
exclude group: "javax.annotation", module: "javax.annotation-api"
}
/*
* Include JavaFX modules
*/
javafx {
// currently there is an issue with the jfx>16 and the feature table on windows
// scrolling lets the table jump
// jfx19 fixes remote connection issues though
version = OperatingSystem.current().isMacOsX() ? "19" : "16"
modules = ["javafx.controls",
"javafx.swing",
"javafx.fxml",
"javafx.web",
"javafx.graphics"]
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
options.compilerArgs += ['--enable-preview']
}
tasks.withType(Test) {
jvmArgs += "--enable-preview"
}
tasks.withType(JavaExec) {
jvmArgs += '--enable-preview'
}
/*
* Set the basic Java runtime parameters (heap size etc.)
*/
application {
mainClass.set("io.github.mzmine.main.MZmineCore")
applicationName = "MZmine"
}
/*
* Build the JVM runtime using jlink
*/
runtime {
options = ["--compress=2", "--vm=server", "--no-header-files", "--no-man-pages", "--output", "jre/jre"]
modules = ["java.desktop",
"java.logging",
"java.net.http",
"java.rmi",
"java.sql",
"java.datatransfer",
"java.management",
"java.xml",
"java.xml.crypto",
"jdk.xml.dom",
"java.naming",
"java.transaction.xa",
"java.scripting",
"java.compiler",
"jdk.jsobject",
"jdk.jfr",
"java.security.sasl",
"java.security.jgss",
"jdk.unsupported",
"jdk.unsupported.desktop"]
jpackage {
if (OperatingSystem.current().isWindows()) {
// The WiX toolset must be installed, see https://wixtoolset.org/releases/
installerType = "msi"
installerName = "MZmine_Windows_installer"
// additional options for jpackage
imageOptions = ["--icon", "src/main/resources/MZmineIcon.ico",
"--add-launcher", "MZmine_console=gradle/win_console_launcher.properties"
]
installerOptions = ["--win-menu",
"--win-menu-group", "MZmine",
"--win-shortcut",
"--win-dir-chooser",
"--win-upgrade-uuid", "$win_uuid",
"--license-file", "LICENSE.txt"
]
}
if (OperatingSystem.current().isMacOsX()) {
installerType = "dmg"
// additional options for jpackage
// only sign if all needed information is present
if (!macSigning) {
imageOptions = ["--icon", "src/main/resources/MZmineIcon.icns"]
installerOptions = ["--license-file", "LICENSE.txt"]
} else {
imageOptions = ["--icon", "src/main/resources/MZmineIcon.icns",
"--mac-sign",
"--mac-package-name", appName,
"--mac-package-identifier", "io.github.mzmine.main",
"--mac-signing-key-user-name", developerID,
"--verbose"
]
installerOptions = [
"--license-file", "LICENSE.txt",
"--mac-sign",
"--mac-signing-key-user-name", developerID,
]
}
installerName = "MZmine_macOS_installer"
}
if (OperatingSystem.current().isLinux()) {
// leave installer type empty to generate all that match
// for rpm, rpmbuild and rpm tools need to be installed, installerType needs to be set to "rpm"
// installerType = "deb"
// additional options for jpackage
imageOptions = ["--icon", "src/main/resources/MZmineIcon.png"]
installerOptions = ["--linux-shortcut",
"--linux-menu-group", "MZmine",
"--license-file", "LICENSE.txt",
"--linux-deb-maintainer", "[email protected]"]
installerName = "MZmine_Linux_installer"
}
imageName = "MZmine"
jvmArgs = ["-showversion",
"-XX:MaxHeapFreeRatio=100",
"-XX:InitialRAMPercentage=30",
"-XX:MinRAMPercentage=80",
"-XX:MaxRAMPercentage=80",
"-enableassertions",
"-Djava.util.logging.config.class=io.github.mzmine.main.MZmineLoggingConfiguration",
"--enable-preview"]
}
}
task signApp(dependsOn: jpackage) {
if (OperatingSystem.current().isMacOsX() && macSigning) {
doLast {
Path entitlementsPth = getRootProject().getProjectDir().toPath().resolve("gradle")
.resolve("macos.entitlements").toAbsolutePath()
// Define codesign command
Consumer<Path> codesign = (Path p) -> exec {
commandLine(["codesign", "--deep", "--force", "--timestamp", "-s", "${developerID}", "--options",
"runtime", "--entitlements", "${entitlementsPth}", "-f", "-v", "${p}"])
}
getLogger().lifecycle('Deleting unused "non-notarizable" libraries...')
// Delete unused dependencies of dependencies causing notarization issues
jarsDir.listFiles((FilenameFilter) ((d, n) -> n.startsWith('netlib') || n.startsWith('jblas')
|| n.startsWith('jocl'))).stream().forEach(File::delete)
getLogger().lifecycle("Signing native ThermoRawFileParser...")
// Unzip ThermoRawFileParser.zip
String mzmineJarName = "mzmine3-${semver.version}"
exec { commandLine(['sh', '-c', "cd ${jarsDir} && unzip -q ${mzmineJarName}.jar -d ${mzmineJarName}"]) }
exec {
commandLine(['sh', '-c', "cd ${jarsDir}/${mzmineJarName}/vendorlib/thermo && unzip -q " +
"ThermoRawFileParser.zip -d ThermoRawFileParser"])
}
// Sign ThermoRawFileParser content
for (File f : jarsDir.toPath().resolve(mzmineJarName).resolve('vendorlib').resolve('thermo')
.resolve('ThermoRawFileParser').toFile().listFiles()) {
// ThermoRawFileParserMac is signed by jpackage
if (f.toPath().toString().endsWith('ThermoRawFileParserMac')) {
continue
}
codesign(f.toPath())
}
// Zip ThermoRawFileParser back
exec {
commandLine(['sh', '-c', "cd ${jarsDir}/${mzmineJarName}/vendorlib/thermo " +
"&& zip -rq ThermoRawFileParser.zip ThermoRawFileParser && rm -rf ThermoRawFileParser"])
}
exec { commandLine(['sh', '-c', "cd ${jarsDir} && jar cvf ${mzmineJarName}.jar -C ${mzmineJarName}/ ."]) }
exec { commandLine(['sh', '-c', "rm -rf ${jarsDir}/${mzmineJarName}"]) }
getLogger().lifecycle("Signing native libraries...")
// Traverse over whole .app and sign each native library
for (Path nativeLib : Files.find(imageDir.toPath(), 999, (p, bfa) // 999 is a recursive depth
-> bfa.isRegularFile() && p.getFileName().toString().matches(".*\\.dylib|.*\\.so|.*\\.dll|.*\\.a|.*\\.lib"))) {
getLogger().lifecycle("Signing native lib '${nativeLib}'")
codesign(nativeLib.toAbsolutePath())
}
getLogger().lifecycle("Signing libraires nested in jars...")
// Define native libraries nested in jars that are to be signed
ArrayList<Path> jarNestedLibs = [
FileSystems.newFileSystem(imageDir.toPath().resolve("Contents").resolve("app")
.resolve("jna-inchi-darwin-x86-64-1.0.1.jar")).getPath("darwin-x86-64/libjnainchi.dylib"),
FileSystems.newFileSystem(imageDir.toPath().resolve("Contents").resolve("app")
.resolve("jna-inchi-darwin-aarch64-1.0.1.jar")).getPath("darwin-aarch64/libjnainchi.dylib"),
FileSystems.newFileSystem(imageDir.toPath().resolve("Contents").resolve("app")
.resolve("adap-4.1.10.jar")).getPath("lib/macosx-x86_64/libadapwavelet.so"),
]
// Move each library out of .jar, sign it, and put it back
Path tmpJarsDir = getBuildDir().toPath().resolve("tmp").resolve("jarLibs")
Files.createDirectories(tmpJarsDir)
for (Path inJar : jarNestedLibs) {
Path tmpPath = tmpJarsDir.resolve(inJar.getFileName().toString())
Files.copy(inJar, tmpPath, StandardCopyOption.REPLACE_EXISTING)
codesign(tmpPath.toAbsolutePath())
Files.copy(tmpPath, inJar, StandardCopyOption.REPLACE_EXISTING)
inJar.fileSystem.close()
}
getLogger().lifecycle("Signing jars...")
// Traverse over entire .app and sign each .jar
for (Path jar : Files.find(imageDir.toPath(), 999, (p, bfa) // 999 is a recursive depth
-> bfa.isRegularFile() && p.getFileName().toString().matches(".*\\.jar"))) {
getLogger().lifecycle("Signing jar '${jar}'")
codesign(jar.toAbsolutePath())
}
// Sign .app directory
getLogger().lifecycle("Signing .app directory...")
codesign(imageDir.toPath())
getLogger().lifecycle("Zipping .app directory...")
exec {
commandLine(['sh', '-c', "cd ${buildDir.toPath().resolve('jpackage')} " +
"&& zip -rq MZmine_macOS_portable.zip MZmine.app"])
}
}
}
}
task notarizeApp(dependsOn: signApp) {
if (OperatingSystem.current().isMacOsX() && macSigning) {
doLast {
getLogger().lifecycle("Notarizing .app...")
ExecResult execResult = exec {
commandLine(["xcrun", "notarytool", "submit", "--wait", "--apple-id", "${appleID}",
"--password", "${appleIDPassword}", "--team-id", "${appleTeamID}",
"${buildDir.toPath().resolve('jpackage').resolve('MZmine_macOS_portable.zip')}"])
}
int returnCode = execResult.getExitValue()
if (returnCode != 0) {
throw new GradleException("Error ${returnCode} during notarization.")
}
getLogger().lifecycle("Stapling .app...")
execResult = exec {
commandLine(["xcrun", "stapler", "staple", "${imageDir.toPath()}"])
}
returnCode = execResult.getExitValue()
if (returnCode != 0) {
throw new GradleException("Error ${returnCode} during stapling.")
}
}
}
}
notarizeApp.mustRunAfter(signApp)
/*
* This is important in order to copy all .java, .fxml, and help files into the final MZmine jar.
* The .java files are only for people who want to check the source codes.
* But the .fxml and help files are required for the GUI.
*/
jar {
sourceSets.main.resources.srcDirs += ["src/main/java"]
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
task copyTestResources(type: Copy) {
from "${projectDir}/src/test/resources"
into "${buildDir}/classes/test"
}
processTestResources.dependsOn copyTestResources