forked from yusuke/samurai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
126 lines (108 loc) · 4.31 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
plugins {
id 'java'
}
group 'one.cafebabe'
version '2021.9'
if (hasProperty('buildScan')) {
buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}
}
def appName = "Samurai"
def jpackageCommand = ['jpackage',
'--verbose',
'--add-modules', 'java.base,java.desktop,java.management,java.naming,jdk.internal.jvmstat,jdk.attach',
'--main-class', "$mainClassName",
'--main-jar', "${projectDir}/samurai-swing/build/libs/samurai-swing-${project.version}.jar",
'--jlink-options', '--strip-native-commands',
'--copyright', 'Yusuke Yamamoto',
'--vendor', 'Yusuke Yamamoto',
'--input', "${projectDir}/samurai-swing/build/",
'--dest', './app/',
'--name', appName,
'--app-version', "${project.version}",
'--java-options']
def javaOptions = """-Xmx128m -Xms128m
-Djdk.attach.allowAttachSelf=true
--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED
--add-exports=jdk.attach/sun.tools.attach=ALL-UNNAMED
--add-opens=java.desktop/javax.swing=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.border=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.colorchooser=ALL-UNNAMED
-XX:ErrorFile=\$USER_HOME/java_error_in_idea_%p.log
-XX:HeapDumpPath=\$USER_HOME/java_error_in_idea.hprof"""
task packageMacApp(type: Exec) {
workingDir './'
commandLine(jpackageCommand +
[javaOptions +' -Dsun.java2d.metal=true --add-opens=java.desktop/com.apple.laf=ALL-UNNAMED',
'--icon', 'package/samurai.icns',
'--type', 'dmg',
// '--mac-app-store',
'--mac-package-identifier', 'one.cafebabe.Samurai',
'--mac-signing-key-user-name', 'Yusuke Yamamoto (TX2Q55XRF7)',
'--mac-sign',
'--mac-entitlements', "${projectDir}/package/entitlement.plist"
]
)
}
tasks.packageMacApp.dependsOn([':samurai-swing:jar'])
task notarizeMacApp(type: Exec) {
workingDir './'
commandLine('xcrun',
'altool', '--notarize-app', '--primary-bundle-id'
, 'one.cafebabe.Samurai', '-u', project.properties['APPLE_DEVELOPER_USER'] ?: "none", '-p', project.properties['APPLE_DEVELOPER_APP_PASSWORD'] ?: "none", '-f', "app/${appName}-${project.version}.dmg"
)
}
task checkMacAppNotarized(type: Exec) {
workingDir './'
commandLine('spctl', '--assess', '-vvvv', '--ignore-cache', '--no-cache', "/Applications/${appName}.app")
}
task stapleMacApp(type: Exec) {
workingDir './'
commandLine('xcrun',
'stapler', 'staple', "app/${appName}-${project.version}.dmg"
)
}
task validateMacApp(type: Exec) {
workingDir './'
commandLine('xcrun',
'altool', '--validate-app', '-u', project.properties['APPLE_DEVELOPER_USER'] ?: "none",
'-p', project.properties['APPLE_DEVELOPER_APP_PASSWORD'] ?: "none",
'-t', 'osx',
'-f', "/Applications/${appName}.app"
)
}
task packageWinApp(type: Exec) {
workingDir './'
commandLine(jpackageCommand +
[javaOptions + ' --add-opens=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED',
'--type', 'app-image',
'--icon', 'package/samurai.ico'
]
)
}
task packageDeb(type: Exec) {
workingDir './'
commandLine(jpackageCommand +
[javaOptions + ' --add-exports=java.desktop/sun.awt.X11=ALL-UNNAMED',
'--license-file', './LICENSE.txt',
'--linux-rpm-license-type', 'ASL 2.0',
'--type', 'deb',
'--icon', './package/samurai-mac.png',
'--linux-shortcut',
]
)
}
task packageRpm(type: Exec) {
workingDir './'
commandLine(jpackageCommand +
[javaOptions + ' --add-exports=java.desktop/sun.awt.X11=ALL-UNNAMED',
'--license-file', './LICENSE.txt',
'--linux-rpm-license-type', 'ASL 2.0',
'--type', 'rpm',
'--icon', './package/samurai-mac.png',
'--linux-shortcut',
]
)
}