-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
735 lines (613 loc) · 22.3 KB
/
build.gradle.kts
File metadata and controls
735 lines (613 loc) · 22.3 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
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
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.internal.extensions.stdlib.toDefaultLowerCase
import java.nio.file.Files
import java.nio.file.Paths
import kotlin.io.path.absolutePathString
import kotlin.io.path.createTempDirectory
import kotlin.io.path.isExecutable
plugins {
`java-library`
application
jacoco
}
enum class OS {
MAC, WINDOWS, LINUX
}
val currentOS = when {
System.getProperty("os.name").lowercase().contains("mac") -> OS.MAC
System.getProperty("os.name").lowercase().contains("windows") -> OS.WINDOWS
else -> OS.LINUX
}
val isNotarizing = System.getenv("NOTARIZE") != null || gradle.startParameter.taskNames.find { s ->
s.lowercase().contains("notarize") || s.lowercase().contains("jpackage") || s.lowercase().contains("staple")
} != null
val provisionprofileDir = layout.projectDirectory
.dir("mac-resources")
.dir("provisionprofile")
.dir(
if (isNotarizing) {
"notarization"
} else {
"app_store"
}
)
// TODO: Replace the below with the name of your 'Developer ID Application' cert which you can get from https://developer.apple.com/account/resources/certificates/list
val macDeveloperApplicationCertName = if (isNotarizing) {
"Developer ID Application: Tanin Na Nakorn (S6482XAL5E)"
} else {
"3rd Party Mac Developer Application: Tanin Na Nakorn (S6482XAL5E)"
}
fun getSecret(envKey: String, filePath: String): String? {
if (System.getenv(envKey) != null) {
return System.getenv(envKey)
}
try {
return project.file(filePath).readText().trim()
} catch (e: Exception) {
return null
}
}
val appleEmail = getSecret("APPLE_EMAIL", "./secret/APPLE_EMAIL")
val appleAppSpecificPassword = getSecret("APPLE_APP_SPECIFIC_PASSWORD","./secret/APPLE_APP_SPECIFIC_PASSWORD")
val appleTeamId = "S6482XAL5E"
group = "tanin.javaelectron"
val appName = "JavaElectron"
val packageIdentifier = "tanin.javaelectron.macos.app"
version = "1.1"
val internalVersion = "1.1.1"
description = "Build cross-platform desktop apps with Java, JavaScript, HTML, and CSS"
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
withSourcesJar()
sourceSets {
main {
resources {
srcDir("build/compiled-frontend-resources")
}
}
}
}
tasks.register<Exec>("compileWindowsApi") {
onlyIf {
currentOS == OS.WINDOWS
}
group = "build"
description = "Compile C code and output the dll to the resource directory."
commandLine(
"gcc",
"-shared",
"-o",
"./src/main/resources/native/WindowsApi.dll",
"./src/main/c/WindowsApi.c",
"-lcomdlg32",
"-lgdi32"
)
}
tasks.register<Exec>("compileSwift") {
onlyIf {
System.getProperty("os.name").lowercase().contains("mac")
}
group = "build"
description = "Compile Swift code and output the dylib to the resource directory."
val inputFile = layout.projectDirectory.file("src/main/swift/MacOsApi.swift").asFile
val outputFile = layout.projectDirectory.file("src/main/resources/native/libMacOsApi.dylib").asFile
println("Compiling Swift code to $outputFile")
commandLine(
"swiftc",
"-emit-library",
inputFile.absolutePath,
"-target",
"arm64-apple-macos11",
"-o",
outputFile.absolutePath,
)
}
tasks.named<JavaCompile>("compileJava") {
if (currentOS == OS.MAC) {
dependsOn("compileSwift")
} else if (currentOS == OS.WINDOWS) {
dependsOn("compileWindowsApi")
}
options.compilerArgs.addAll(listOf(
"--add-exports",
"java.base/sun.security.x509=ALL-UNNAMED",
"--add-exports",
"java.base/sun.security.tools.keytool=ALL-UNNAMED",
))
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
reports {
xml.required = true
csv.required = false
html.outputLocation = layout.buildDirectory.dir("jacocoHtml")
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("com.renomad:minum:8.3.2")
implementation("net.java.dev.jna:jna:5.14.0")
implementation("com.eclipsesource.minimal-json:minimal-json:0.9.5")
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("org.seleniumhq.selenium:selenium-java:4.36.0")
}
tasks.named<Test>("test") {
useJUnitPlatform()
maxHeapSize = "1G"
testLogging {
events("started", "passed", "skipped", "failed")
showStandardStreams = true
showStackTraces = true
showExceptions = true
showCauses = true
exceptionFormat = TestExceptionFormat.FULL
}
}
var mainClassName = "tanin.javaelectron.Main"
application {
mainClass.set(mainClassName)
applicationDefaultJvmArgs = buildList {
if (currentOS == OS.MAC) {
add("-XstartOnFirstThread")
}
add("--add-exports")
add("java.base/sun.security.x509=ALL-UNNAMED")
add("--add-exports")
add("java.base/sun.security.tools.keytool=ALL-UNNAMED")
}
}
tasks.jar {
manifest.attributes["Main-Class"] = mainClassName
}
val executableExt = if (currentOS == OS.WINDOWS) ".cmd" else ""
tasks.register<Exec>("compileTailwind") {
environment("NODE_ENV", "production")
executable = "./node_modules/.bin/postcss${executableExt}"
args = listOf(
"./frontend/stylesheets/tailwindbase.css",
"--config",
".",
"--output",
"./build/compiled-frontend-resources/assets/stylesheets/tailwindbase.css"
)
}
tasks.register<Exec>("compileSvelte") {
environment("NODE_ENV", "production")
environment("ENABLE_SVELTE_CHECK", "true")
executable = "./node_modules/.bin/webpack${executableExt}"
args = listOf(
"--config",
"./webpack.config.js",
"--output-path",
"./build/compiled-frontend-resources/assets",
"--mode",
"production"
)
}
tasks.processResources {
dependsOn("compileTailwind")
dependsOn("compileSvelte")
}
tasks.named("sourcesJar") {
dependsOn("compileTailwind")
dependsOn("compileSvelte")
}
// For CI validation.
tasks.register("printInternalVersion") {
doLast {
print(internalVersion)
}
}
tasks.register("copyDependencies", Copy::class) {
from(configurations.runtimeClasspath).into(layout.buildDirectory.dir("jmods"))
}
tasks.register("copyJar", Copy::class) {
from(tasks.jar).into(layout.buildDirectory.dir("jmods"))
}
private fun maskSecret(commandLine: String): String {
return commandLine.split(" ").joinToString(" ") { arg ->
val sanitized = arg.toDefaultLowerCase()
if (sanitized.contains("password") || sanitized.contains("secret")) {
"<REDACTED>"
} else {
arg
}
}
}
private fun runCmd(currentDir: File, vararg args: String): String {
println("Executing command: ${maskSecret(args.joinToString(" "))} at ${currentDir.absolutePath}")
val output = StringBuilder()
val process = ProcessBuilder(*args)
.directory(currentDir)
.start()
// Print stdout
process.inputStream.bufferedReader().use { reader ->
reader.lines().forEach {
println("stdout: $it")
output.appendLine(it)
}
}
// Print stderr
process.errorStream.bufferedReader().use { reader ->
reader.lines().forEach { println("stderr: $it") }
}
val retVal = process.waitFor()
if (retVal != 0) {
throw IllegalStateException("Command execution failed with return value: $retVal")
}
return output.toString()
}
private fun runCmd(vararg args: String): String {
return runCmd(layout.projectDirectory.asFile, *args)
}
enum class EntitlementType {
NoEntitlement,
MainEntitlement,
RuntimeEntitlement
}
private fun codesign(file: File, entitlementType: EntitlementType = EntitlementType.NoEntitlement) {
if (currentOS == OS.MAC) {
val entitlementArgs = when (entitlementType) {
EntitlementType.NoEntitlement -> emptyList()
EntitlementType.MainEntitlement -> listOf("--entitlements", "entitlements.plist")
EntitlementType.RuntimeEntitlement -> listOf("--entitlements", "runtime-entitlements.plist")
}
runCmd(
*(listOf(
"codesign",
"-vvvv",
"--options",
"runtime",
) + entitlementArgs + listOf(
"--timestamp",
"--force",
"--sign",
macDeveloperApplicationCertName,
file.absolutePath,
)).toTypedArray()
)
}
}
private fun isCodesignable(file: File): Boolean {
if (currentOS == OS.MAC) {
val excludedExtensions = setOf("so", "a", "xml")
return file.extension == "dylib" ||
file.extension == "jnilib" ||
(!excludedExtensions.contains(file.extension) && file.toPath().isExecutable())
} else if (currentOS == OS.WINDOWS) {
return file.extension == "dll"
} else {
throw Exception("Unsupported OS: $currentOS")
}
}
private fun isValidLibFile(file: File): Boolean {
if (currentOS == OS.MAC) {
return !(
file.absolutePath.contains("darwin-x86-64") || // for libjnidispatch.jnilib
file.absolutePath.contains("x86_64") // for liblz4-java.dylib
)
} else if (currentOS == OS.WINDOWS) {
return !(
file.absolutePath.endsWith("win32-aarch64\\jnidispatch.dll") ||
file.absolutePath.endsWith("win32-x86\\jnidispatch.dll")
)
} else {
throw Exception("Unsupported OS: $currentOS")
}
}
private fun codesignInJar(jarFile: File, nativeLibPath: File) {
val tmpDir = createTempDirectory("codesignLibsInJarsTask").toFile()
runCmd("unzip", "-q", jarFile.absolutePath, "-d", tmpDir.absolutePath)
tmpDir.walk()
.filter { it.isFile && isCodesignable(it) }
.forEach { libFile ->
codesign(libFile)
if (isValidLibFile(libFile)) {
runCmd("cp", libFile.absolutePath, nativeLibPath.absolutePath)
}
runCmd(
"jar",
"-uvf",
jarFile.absolutePath,
"-C", tmpDir.absolutePath,
libFile.relativeToOrSelf(tmpDir).path
)
}
tmpDir.deleteRecursively()
}
tasks.register("codesignLibsInJars") {
dependsOn("copyDependencies", "copyJar")
inputs.files(tasks.named("copyJar").get().outputs.files)
val resourceNativePath = layout.buildDirectory.file("resources-native").get().asFile
val nativeLibPath = layout.buildDirectory.file("resources-native").get().asFile.resolve("app/resources")
doLast {
resourceNativePath.deleteRecursively()
nativeLibPath.mkdirs()
inputs.files.forEach { file ->
println("Process: ${file.absolutePath}")
if (file.isDirectory) {
file.walk()
.filter { it.isFile && it.extension == "jar" }
.forEach { codesignInJar(it, nativeLibPath) }
} else if (file.extension == "jar") {
codesignInJar(file, nativeLibPath)
}
}
}
}
private fun codesignDir(dir: File) {
dir.walk()
.filter { it.isFile && isCodesignable(it) }
.forEach { libFile ->
codesign(libFile, EntitlementType.NoEntitlement)
}
}
private fun removeQuarantine(file: File) {
try {
runCmd("/usr/bin/xattr", "-d", "com.apple.quarantine", file.absolutePath)
} catch (_: IllegalStateException) {}
}
tasks.register("macosCodesignProvisionprofile") {
onlyIf { currentOS == OS.MAC }
doLast {
removeQuarantine(provisionprofileDir.file("embedded.provisionprofile").asFile)
codesign(provisionprofileDir.file("embedded.provisionprofile").asFile)
removeQuarantine(provisionprofileDir.file("runtime.provisionprofile").asFile)
codesign(provisionprofileDir.file("runtime.provisionprofile").asFile)
}
}
tasks.register<Exec>("jlink") {
dependsOn("assemble", "codesignLibsInJars", "macosCodesignProvisionprofile")
val jlinkBin = Paths.get(System.getProperty("java.home"), "bin", "jlink")
inputs.files(tasks.named("copyJar").get().outputs.files)
outputs.file(layout.buildDirectory.file("jlink"))
outputs.files.singleFile.deleteRecursively()
commandLine(
jlinkBin,
"--ignore-signing-information",
"--strip-native-commands", "--no-header-files", "--no-man-pages", "--strip-debug",
"-p", inputs.files.singleFile.absolutePath,
"--module-path", "${System.getProperty("java.home")}/jmods;${inputs.files.singleFile.absolutePath}",
"--add-modules", "java.base,java.desktop,java.logging,java.net.http,java.security.jgss,jdk.unsupported,java.security.sasl,jdk.crypto.ec,jdk.crypto.cryptoki",
"--output", outputs.files.singleFile.absolutePath,
)
}
tasks.register("prepareInfoPlist") {
onlyIf { currentOS == OS.MAC }
doLast {
val template = layout.projectDirectory.file("mac-resources/Info.plist.template").asFile.readText()
val content = template
.replace("{{VERSION}}", version.toString())
.replace("{{INTERNAL_VERSION}}", internalVersion)
.replace("{{PACKAGE_IDENTIFIER}}", packageIdentifier)
.replace("{{APP_NAME}}", appName)
layout.projectDirectory.file("mac-resources/Info.plist").asFile.writeText(content)
}
}
tasks.register("bareJpackage") {
dependsOn("jlink", "prepareInfoPlist")
val javaHome = System.getProperty("java.home")
val jpackageBin = Paths.get(javaHome, "bin", "jpackage")
val runtimeImage = tasks.named("jlink").get().outputs.files.singleFile
val modulePath = tasks.named("copyJar").get().outputs.files.singleFile
inputs.files(runtimeImage, modulePath)
val outputDir = layout.buildDirectory.dir("bare-jpackage")
val outputFile = if (currentOS == OS.MAC) {
outputDir.get().asFile.resolve("${appName}-$version.dmg")
} else if (currentOS == OS.WINDOWS) {
outputDir.get().asFile.resolve("${appName}-$version.msi")
} else {
throw Exception("Unsupported OS: $currentOS")
}
outputs.file(outputFile)
outputDir.get().asFile.deleteRecursively()
doLast {
// -XstartOnFirstThread is required for MacOS
val maybeStartOnFirstThread = if (currentOS == OS.MAC) {
"-XstartOnFirstThread"
} else {
""
}
val javaOptionsArg = listOf(
"--java-options",
// -Djava.library.path=$APPDIR/resources is needed because we put the needed dylibs, jnilibs, and dlls there.
"$maybeStartOnFirstThread -Djava.electron.packaged=true -Djava.library.path=\$APPDIR/resources --add-exports java.base/sun.security.x509=ALL-UNNAMED --add-exports java.base/sun.security.tools.keytool=ALL-UNNAMED"
)
val baseArgs = listOf(
"--name", appName,
"--app-version", version.toString(),
"--main-jar", modulePath.resolve("${project.name}-$version.jar").absolutePath,
"--main-class", mainClassName,
"--runtime-image", runtimeImage.absolutePath,
"--input", modulePath.absolutePath,
"--dest", outputDir.get().asFile.absolutePath,
"--app-content", layout.buildDirectory.file("resources-native").get().asFile.resolve("app").absolutePath,
) + javaOptionsArg
val platformSpecificArgs = if (currentOS == OS.MAC) {
listOf(
"--mac-package-identifier",
packageIdentifier,
"--mac-package-name",
appName,
"--mac-sign",
"--mac-app-store",
"--mac-signing-key-user-name",
macDeveloperApplicationCertName,
"--mac-entitlements",
"entitlements.plist",
"--resource-dir",
layout.projectDirectory.dir("mac-resources").asFile.absolutePath,
"--app-content",
provisionprofileDir.file("embedded.provisionprofile").asFile.absolutePath,
)
} else if (currentOS == OS.WINDOWS) {
listOf(
"--type", "msi",
"--win-menu",
"--win-shortcut"
)
} else {
throw Exception("Unsupported OS: $currentOS")
}
runCmd(
*((listOf(jpackageBin.absolutePathString())
+ baseArgs + platformSpecificArgs).toTypedArray())
)
}
}
tasks.register("jpackageForMac") {
onlyIf { currentOS == OS.MAC }
dependsOn("bareJpackage")
inputs.file(tasks.named("bareJpackage").get().outputs.files.singleFile)
val outputAppDir = layout.buildDirectory.dir("extracted-dmg").get().asFile
val outputAppFile = outputAppDir.resolve("$appName.app")
val outputDmgDir = layout.buildDirectory.dir("dmg").get().asFile
val outputDmgFile = outputDmgDir.resolve(inputs.files.singleFile.name)
outputs.dir(outputAppFile)
outputs.file(outputDmgFile)
doLast {
outputAppDir.deleteRecursively()
outputAppDir.mkdirs()
var volumeName: String? = null
val output = runCmd("/usr/bin/hdiutil", "attach", "-readonly", inputs.files.singleFile.absolutePath)
volumeName = output.lines()
.firstNotNullOfOrNull { line -> Regex("/Volumes/([^ ]*)").find(line)?.groupValues?.get(1) }
println("Found /Volumes/$volumeName/")
if (volumeName == null) {
throw Exception("Unable to extract the volumn name from the hdiutil command. Output: $output")
}
runCmd("cp", "-R", "/Volumes/$volumeName/.", outputAppFile.parentFile.absolutePath)
runCmd("/usr/bin/hdiutil", "detach", "/Volumes/$volumeName")
runCmd("/usr/bin/open", outputAppFile.parentFile.absolutePath)
// Prepare runtime
Files.copy(
provisionprofileDir.file("runtime.provisionprofile").asFile.toPath(),
outputAppFile.resolve("Contents/runtime/Contents/embedded.provisionprofile").toPath()
)
codesignDir(outputAppFile.resolve("Contents/runtime"))
codesign(
outputAppFile.resolve("Contents/runtime/Contents/Home/lib/jspawnhelper"),
EntitlementType.RuntimeEntitlement
)
codesign(outputAppFile.resolve("Contents/runtime"))
codesign(outputAppFile, EntitlementType.MainEntitlement)
outputDmgDir.deleteRecursively()
outputDmgDir.mkdirs()
// Sometimes we need to unlock the *.app file in order to allow hdiutil to package it into DMG.
// It seems to happen when TestFlight is reusing the file.
runCmd("chflags", "nouchg,noschg", outputAppFile.absolutePath)
runCmd(
"/usr/bin/hdiutil",
"create",
"-ov",
"-srcFolder", outputAppDir.absolutePath,
outputDmgFile.absolutePath,
)
}
}
tasks.register("jpackageForWindows") {
onlyIf { currentOS == OS.WINDOWS }
dependsOn("bareJpackage")
inputs.file(tasks.named("bareJpackage").get().outputs.files.singleFile)
val outputAppDir = layout.buildDirectory.dir("msi").get().asFile
outputs.dir(outputAppDir)
doLast {
outputAppDir.deleteRecursively()
outputAppDir.mkdirs()
runCmd(
File(System.getenv("CODESIGN_TOOL_DIR")).canonicalFile,
"cmd",
"/c",
listOf(
"CodeSignTool.bat",
"sign",
"-input_file_path=${inputs.files.singleFile.absolutePath}",
"-output_dir_path=${outputAppDir.absolutePath}",
"-program_name=${appName}",
"-username=${System.getenv("SSL_COM_USERNAME")}",
"-password=${System.getenv("SSL_COM_PASSWORD")}",
"-totp_secret=${System.getenv("SSL_COM_TOTP_SECRET")}",
)
.joinToString(" ")
.replace("\\", "/")
)
}
}
tasks.register("jpackage") {
dependsOn("bareJpackage", "jpackageForMac", "jpackageForWindows")
}
tasks.register("notarize") {
dependsOn("jpackageForMac")
inputs.file(tasks.named("jpackageForMac").get().outputs.files.filter { it.extension == "dmg" }.first())
doLast {
runCmd(
"/usr/bin/xcrun",
"notarytool",
"submit",
"--wait",
"--apple-id", appleEmail!!,
"--password", appleAppSpecificPassword!!,
"--team-id", appleTeamId,
inputs.files.singleFile.absolutePath,
)
}
}
tasks.register<Exec>("staple") {
dependsOn("notarize")
inputs.file(tasks.named("jpackageForMac").get().outputs.files.filter { it.extension == "dmg" }.first())
commandLine(
"/usr/bin/xcrun",
"stapler",
"staple",
"-v",
inputs.files.singleFile.absolutePath,
)
}
tasks.register<Exec>("convertToPkg") {
dependsOn("jpackageForMac")
val app = tasks.named("jpackageForMac").get().outputs.files.filter { it.extension == "app" }.first()
inputs.dir(app)
outputs.file(layout.buildDirectory.dir("pkg").get().file("Backdoor.pkg"))
commandLine(
"/usr/bin/productbuild",
"--sign", "3rd Party Mac Developer Installer: Tanin Na Nakorn (S6482XAL5E)",
"--component", app.absolutePath,
"/Applications",
outputs.files.singleFile.absolutePath,
)
}
tasks.register("validatePkg") {
dependsOn("convertToPkg")
inputs.file(tasks.named("convertToPkg").get().outputs.files.singleFile)
doLast {
runCmd(
"/usr/bin/xcrun",
"altool",
"--validate-app",
"-f", inputs.files.singleFile.absolutePath,
"-t", "osx",
"-u", appleEmail!!,
"-p", appleAppSpecificPassword!!
)
}
}
tasks.register("uploadPkgToAppStore") {
dependsOn("validatePkg")
inputs.file(tasks.named("convertToPkg").get().outputs.files.singleFile)
doLast {
runCmd(
"/usr/bin/xcrun",
"altool",
"--upload-app",
"-f", inputs.files.singleFile.absolutePath,
"-t", "osx",
"-u", appleEmail!!,
"-p", appleAppSpecificPassword!!
)
}
}