-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.xml
297 lines (268 loc) · 11.5 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
<?xml version="1.0" encoding="UTF-8"?>
<project default="jars" name="grand-ui" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<property file="build-local.properties"/>
<property file="build.properties"/>
<property name="product.name" value="grand-ui"/>
<property name="product.fullname" value="${product.name}-${product.version}"/>
<property name="product.vendor" value="ggTools"/>
<property name="libdir" value="lib"/>
<property name="extlibdir" value="deps"/>
<property name="classdir" value="bin"/>
<property name="srcdir" value="src/main/java"/>
<property name="confdir" value="src/main/resources"/>
<property name="scriptdir" value="src/main/scripts"/>
<property name="buildnum-file" value="${confdir}/net/ggtools/grand/ui/buildnum.properties"/>
<property name="distdir" value="dist"/>
<property name="javadocdir" value="tmp/docs/api"/>
<property name="java.target" value="1.8"/>
<property name="bundle.name" value="GrandUI.app"/>
<property name="bundle.launcher.name" value="JavaAppLauncher"/>
<property name="verbose-get" value="false"/>
<tstamp>
<format pattern="2004-yyyy" property="years"/>
</tstamp>
<property name="central.repo" value="https://repo1.maven.org/maven2"/>
<property name="ivy.version" value="2.5.0"/>
<property name="ivy.dir" value="${user.home}/.ivy2/cache/org.apache.ivy/jars"/>
<property name="ivy.jar.name" value="ivy-${ivy.version}.jar"/>
<available property="has.ivy" file="${ivy.dir}/${ivy.jar.name}" type="file"/>
<target name="get-ivy" description="Get Ivy jar unless already cached" unless="has.ivy">
<mkdir dir="${ivy.dir}"/>
<get usetimestamp="true" src="${central.repo}/org/apache/ivy/ivy/${ivy.version}/${ivy.jar.name}"
skipexisting="true"
dest="${ivy.dir}/${ivy.jar.name}"/>
</target>
<target name="init" description="Initialize Ivy" depends="get-ivy">
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${ivy.dir}/${ivy.jar.name}"/>
<ivy:settings file="${basedir}/ivy.settings.xml"/>
</target>
<target name="get-deps" description="Retrieve dependencies" depends="init" unless="noget">
<ivy:retrieve pattern="${extlibdir}/[artifact]-[revision].[ext]" sync="true" type="jar"/>
</target>
<macrodef name="getjar" description="Download a jar to the extlib directory">
<attribute name="dest"/>
<attribute name="url"/>
<sequential>
<get dest="${extlibdir}/@{dest}" verbose="${verbose-get}" usetimestamp="true" ignoreerrors="true" src="@{url}"/>
</sequential>
</macrodef>
<target name="get-alldeps" description="Retrieve all dependencies" depends="get-deps,set-eclipse-deps" unless="noget">
<getjar dest="blacksun-util.jar" url="${url.blacksun-util.jar}"/>
<getjar dest="jzgraph.jar" url="${url.jzgraph.jar}"/>
<getjar dest="grand-module.jar" url="${url.grand.jar}"/>
<getjar dest="appbundler.jar" url="${url.appbundler.jar}"/>
</target>
<selector id="src-dist-selector">
<or>
<filename name="${srcdir}/**"/>
<filename name="${confdir}/**"/>
<filename name="${scriptdir}/**"/>
<filename name="README.txt"/>
<filename name="LICENSE"/>
<filename name="COPYING"/>
<filename name="LICENSE-Graphviz.txt"/>
<filename name="cpl-v10.html"/>
<filename name="build.xml"/>
<filename name="build.properties"/>
</or>
</selector>
<target name="javadoc" description="Generates javadoc" depends="jars">
<mkdir dir="${javadocdir}"/>
<property name="copyright" value="Copyright &copy;${years} ${product.vendor}. All Rights Reserved."/>
<property name="title" value="Grand UI ${product.version} API"/>
<javadoc use="true" private="true" destdir="${javadocdir}" author="true" version="true" windowtitle="Grand UI" doctitle="${title}" bottom="${copyright}"
sourcepath="${srcdir}" packagenames="net.ggtools.grand.*">
<classpath>
<fileset dir="${libdir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${extlibdir}">
<include name="*.jar"/>
</fileset>
</classpath>
</javadoc>
</target>
<target name="dist" depends="bin-dist,src-dist" description="Create source and binary distributions"/>
<target name="src-dist">
<mkdir dir="${distdir}"/>
<tar destfile="${distdir}/${product.fullname}-src.tar.gz" compression="gzip">
<tarfileset dir="." prefix="${product.fullname}-src">
<selector refid="src-dist-selector"/>
</tarfileset>
</tar>
<zip destfile="${distdir}/${product.fullname}-src.zip">
<zipfileset dir="." prefix="${product.fullname}-src">
<selector refid="src-dist-selector"/>
</zipfileset>
</zip>
</target>
<target name="bin-dist" depends="real-clean,jars">
<!-- Prepare for bin distribution -->
<mkdir dir="tmp/${product.fullname}"/>
<!-- Java libraries -->
<copy tofile="tmp/${product.fullname}/lib/grand-ui.jar" file="${libdir}/${product.fullname}.jar"/>
<copy todir="tmp/${product.fullname}/lib">
<fileset dir="${extlibdir}" excludes="org.eclipse.swt.*.jar,swt.jar,appbundler.jar"/>
</copy>
<!-- Names of SWT platform-specific libraries are incompatible with JPMS automatic module naming -->
<copy todir="tmp/${product.fullname}/lib/gtk">
<fileset dir="${extlibdir}" includes="org.eclipse.swt.gtk.*.x86_64-*.jar"/>
<regexpmapper from="([^-]*).x86_64-(\d+\.\d+\.\d+).*\.jar" to="\1-\2.jar"/>
</copy>
<copy todir="tmp/${product.fullname}/lib/win32">
<fileset dir="${extlibdir}" includes="org.eclipse.swt.win32.*.x86_64-*.jar"/>
<regexpmapper from="([^-]*).x86_64-(\d+\.\d+\.\d+).*\.jar" to="\1-\2.jar"/>
</copy>
<!-- Licenses -->
<copy todir="tmp/${product.fullname}" flatten="true">
<fileset dir=".">
<include name="README.txt"/>
<include name="LICENSE"/>
<include name="COPYING"/>
<include name="LICENSE-Graphviz.txt"/>
<include name="cpl-v10.html"/>
</fileset>
</copy>
<copy todir="tmp/${product.fullname}">
<fileset dir="${scriptdir}" includes="**/*.sh"/>
<globmapper from="*.sh" to="*"/>
</copy>
<chmod perm="755">
<fileset dir="tmp/${product.fullname}" includes="grand-ui"/>
</chmod>
<copy todir="tmp/${product.fullname}">
<fileset dir="${scriptdir}" includes="**/*.bat"/>
</copy>
<fixcrlf srcdir="tmp/${product.fullname}" includes="*.bat" eol="dos"/>
<copy todir="tmp">
<fileset dir="${scriptdir}" includes="${bundle.name}/**" excludes="**/*.icns"/>
<filterset>
<filter token="VENDOR" value="${product.vendor}"/>
<filter token="VERSION" value="${product.version}"/>
<filter token="YEARS" value="${years}"/>
</filterset>
</copy>
<copy todir="tmp">
<fileset dir="${scriptdir}" includes="**/*.icns"/>
</copy>
<copy todir="tmp/${bundle.name}/Contents/Resources" flatten="true">
<fileset dir=".">
<include name="README.txt"/>
<include name="LICENSE"/>
<include name="COPYING"/>
<include name="LICENSE-Graphviz.txt"/>
<include name="cpl-v10.html"/>
</fileset>
</copy>
<mkdir dir="tmp/${bundle.name}/Contents/MacOS"/>
<copy todir="tmp/${bundle.name}/Contents/MacOS">
<mappedresources>
<zipfileset src="${extlibdir}/appbundler.jar" includes="**/${bundle.launcher.name}"/>
<flattenmapper/>
</mappedresources>
</copy>
<chmod perm="755">
<fileset dir="tmp/${bundle.name}/Contents/MacOS"/>
</chmod>
<mkdir dir="tmp/${bundle.name}/Contents/Java"/>
<copy todir="tmp/${bundle.name}/Contents/Java">
<fileset dir="${extlibdir}" includes="*.jar" excludes="org.eclipse.swt.gtk.*.jar,org.eclipse.swt.win32.*.jar,swt.jar,appbundler.jar"/>
</copy>
<copy tofile="tmp/${bundle.name}/Contents/Java/grand-ui.jar" file="${libdir}/${product.fullname}.jar"/>
<mkdir dir="${distdir}"/>
<tar destfile="${distdir}/${product.fullname}.tar.gz" compression="gzip">
<tarfileset dir="tmp/${product.fullname}" prefix="${product.fullname}" filemode="755">
<include name="grand-ui"/>
</tarfileset>
<tarfileset dir="tmp/${product.fullname}" prefix="${product.fullname}">
<exclude name="grand-ui"/>
</tarfileset>
<tarfileset dir="tmp/${bundle.name}" prefix="${bundle.name}" filemode="755">
<include name="**/${bundle.launcher.name}"/>
</tarfileset>
<tarfileset dir="tmp/${bundle.name}" prefix="${bundle.name}">
<exclude name="**/${bundle.launcher.name}"/>
</tarfileset>
</tar>
<zip destfile="${distdir}/${product.fullname}.zip">
<zipfileset dir="tmp/${product.fullname}" prefix="${product.fullname}" filemode="755">
<include name="grand-ui"/>
</zipfileset>
<zipfileset dir="tmp/${product.fullname}" prefix="${product.fullname}">
<exclude name="grand-ui"/>
</zipfileset>
<zipfileset dir="tmp/${bundle.name}" prefix="${bundle.name}" filemode="755">
<include name="**/${bundle.launcher.name}"/>
</zipfileset>
<zipfileset dir="tmp/${bundle.name}" prefix="${bundle.name}">
<exclude name="**/${bundle.launcher.name}"/>
</zipfileset>
</zip>
</target>
<target name="jars" depends="compile-java,incbuildnum" description="Create the application jar(s)">
<mkdir dir="${libdir}"/>
<jar destfile="${libdir}/${product.fullname}.jar" index="true">
<fileset dir="${classdir}"/>
<fileset dir="${confdir}"/>
<manifest>
<attribute name="Main-Class" value="net.ggtools.grand.ui.Application"/>
<section name="net/ggtools/grand/ui">
<attribute name="Specification-Title" value="${product.name}"/>
<attribute name="Specification-Version" value="${product.version}"/>
<attribute name="Specification-Vendor" value="${product.vendor}"/>
<attribute name="Implementation-Title" value="${product.name}"/>
<attribute name="Implementation-Version" value="${product.version}"/>
<attribute name="Implementation-Vendor" value="${product.vendor}"/>
</section>
</manifest>
</jar>
</target>
<target name="compile-java" depends="get-alldeps" description="Compile the java source files">
<mkdir dir="${classdir}"/>
<javac srcdir="${srcdir}" destdir="${classdir}" debug="true" optimize="true" includeantruntime="false" source="${java.target}" target="${java.target}">
<classpath>
<fileset dir="${extlibdir}" includes="*.jar"/>
</classpath>
</javac>
</target>
<target name="incbuildnum" unless="noincbuildnum">
<propertyfile file="${buildnum-file}">
<entry key="build.date" type="date" value="now" pattern="yyyy-MM-dd"/>
<entry key="build.time" type="date" value="now" pattern="HH:mm:ss"/>
<entry key="build.number" type="int" operation="+" default="0"/>
<entry key="build.version.string" type="string" value="${product.version}"/>
</propertyfile>
<property file="${buildnum-file}"/>
<echo message="build number set to ${build.number}"/>
</target>
<target name="clean" depends="clean-dist,clean-deps" description="Remove intermediate files but not external libs">
<delete dir="${libdir}"/>
<delete dir="${classdir}"/>
</target>
<target name="clean-deps" description="Clean the dependencies directory">
<delete dir="${extlibdir}"/>
</target>
<target name="clean-dist" description="Clean the dist directory">
<delete dir="${distdir}"/>
</target>
<target name="real-clean" depends="clean" description="Remove intermediate files ant external libs">
<delete dir="tmp"/>
</target>
<!-- Eclipse helper targets -->
<target name="set-eclipse-deps" depends="set-swt-properties" if="eclipse.pdebuild.home">
<copy tofile="${extlibdir}/swt.jar">
<fileset dir="${extlibdir}" includes="org.eclipse.swt.${swtfw}.x86_64-*.jar"/>
</copy>
</target>
<target name="set-swt-properties">
<condition property="swtfw" value="gtk.linux">
<os name="Linux"/>
</condition>
<condition property="swtfw" value="win32.win32">
<os family="windows"/>
</condition>
<condition property="swtfw" value="cocoa.macosx">
<os family="mac"/>
</condition>
</target>
</project>