forked from freeplane/freeplane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mac.dist.gradle
155 lines (126 loc) · 4.68 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
import org.apache.tools.ant.taskdefs.condition.Os
import org.apache.tools.ant.filters.*
def appBundlerJar = 'freeplane_framework/mac-appbundler/appbundler-1.0.jar'
ant.taskdef(
name: "appbundler",
classname: 'com.oracle.appbundler.AppBundlerTask',
classpath: appBundlerJar,
onerror: "report"
)
def macAppPropertiesFile = file('macapp.properties')
Properties macAppProperties = new Properties()
if (macAppPropertiesFile.exists())
{
macAppProperties.load(new FileInputStream(macAppPropertiesFile))
}
task macDist {}
def defineMacBuildTasks = {
def jpackage = macAppProperties['macapp.jpackage.jdk'] + '/bin/jpackage'
def zipExtracted = 'build/zip-extracted'
String macosapp_input_dir
def macosapp_extractzip = tasks.create('macosapp_extractzip'){
mustRunAfter binZip
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]
}
}
def macosapp_input = tasks.create('macosapp_input'){
dependsOn macosapp_extractzip
doFirst {
copy {
from(macosapp_input_dir) {
include '*.*'
}
into 'build/macosapp/input'
}
}
}
def macosapp_deleteAppImage = tasks.create('macosapp_deleteAppImage', Delete) {
delete 'build/macosapp/app-image'
}
def jpackage_macosxapp = tasks.create ('jpackage_macosxapp', Exec) {
commandLine jpackage,
'--name' , 'Freeplane',
'--type', 'app-image',
'--icon', 'freeplane_framework/mac-appbundler/freeplane.icns',
'--app-version', distVersion,
'--java-options', '-Xmx512m',
'--java-options', '-Dapple.laf.useScreenMenuBar=true',
'--java-options', '-Xdock:name=Freeplane',
'--input', 'build/macosapp/input',
'--main-jar', 'freeplanelauncher.jar',
'--runtime-image', macAppProperties['macapp.jdk.runtime.image'],
'--copyright', "Freeplane ${distVersion}",
'--dest', 'build/macosapp/app-image'
dependsOn macosapp_input, macosapp_deleteAppImage
}
def macosapp_makeapp= tasks.create ('macosapp_makeapp') {
dependsOn jpackage_macosxapp
doFirst {
copy {
from(macosapp_input_dir) {
include '*/**'
}
into 'build/macosapp/app-image/Freeplane.app/Contents/app'
}
copy {
from file ('freeplane_framework/mac-appbundler/freeplanedoc.icns')
into 'build/macosapp/app-image/Freeplane.app/Contents/Resources'
}
def dist_macos_info = 'build/macosapp/app-image/Freeplane.app/Contents/Info.plist'
ant.xslt(in: new File(dist_macos_info),
style: new File('freeplane_framework/mac-appbundler/mac_info_plist.xslt'),
out: new File(dist_macos_info + '2')
)
java.nio.file.Files.move(java.nio.file.Paths.get(dist_macos_info + '2'),
java.nio.file.Paths.get(dist_macos_info),
java.nio.file.StandardCopyOption.REPLACE_EXISTING)
}
}
def signMacApp= tasks.create ('signMacApp', Exec) {
onlyIf { Os.isFamily(Os.FAMILY_MAC) && macAppProperties['macapp.codesign.identity'] != null}
commandLine 'codesign', '--deep', '-f',
'-s', 'Developer ID Application: ' + macAppProperties['macapp.codesign.identity'],
'-v', 'build/macosapp/app-image/Freeplane.app'
dependsOn macosapp_makeapp
}
def macosapp_copyvolumeicon= tasks.create ('macosapp_copyvolumeicon', Copy) {
from file ('freeplane_framework/mac-appbundler/freeplane.icns')
into file('build/macosapp/app-resource-dir')
rename { String fileName ->
'Freeplane-volume.icns'
}
}
def dmg4mac = tasks.create ('dmg4mac', Exec) {
def dmgPath = globalDist + '/freeplane' + '-' + distVersion + '.dmg';
doFirst {
mkdir globalDist
file(dmgPath).delete()
}
commandLine jpackage,
'--name' , 'Freeplane',
'--type', 'dmg',
'--app-version', distVersion,
'--app-image', 'build/macosapp/app-image',
'--mac-package-identifier', 'org.freeplane.core',
'--mac-package-name', 'Freeplane',
'--resource-dir', 'build/macosapp/app-resource-dir',
'--dest', globalDist
dependsOn signMacApp, macosapp_copyvolumeicon
}
}
if ( Os.isFamily(Os.FAMILY_MAC)
&& macAppProperties['macapp.jdk.runtime.image'] != null
&& macAppProperties['macapp.jpackage.jdk'] != null
&& macAppProperties['macapp.codesign.identity'] != null
) {
defineMacBuildTasks()
}