-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
313 lines (282 loc) · 13.6 KB
/
build.xml
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<?xml version="1.0" encoding="UTF-8"?>
<!-- Ant is used instead of Maven or Gradle because both Maven and Gradle
are hideously slow on older machines like a Mac PowerBook G4 or Sun
Ultra 5. Ant is more than 2X faster and the Ant code is more than 2X
simpler, shorter and easier to understand. The only thing that Maven
would offer is dependency management. But there is only one dependency
so Maven is just an annoying nuisance for this purpose.
Also, Maven can't build a DMG that works on both old and new Macs.
Ant is required for that.
A Maven directory layout is maintained for consistency with other
projects. -->
<!-- This DOCTYPE tag shuts off the warning from Eclipse that there is no DTD
associated with this XML file. -->
<!DOCTYPE project>
<project name="rune" default="all" basedir=".">
<property environment="env"/>
<property name="version" value="1.0"/>
<property name="build.dir" value="target"/>
<property name="cls.dir" value="${build.dir}/classes"/>
<property name="main.class" value="Rune"/>
<property name="lib.dir" value="lib"/>
<property name="jar" value="${build.dir}/rune.jar"/>
<property name="app" value="${build.dir}/Rune.app"/>
<property name="dmg" value="${build.dir}/Rune.dmg"/>
<property name="zip" value="${build.dir}/Rune.zip"/>
<property name="dmg.setup.dir" value="${build.dir}/Rune"/>
<property name="font.install.script" value="${dmg.setup.dir}/Install Free Programming Fonts"/>
<property name="izpack.root" value="${build.dir}/izpack"/>
<property name="izpack.app.dir" value="appfiles"/>
<!-- The location of this jar is very bad, but that is what izPack requires. -->
<property name="xdg.desktop.menu.jar" value="${build.dir}/xdg-desktop-menu.jar"/>
<!-- Allows us to use the IzPack Ant task, standalone-compiler.jar added to Ant lib -->
<taskdef name="izpack"
classpath="lib/izpack-standalone-compiler-4.3.5.jar"
classname="com.izforge.izpack.ant.IzPackTask"/>
<!-- If the version is between 1.5 and 1.8, then compile for 1.5, so it
works on old machines. If not, then just use the runtime java
version because newer versions can't compile for 1.5. -->
<condition property="target.java.version" value="1.5" else="${java.specification.version}">
<or>
<equals arg1="1.5" arg2="${java.specification.version}"/>
<equals arg1="1.6" arg2="${java.specification.version}"/>
<equals arg1="1.7" arg2="${java.specification.version}"/>
<equals arg1="1.8" arg2="${java.specification.version}"/>
</or>
</condition>
<condition property="mac">
<os family="mac"/>
</condition>
<condition property="linux">
<os name="linux"/>
</condition>
<condition property="windows">
<os family="windows"/>
</condition>
<target name="clean" description="Deletes all build artifacts">
<delete dir="${build.dir}" verbose="true"/>
</target>
<target name="compile-setup" description="Sets up for compile">
<mkdir dir="${cls.dir}"/>
</target>
<target name="compile" depends="compile-setup" description="Compiles Java code">
<javac srcdir="src/main/java"
source="${target.java.version}"
target="${target.java.version}"
destdir="${cls.dir}"
classpath="lib/izpack-standalone-compiler-4.3.5.jar"
includeantruntime="false"
debug="true"/>
</target>
<target name="jar-xdg-desktop-menu-setup" depends="compile" description="Builds jar for custom install listener">
<jar destfile="${xdg.desktop.menu.jar}">
<fileset dir="${build.dir}/classes">
<include name="com/alteredmechanism/izpack/**"/>
<include name="com/alteredmechanism/rune/Executor.class"/>
</fileset>
<manifest>
<attribute name="Main-Class" value="com.alteredmechanism.izpack.XdgDesktopMenu"/>
</manifest>
</jar>
</target>
<target name="jar" depends="compile" description="Builds a fat jar, rune.jar">
<jar destfile="${build.dir}/${ant.project.name}.jar">
<fileset dir="${build.dir}/classes">
<exclude name="com/alteredmechanism/izpack/**"/>
</fileset>
<fileset dir="src/main/resources" includes="icons/**" excludes="mac"/>
<zipfileset src="lib/jlfgr-1_0.jar" excludes="META-INF/*.SF"/>
<zipfileset src="lib/kunststoff.jar" excludes="META-INF/*.SF"/>
<zipfileset src="lib/liquidlnf.jar" excludes="META-INF/*.SF"/>
<zipfileset src="lib/looks.jar" excludes="META-INF/*.SF"/>
<zipfileset src="lib/metouia.jar" excludes="META-INF/*.SF"/>
<zipfileset src="lib/substance.jar" excludes="META-INF/*.SF"/>
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
</manifest>
</jar>
</target>
<target name="mac-app" depends="jar" description="Builds Rune.app directory structure">
<delete dir="${app}" />
<mkdir dir="${app}/Contents/MacOS" />
<mkdir dir="${app}/Contents/Resources/Java" />
<copy todir="${app}/Contents/MacOS" preservelastmodified="true" verbose="true">
<fileset file="src/main/scripts/rune"/>
<fileset file="src/main/scripts/rune-debug.sh"/>
<fileset file="src/main/scripts/rune-common-functions.sh"/>
<fileset file="src/main/scripts/rune-out-of-mem-err-handler.sh"/>
</copy>
<!-- Ant's 'copy' command drops permissions so, they need to be reset after each copy. -->
<chmod perm="ugo+rx" verbose="true">
<fileset file="${app}/Contents/MacOS/rune"/>
<fileset file="${app}/Contents/MacOS/rune-debug.sh"/>
<fileset file="${app}/Contents/MacOS/rune-out-of-mem-err-handler.sh"/>
<fileset file="${app}/Contents/MacOS/install-fonts.sh"/>
</chmod>
<copy file="${jar}" tofile="${app}/Contents/Resources/Java/rune.jar" preservelastmodified="true"
verbose="true"/>
<copy todir="${app}/Contents/Resources" preservelastmodified="true" verbose="true">
<fileset file="src/main/resources/icons/vegvisir.icns"/>
</copy>
<copy todir="${app}/Contents" preservelastmodified="true" verbose="true">
<fileset dir="src/main/resources/mac">
<include name="Info.plist"/>
<include name="PkgInfo"/>
</fileset>
</copy>
</target>
<target name="mac-app-zip" depends="mac-app" description="Build a zip file containing the mac app">
<echo message="A DMG is a Mac-only technology so building a Zip also" />
<zip destfile="${zip}">
<fileset file="${app}"/>
</zip>
</target>
<target name="dmg-on-mac-setup" depends="mac-app" description="Setup for building a dmg on a Mac" if="mac">
<mkdir dir="${dmg.setup.dir}"/>
<copy todir="${dmg.setup.dir}">
<fileset dir="${build.dir}" includes="Rune.app/**"/>
<!-- <fileset file="src/main/resources/mac/Applications"/> -->
</copy>
<!-- Ant's 'copy' command drops permissions so, they need to be reset after each copy. -->
<chmod perm="a+rx" verbose="true">
<fileset file="${dmg.setup.dir}/Rune.app/Contents/MacOS/rune"/>
<fileset file="${dmg.setup.dir}/Rune.app/Contents/MacOS/rune-debug.sh"/>
<fileset file="${dmg.setup.dir}/Rune.app/Contents/MacOS/rune-out-of-mem-err-handler.sh"/>
<fileset file="${dmg.setup.dir}/Rune.app/Contents/MacOS/install-fonts.sh"/>
</chmod>
<copy file="src/main/scripts/install-fonts.sh" tofile="${font.install.script}"/>
<chmod file="${font.install.script}" perm="a+rx"/>
<mkdir dir="${dmg.setup.dir}/Fonts"/>
<copy todir="${dmg.setup.dir}/Fonts">
<fileset dir="${basedir}/src/main/resources/fonts" includes="**"/>
</copy>
</target>
<target name="dmg-on-mac" depends="dmg-on-mac-setup" description="Builds a dmg on a Mac" if="mac">
<exec dir="${build.dir}" executable="hdiutil">
<arg value="create"/>
<arg value="-ov"/>
<!-- Overwrite any existing file -->
<arg value="-srcfolder"/>
<arg value="Rune"/>
<arg value="Rune.dmg"/>
</exec>
<!-- This should be "if mac os < catalina" -->
<exec dir="${build.dir}" executable="hdiutil">
<arg value="internet-enable"/>
<arg value="-yes"/>
<arg value="Rune.dmg"/>
</exec>
</target>
<target name="dmg-on-linux" depends="mac-app" if="linux" description="Builds a dmg on a Lignix">
<touch file="${dmg}" />
<echo message="Zeroing out ${dmg} file"/>
<exec dir="${basedir}" executable="dd" failonerror="true">
<arg value="if=/dev/zero"/>
<arg value="of=${dmg}"/>
<arg value="bs=1M"/>
<arg value="count=10"/>
<!-- Number of megabytes -->
<arg value="status=progress"/>
</exec>
<!-- echo message="${env.PATH}"-->
<exec dir="${basedir}" executable="mkfs" resultproperty="mkfs.hfsplus.result">
<arg value="-t"/>
<arg value="hfsplus"/>
<arg value="-v"/>
<arg value="Rune"/>
<arg value="${dmg}"/>
</exec>
<fail>
<condition>
<not>
<equals arg1="${mkfs.hfsplus.result}" arg2="0"/>
</not>
</condition>
Failed to create hfs+ file system for dmg.
You may need to install the appropriate hfs+ file system package:
Fedora: sudo dnf install hfsplus-tools
Ubuntu: sudo apt install hfsprogs
This will also fail if it is running inside a snap or flatpak Intellij
because they are sandboxed and therefore can't access /usr/bin/mkfs.
</fail>
<mkdir dir="target/dmg-mount"/>
<echo>Super user privileges will be required to mount/unmount the dmg file</echo>
<exec dir="${basedir}" executable="sudo" failonerror="true">
<arg value="mount"/>
<arg value="--verbose"/>
<arg value="-o"/>
<arg value="loop"/>
<arg value="${dmg}"/>
<arg value="target/dmg-mount"/>
</exec>
<exec dir="${build.dir}" executable="sudo" failonerror="true">
<arg value="chown"/>
<arg value="-R"/>
<arg value="${user.name}:${user.name}"/>
<arg value="dmg-mount"/>
</exec>
<copy todir="${build.dir}/dmg-mount" verbose="true">
<fileset dir="${build.dir}">
<include name="Rune.app/**"/>
</fileset>
</copy>
<!-- Ant's 'copy' command drops permissions so, they need to be reset after each copy. -->
<chmod perm="a+rx" verbose="true">
<fileset file="${build.dir}/dmg-mount/Rune.app/Contents/MacOS/rune"/>
<fileset file="${build.dir}/dmg-mount/Rune.app/Contents/MacOS/rune-debug.sh"/>
<fileset file="${build.dir}/dmg-mount/Rune.app/Contents/MacOS/rune-out-of-mem-err-handler.sh"/>
</chmod>
<exec dir="${build.dir}" executable="sudo" failonerror="true">
<arg value="umount"/>
<arg value="--verbose"/>
<arg value="dmg-mount"/>
</exec>
</target>
<target name="dmg" depends="dmg-on-mac,dmg-on-linux,mac-app-zip" description="Builds a dmg" />
<target name="izpack-setup" depends="jar,jar-xdg-desktop-menu-setup">
<mkdir dir="${izpack.root}"/>
<copy todir="${izpack.root}">
<fileset dir="src/main/izpack" includes="**"/>
</copy>
<!-- Copy scripts into izpack deployment directory. -->
<mkdir dir="${izpack.root}/${izpack.app.dir}/bin"/>
<copy todir="${izpack.root}/${izpack.app.dir}/bin">
<fileset dir="src/main/scripts">
<include name="rune*"/> <!-- All files starting with rune -->
<include name="rune-common-functions.sh"/>
<include name="dtksh-dialog"/>
</fileset>
</copy>
<mkdir dir="${izpack.root}/${izpack.app.dir}/lib"/>
<copy tofile="${izpack.root}/${izpack.app.dir}/lib/rune.jar" file="${jar}"/>
<copy todir="${izpack.root}/${izpack.app.dir}/lib" file="${xdg.desktop.menu.jar}"/>
<mkdir dir="${izpack.root}/${izpack.app.dir}"/>
<copy todir="${izpack.root}/${izpack.app.dir}">
<fileset dir="${basedir}">
<include name="README.md"/>
<include name="LICENSE"/>
</fileset>
</copy>
<mkdir dir="${izpack.root}/${izpack.app.dir}/share/icons"/>
<copy todir="${izpack.root}/${izpack.app.dir}/share/icons">
<fileset dir="src/main/resources/icons">
<include name="vegvisir.png"/>
</fileset>
</copy>
</target>
<target name="izpack" depends="izpack-setup">
<!-- Setting compression="deflate" causes
ClassNotFoundException: java.util.jar.Pack200 with some versions
of Java (8, 14, etc) which do not have that class. -->
<izpack input="src/main/izpack/izpack-main-install-setup.xml"
output="${build.dir}/rune-installer.jar"
installerType="standard"
inheritAll="true"
basedir="${izpack.root}"
/>
</target>
<target name="all" depends="dmg"/>
<target name="test" depends="all">
<java jar="${build.dir}/rune-install.jar" fork="true"/>
</target>
</project>