forked from freeplane/freeplane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mac.dist.gradle
162 lines (133 loc) · 4.54 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
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 = {boolean includeJavaRuntime ->
def taskName = {base -> includeJavaRuntime ? base + '_jre' : base}
def bin4mac = taskName(rootDir.path + '/BIN4mac')
def macappfullpath = new File(bin4mac, 'Freeplane.app').absoluteFile
def macosxapp = tasks.create (taskName('macosxapp')) {
mustRunAfter binZip
doFirst {
if(! binZip.archivePath.exists())
ant.fail("File ${binZip.archivePath.path} not found")
delete bin4mac + '/Freeplane.app'
mkdir bin4mac
def zipExtracted = globalBin+'-extracted'
delete zipExtracted
mkdir zipExtracted
copy {
from(zipTree(binZip.archivePath))
into(zipExtracted)
}
def globalBinExtracted = zipExtracted + '/' + file(zipExtracted).list()[0]
ant.appbundler(
outputdirectory: bin4mac,
name: 'Freeplane',
displayname: 'Freeplane',
mainclassname: 'org.freeplane.launcher.Launcher',
shortversion: distVersion,
copyright: "Freeplane ${distVersion}",
identifier: 'org.freeplane.core',
icon: 'freeplane_framework/mac-appbundler/freeplane.icns',
signature: '????'
) {
if (includeJavaRuntime) {
if(macAppProperties['macapp.jdk.home'] != null) {
runtime(dir: macAppProperties['macapp.jdk.home'])
}
else {
def javaHomeJre = System.properties['java.home']
def javaHome = javaHomeJre - ~/\/jre$/
runtime(dir: javaHome)
}
}
classpath(dir: globalBinExtracted, includes: '*.jar')
option(value: "-Xmx512m")
option(value: "-Dapple.laf.useScreenMenuBar=true")
option(value: "-Xdock:name=Freeplane")
}
def dist_macos_info = macappfullpath.path + '/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 macjavafullpath = macappfullpath.path + '/Contents/Java'
copy {
from(globalBinExtracted) {
exclude('**/*.bat')
exclude('**/*.exe')
exclude('*.jar')
exclude('license.txt')
}
into(macjavafullpath)
}
def macresourcesfullpath = macappfullpath.path + '/Contents/Resources'
copy {
from('freeplane_framework/mac-appbundler') {
include('freeplanedoc.icns')
}
into(macresourcesfullpath)
}
delete zipExtracted
}
}
def signMacApp= tasks.create (taskName('signMacApp'), Exec) {
onlyIf { Os.isFamily(Os.FAMILY_MAC) && macAppProperties['macapp.codesign.identity'] != null}
commandLine 'codesign', '--deep', '-s', macAppProperties['macapp.codesign.identity'], '-v', macappfullpath.path
dependsOn macosxapp
}
def dmg4mac= tasks.create (taskName('dmg4mac'), Exec) {
onlyIf { Os.isFamily(Os.FAMILY_MAC) }
def dmgPath = globalDist + taskName('/freeplane_app') + '-' + distVersion + '.dmg';
doFirst {
mkdir globalDist
file(dmgPath).delete()
}
commandLine 'hdiutil', 'create', '-srcfolder', macappfullpath.path,
dmgPath
dependsOn macosxapp, signMacApp
}
def zip4mac = tasks.create (taskName('zip4mac'), Zip) {
destinationDir = new File(globalDist)
archiveName = taskName('freeplane_macos_bin') + '-' + distVersion + '.zip'
from(bin4mac) {
exclude('**/JavaAppLauncher')
}
from(bin4mac) {
include('**/JavaAppLauncher')
fileMode = 0775
}
into('freeplane-' + distVersion)
dependsOn macosxapp
}
def cleanMac = tasks.create (taskName('cleanMac'), Delete) {
delete bin4mac
}
if (Os.isFamily(Os.FAMILY_MAC)) {
macDist.dependsOn dmg4mac
}
else {
macDist.dependsOn zip4mac
}
clean.dependsOn cleanMac
}
if (Os.isFamily(Os.FAMILY_MAC)) {
defineMacBuildTasks(true)
}
defineMacBuildTasks(false)