forked from freeplane/freeplane
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mac.dist.gradle
180 lines (150 loc) · 6.08 KB
/
mac.dist.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
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))
}
task macDist {}
String macosapp_input_dir
task macosapp_extractzip {
mustRunAfter binZip
def zipExtracted = 'build/zip-extracted'
doFirst {
if(! binZip.archivePath.exists())
ant.fail("File ${binZip.archivePath.path} not found")
delete zipExtracted
mkdir zipExtracted
copy {
from(zipTree(binZip.archivePath))
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}"
}
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', '-Xmx512m',
'--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/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"
}
if(architecture=='intel') {
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 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
}
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 notarytool = tasks.create ("notarytool_${architecture}", Exec) {
commandLine 'bash', '-e', '-c', """
xcrun notarytool submit $globalDist/Freeplane-${distVersion}-${architecture}.dmg --keychain-profile ${macAppProperties['macapp.notarytool.keychainprofile']}
"""
mustRunAfter dmg4mac
}
}
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')
}
}