forked from freeplane/freeplane
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmac.dist.gradle
More file actions
228 lines (193 loc) · 8.91 KB
/
Copy pathmac.dist.gradle
File metadata and controls
228 lines (193 loc) · 8.91 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
import org.apache.tools.ant.taskdefs.condition.Os
import org.apache.tools.ant.filters.*
def macAppPropertiesFile = file('macapp.properties')
Properties macAppProperties = new Properties()
if (macAppPropertiesFile.exists())
{
macAppProperties.load(new FileInputStream(macAppPropertiesFile))
}
String macosapp_input_dir
task macosapp_extractzip {
mustRunAfter binZip
def zipExtracted = 'build/zip-extracted'
doFirst {
if(! binZip.archiveFile.get().asFile.exists())
ant.fail("File ${binZip.archiveFile.get().asFile.path} not found")
delete zipExtracted
mkdir zipExtracted
copy {
from(zipTree(binZip.archiveFile.get().asFile))
into(zipExtracted)
}
macosapp_input_dir = zipExtracted + '/' + file(zipExtracted).list()[0]
}
}
task macosapp_input {
dependsOn macosapp_extractzip
doFirst {
copy {
from(macosapp_input_dir) {
include '*.*'
}
into 'build/macosapp/input'
}
}
}
def macosapp_copyvolumeicon= tasks.create ("macosapp_copyvolumeicon", Copy) {
from file ('freeplane_framework/mac-appbundler/freeplane.icns')
into file('build/macosapp/dmg-resource-dir')
rename { String fileName ->
'Freeplane-volume.icns'
}
}
def defineMacBuildTasks = { architecture ->
def jpackage = macAppProperties["macapp.${architecture}.jpackage.jdk"] + '/bin/jpackage'
def macosapp_deleteAppImage = tasks.create("macosapp_deleteAppImage_${architecture}", Delete) {
delete "build/macosapp/app-image-${architecture}"
}
macosapp_extractzip.mustRunAfter macosapp_deleteAppImage
def jpackage_macosxapp = tasks.create ("jpackage_macosxapp_${architecture}", Exec) {
commandLine jpackage,
'--name' , 'Freeplane',
'--type', 'app-image',
'--icon', 'freeplane_framework/mac-appbundler/freeplane.icns',
'--app-version', majorVersion,
'--java-options', "-XX:-IgnoreUnrecognizedVMOptions",
'--java-options', "-XX:MaxRAM=20g",
'--java-options', "-XX:MaxRAMPercentage=15.0",
'--java-options', '-Djava.security.manager=allow',
'--java-options', '-Dapple.laf.useScreenMenuBar=false',
'--java-options', '-Xdock:name=Freeplane',
'--java-options', '--add-exports',
'--java-options', 'java.desktop/com.apple.eawt=ALL-UNNAMED',
'--java-options', '--add-exports',
'--java-options', 'java.desktop/com.apple.eawt.event=ALL-UNNAMED',
'--java-options', '--add-exports',
'--java-options', 'java.desktop/sun.awt=ALL-UNNAMED',
'--java-options', '--add-exports',
'--java-options', 'java.desktop/sun.swing=ALL-UNNAMED',
'--java-options', '--add-exports',
'--java-options', 'java.desktop/com.apple.laf=ALL-UNNAMED',
'--java-options', '--add-opens',
'--java-options', 'java.desktop/javax.swing.text.html=ALL-UNNAMED',
'--input', 'build/macosapp/input',
'--main-class', 'org.freeplane.launcher.Launcher',
'--main-jar', 'freeplanelauncher.jar',
'--runtime-image', macAppProperties["macapp.${architecture}.jdk.runtime.image"],
'--copyright', "Freeplane ${distVersion}",
'--dest', "build/macosapp/app-image-${architecture}"
dependsOn macosapp_input, macosapp_deleteAppImage
}
def macosapp_makeapp= tasks.create ("macosapp_makeapp_${architecture}") {
dependsOn jpackage_macosxapp
doFirst {
copy {
from(macosapp_input_dir) {
include '*/**'
}
into "build/macosapp/app-image-${architecture}/Freeplane.app/Contents/app"
}
copy {
from project('freeplane').configurations.maclib
into("build/macosapp/app-image-${architecture}/Freeplane.app/Contents/app/core/org.freeplane.core/lib")
}
copy {
from file ('freeplane_framework/mac-appbundler/freeplanedoc.icns')
into "build/macosapp/app-image-${architecture}/Freeplane.app/Contents/Resources"
}
def dist_macos_info = "build/macosapp/app-image-${architecture}/Freeplane.app/Contents/Info.plist"
ant.move(file:dist_macos_info, tofile:dist_macos_info + '2')
ant.xslt(in: new File(dist_macos_info + '2'),
style: new File('freeplane_framework/mac-appbundler/mac_info_plist.xslt'),
out: new File(dist_macos_info)
)
delete dist_macos_info + '2'
}
}
def signFlatlaf= tasks.create ("signFlatlaf_${architecture}", Exec) {
onlyIf { Os.isFamily(Os.FAMILY_MAC) && macAppProperties['macapp.codesign.identity'] != null}
commandLine 'bash', 'codesign/sign-jars-on-mac.sh',
"build/macosapp/app-image-${architecture}/Freeplane.app/Contents/app/core/org.freeplane.core/lib/flatlaf-*.jar",
macAppProperties['macapp.codesign.identity']
dependsOn macosapp_makeapp
}
def signJline= tasks.create ("signJline_${architecture}", Exec) {
onlyIf { Os.isFamily(Os.FAMILY_MAC) && macAppProperties['macapp.codesign.identity'] != null}
commandLine 'bash', 'codesign/sign-jars-on-mac.sh',
"build/macosapp/app-image-${architecture}/Freeplane.app/Contents/app/plugins/org.freeplane.plugin.script/lib/jline-*.jar",
macAppProperties['macapp.codesign.identity']
dependsOn macosapp_makeapp
}
def signJnr= tasks.create ("signJnr_${architecture}", Exec) {
onlyIf { Os.isFamily(Os.FAMILY_MAC) && macAppProperties['macapp.codesign.identity'] != null}
commandLine 'bash', 'codesign/sign-jars-on-mac.sh',
"build/macosapp/app-image-${architecture}/Freeplane.app/Contents/app/core/org.freeplane.core/lib/jnr-*.jar",
macAppProperties['macapp.codesign.identity']
dependsOn macosapp_makeapp
}
def signVappearances= tasks.create ("signVappearances_${architecture}", Exec) {
onlyIf { Os.isFamily(Os.FAMILY_MAC) && macAppProperties['macapp.codesign.identity'] != null}
commandLine 'bash', 'codesign/sign-jars-on-mac.sh',
"build/macosapp/app-image-${architecture}/Freeplane.app/Contents/app/core/org.freeplane.core/lib/vappearances-*.jar",
macAppProperties['macapp.codesign.identity']
dependsOn macosapp_makeapp
}
def signVaqua= tasks.create ("signVaqua_${architecture}", Exec) {
onlyIf { Os.isFamily(Os.FAMILY_MAC) && macAppProperties['macapp.codesign.identity'] != null}
commandLine 'bash', 'codesign/sign-jars-on-mac.sh',
"build/macosapp/app-image-${architecture}/Freeplane.app/Contents/app/core/org.freeplane.core/lib/vaqua-*.jar",
macAppProperties['macapp.codesign.identity']
dependsOn macosapp_makeapp
}
def signMacApp= tasks.create ("signMacApp_${architecture}", Exec) {
onlyIf { Os.isFamily(Os.FAMILY_MAC) && macAppProperties['macapp.codesign.identity'] != null}
commandLine jpackage,
'--type', 'app-image',
'--app-image', "build/macosapp/app-image-${architecture}/Freeplane.app",
'--mac-sign',
'--mac-signing-key-user-name', macAppProperties['macapp.codesign.identity']
dependsOn macosapp_makeapp, signFlatlaf, signJline, signJnr, signVappearances, signVaqua
}
def dmg4mac = tasks.create ("dmg4mac_${architecture}", Exec) {
doFirst {
mkdir globalDist
file("$globalDist/freeplane-${majorVersion}.dmg").delete()
file("$globalDist/freeplane-$distVersion-${architecture}.dmg").delete()
}
commandLine jpackage,
'--name' , 'Freeplane',
'--type', 'dmg',
'--app-version', majorVersion,
'--app-image', "build/macosapp/app-image-${architecture}/Freeplane.app",
'--mac-package-identifier', 'org.freeplane.core',
'--mac-package-name', 'Freeplane',
'--resource-dir', 'build/macosapp/dmg-resource-dir',
'--dest', globalDist
dependsOn signMacApp, macosapp_copyvolumeicon
doLast {
ant.move (file:"$globalDist/Freeplane-${majorVersion}.dmg", tofile:"$globalDist/Freeplane-${distVersion}-${architecture}.dmg")
}
}
def signDmg = tasks.create ("signDmg_${architecture}", Exec) {
commandLine 'bash', '-e', '-c', """
set -x; codesign --sign "Developer ID Application: ${macAppProperties['macapp.codesign.identity']}" $globalDist/Freeplane-${distVersion}-${architecture}.dmg
"""
dependsOn dmg4mac
}
def notarytool = tasks.create ("notarytool_${architecture}", Exec) {
commandLine 'bash', '-e', '-c', """
set -x; xcrun notarytool submit $globalDist/Freeplane-${distVersion}-${architecture}.dmg --keychain-profile ${macAppProperties['macapp.notarytool.keychainprofile']}
"""
dependsOn signDmg
}
}
if ( Os.isFamily(Os.FAMILY_MAC) && macAppProperties['macapp.codesign.identity'] != null) {
if (macAppProperties['macapp.intel.jdk.runtime.image'] != null
&& macAppProperties['macapp.intel.jpackage.jdk'] != null) {
defineMacBuildTasks('intel')
}
if (macAppProperties['macapp.apple.jdk.runtime.image'] != null
&& macAppProperties['macapp.apple.jpackage.jdk'] != null) {
defineMacBuildTasks('apple')
}
}