-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
361 lines (306 loc) · 14 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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="Jetrix TetriNET Server" default="dist" basedir=".">
<taskdef resource="org/jdesktop/deployment/ant/pack200/antlib.xml" classpath="lib/build/deployment-ant-pack200-1.0-rc1.jar"/>
<property name="compile.debug" value="true"/>
<property name="compile.optimize" value="false"/>
<property name="src" value="src"/>
<property name="lib" value="lib"/>
<property name="doc" value="doc"/>
<property name="build" value="build"/>
<property name="dist" value="dist"/>
<property name="deploy" value="deploy"/>
<property file="build.properties" />
<property file="project.properties" />
<property file="password.properties" />
<path id="classpath.main">
<fileset dir="${lib}" includes="**/*.jar"/>
</path>
<target name="init">
<!-- Create the time stamp -->
<tstamp>
<format property="build.time" pattern="yyyyMMddHH"/>
</tstamp>
<!-- Filters -->
<filter token="version" value="${version}"/>
<filter token="build.time" value="${build.time}"/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
<mkdir dir="${build}/java"/>
<mkdir dir="${build}/classes"/>
</target>
<target name="prepare" depends="init">
<copy todir="${build}/java" filtering="on">
<fileset dir="${src}/java" includes="**/*.java"/>
</copy>
<fixcrlf srcdir="${build}/java" eol="lf" eof="remove" includes="**/*.java"/>
</target>
<target name="compile" depends="prepare">
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${build}/java" destdir="${build}/classes" debug="${compile.debug}" optimize="${compile.optimize}">
<classpath>
<path refid="classpath.main"/>
</classpath>
</javac>
</target>
<target name="compile.jsp.check" depends="compile" description="Compile the JSP pages if they aren't up to date">
<uptodate property="compile.jsp.notRequired">
<srcfiles dir= "${src}/admin" includes="**/*.jsp"/>
<mapper type="regexp" from="^(.*)\.jsp$$" to="../../${build}/jsp/\1_jsp.java"/>
</uptodate>
</target>
<target name="compile.servlet" depends="compile" description="Compile the Servlets">
<mkdir dir="${build}/jsp"/>
<javac destdir="${build}/jsp" debug="yes">
<classpath>
<pathelement path="${build}/classes/"/>
<path refid="classpath.main"/>
</classpath>
<src path="${src}/admin/WEB-INF/classes"/>
</javac>
</target>
<target name="compile.jsp" depends="compile, compile.jsp.check" unless="compile.jsp.notRequired" description="Compile the JSP pages">
<mkdir dir="${build}/jsp"/>
<jspc destdir="${build}/jsp" verbose="10" srcdir="${src}/admin">
<classpath>
<path refid="classpath.main"/>
<pathelement location="${ant.home}/lib/ant.jar"/>
</classpath>
</jspc>
<javac destdir="${build}/jsp" debug="yes">
<classpath>
<pathelement path="${build}/classes/"/>
<path refid="classpath.main"/>
</classpath>
<src path="${build}/jsp"/>
<src path="${src}/admin/WEB-INF/classes"/>
</javac>
</target>
<target name="jar" depends="compile.jsp, compile.servlet">
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>
<!-- Create the main JAR -->
<jar jarfile="${dist}/lib/jetrix-${version}.jar" compress="false">
<manifest>
<attribute name="Implementation-Title" value="Jetrix TetriNET Server"/>
<attribute name="Implementation-Version" value="${version}"/>
</manifest>
<fileset dir="${build}/classes" excludes="**/Launcher*.class"/>
<fileset dir="${src}/etc">
<include name="tetrinet-server.dtd"/>
<include name="tetrinet-channels.dtd"/>
<include name="icons/jetrix-16x16.png"/>
<include name="icons/jetrix-32x32.png"/>
</fileset>
</jar>
<!-- Create the Launcher JAR -->
<jar jarfile="${dist}/lib/jetrix-launcher-${version}.jar" compress="false">
<manifest>
<attribute name="Implementation-Title" value="Jetrix Launcher"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Main-Class" value="net.jetrix.Launcher"/>
</manifest>
<fileset dir="${build}/classes" includes="**/Launcher*.class"/>
</jar>
<!-- Create the WAR for the administration console -->
<mkdir dir="${dist}/webapp"/>
<war destfile="${dist}/webapp/jetrix-admin-${version}.war" webxml="${src}/admin/WEB-INF/web.xml" compress="false">
<fileset dir="${src}/admin">
<exclude name="WEB-INF/web.xml"/>
<exclude name="**/*.jsp"/>
<exclude name="**/*.java"/>
</fileset>
<classes dir="${build}/jsp" includes="**/*.class"/>
</war>
</target>
<target name="pack" depends="jar" description="Pack the dependencies to reduce the distribution size">
<!-- Copy the JARs -->
<copy todir="${build}/lib">
<fileset dir="${lib}" includes="*"/>
</copy>
<!-- Pack the main JAR and the WAR for the administration console -->
<pack200 src="${dist}/lib/jetrix-${version}.jar" destfile="${dist}/lib/jetrix-${version}.jar.pack" gzipoutput="false" stripdebug="false" keepfileorder="false"/>
<pack200 src="${dist}/webapp/jetrix-admin-${version}.war" destfile="${dist}/webapp/jetrix-admin-${version}.war.pack" gzipoutput="false" stripdebug="false" keepfileorder="false"/>
<!-- Pack the dependencies -->
<pack200 gzipoutput="false" stripdebug="true" keepfileorder="false" segmentlimit="-1" todir="${build}/lib">
<fileset dir="${build}/lib" includes="*.jar" excludes="jetrix-${version}.jar"/>
</pack200>
</target>
<target name="dist" depends="pack">
<mkdir dir="${build}/dist"/>
<copy todir="${build}/dist" filtering="on">
<fileset dir="${src}/bin" includes="**/*" excludes="**/*.nsi"/>
</copy>
<copy todir="${build}/dist">
<fileset dir="${src}/etc">
<include name="LICENSE" />
<include name="README" />
<include name="conf/*" />
<include name="data/**" />
<include name="log/**" />
</fileset>
<fileset dir="${build}" includes="lib/*.pack"/>
<fileset dir="${dist}">
<include name="lib/jetrix-${version}.jar.pack" />
<include name="lib/jetrix-launcher-${version}.jar" />
</fileset>
<fileset dir="${src}" includes="lang/**/*.properties"/>
</copy>
<copy todir="${build}/dist/lib">
<fileset dir="${dist}/webapp/" includes="*.war.pack"/>
</copy>
<!-- Create the distribution directory -->
<mkdir dir="${dist}/bin"/>
<!-- Create the Windows distribution -->
<zip zipfile="${dist}/bin/jetrix-${version}.zip">
<zipfileset prefix="jetrix-${version}" dir="${build}/dist" includes="jetrix" filemode="755"/>
<zipfileset prefix="jetrix-${version}" dir="${build}/dist" excludes="jetrix"/>
</zip>
<!-- Create the Unix distribution -->
<tar destfile="${dist}/bin/jetrix-${version}.tar.bz2" compression="bzip2">
<tarfileset prefix="jetrix-${version}" dir="${build}/dist" includes="jetrix" filemode="755"/>
<tarfileset prefix="jetrix-${version}" dir="${build}/dist" excludes="jetrix"/>
</tar>
</target>
<target name="dist.linux" depends="dist.debian" description="Build the Linux packages"/>
<target name="dist.debian" depends="dist" description="Build the Debian package">
<mkdir dir="${build}/control"/>
<copy todir="${build}/control" filtering="true" >
<fileset dir="src/etc/deb/control"/>
</copy>
<taskdef name="deb" classname="org.vafer.jdeb.ant.DebAntTask" classpath="lib/build/jdeb-0.8-SNAPSHOT.jar"/>
<deb destfile="${dist}/bin/jetrix-${version}.deb" control="${build}/control" compression="bzip2">
<fileset dir="src/etc/deb/data"/>
<tarfileset prefix="/usr/share/jetrix" dir="${build}/dist" username="root" group="root" filemode="755">
<include name="jetrix"/>
</tarfileset>
<tarfileset prefix="/usr/share/jetrix" dir="${build}/dist" username="root" group="root">
<exclude name="jetrix"/>
<exclude name="*.bat"/>
</tarfileset>
</deb>
</target>
<target name="dist.win" depends="deploy" description="Build the Windows installer">
<taskdef name="nsis" classname="net.sf.nsisant.Task" classpath="lib/build/nsisant-1.2.jar"/>
<condition property="nsis.home" value="C:\Program Files\NSIS" else="/usr/bin">
<os family="windows"/>
</condition>
<!-- Build the windows executable file jetrix.exe -->
<mkdir dir="${build}/bin"/>
<copy todir="${build}/bin" filtering="true">
<fileset dir="${src}/bin" includes="*.nsi"/>
</copy>
<copy file="${src}/etc/icons/jetrix.ico" todir="${build}/bin"/>
<nsis verbosity="3" script="${build}/bin/launcher.nsi" path="${nsis.home}">
<define name="OUT_DIR" value="${build}/bin"/>
</nsis>
<!-- Build the installer -->
<nsis verbosity="3" script="${build}/bin/installer.nsi" path="${nsis.home}">
<define name="OUT_DIR" value="${build}/bin"/>
</nsis>
<move file="${build}/bin/jetrix-${version}-installer.exe" todir="${dist}/bin"/>
</target>
<target name="dist.src" description="Build source distribution">
<!-- Create the source distribution directory -->
<mkdir dir="${dist}/src"/>
<zip zipfile="${dist}/src/jetrix-${version}-src.zip">
<zipfileset prefix="jetrix-${version}-src/" dir=".">
<include name="build.xml" />
<include name="project.xml" />
<include name="project.properties" />
</zipfileset>
<zipfileset prefix="jetrix-${version}-src/src/" dir="${src}" excludes="site/"/>
<zipfileset prefix="jetrix-${version}-src/lib/" dir="${lib}" />
</zip>
<tar destfile="${dist}/src/jetrix-${version}-src.tar">
<tarfileset prefix="jetrix-${version}-src/" dir=".">
<include name="build.xml" />
<include name="project.xml" />
<include name="project.properties" />
</tarfileset>
<tarfileset prefix="jetrix-${version}-src/src/" dir="${src}" excludes="site/"/>
<tarfileset prefix="jetrix-${version}-src/lib/" dir="${lib}" />
</tar>
<bzip2 zipfile="${dist}/src/jetrix-${version}-src.tar.bz2" src="${dist}/src/jetrix-${version}-src.tar"/>
<delete file="${dist}/src/jetrix-${version}-src.tar"/>
</target>
<target name="dist.all" depends="clean, dist, dist.src, dist.win, dist.linux" description="Build all distributed files"/>
<target name="deploy" depends="dist">
<delete dir="${deploy}"/>
<mkdir dir="${deploy}"/>
<unzip src="${dist}/bin/jetrix-${version}.zip" dest="${deploy}" />
<chmod file="${deploy}/jetrix-${version}/jetrix" perm="+x"/>
</target>
<target name="run" depends="deploy">
<java dir="${deploy}/jetrix-${version}" jar="${deploy}/jetrix-${version}/lib/jetrix-launcher-${version}.jar" fork="true">
<sysproperty key="jetrix.debug" value="true"/>
<arg value="--conf"/>
<arg value="conf/server.xml"/>
</java>
</target>
<target name="docgen" depends="compile" description="Generates the documentation of the server commands">
<java classname="net.jetrix.tools.DocumentationGenerator" fork="true">
<classpath>
<pathelement path="${build}/classes"/>
<pathelement path="${src}/etc"/>
<pathelement path="${src}/lang"/>
<fileset dir="lib" includes="*.jar"/>
</classpath>
</java>
</target>
<target name="site" depends="docgen" description="Generate and publish the web site to SourceForge">
<!-- Create the site distribution directory -->
<mkdir dir="${dist}/site/docs"/>
<!-- Build the project reports with Maven-->
<property environment="env"/>
<exec executable="${env.MVN_HOME}/bin/mvn.bat" osfamily="windows"><arg line="site"/></exec>
<exec executable="mvn" osfamily="unix"><arg line="site"/></exec>
<!-- Copy the project reports -->
<copy todir="${dist}/site/docs">
<fileset dir="target/site"/>
</copy>
<!-- Copy the site -->
<property file="project.properties"/>
<filter token="version.stable" value="${version.stable}"/>
<filter token="version" value="${version}"/>
<copy todir="${dist}/site" filtering="true" overwrite="true">
<fileset dir="src/site">
<exclude name="**/*.png"/>
<exclude name="**/*.ico"/>
</fileset>
</copy>
<copy todir="${dist}/site" overwrite="true">
<fileset dir="src/site">
<include name="**/*.png"/>
<include name="**/*.ico"/>
</fileset>
</copy>
<!-- Update the news from the RSS feed -->
<get src="http://sourceforge.net/export/rss2_projnews.php?group_id=52188&rss_fulltext=1"
dest="${dist}/site/jetrix-rss.xml"/>
<xslt in="${dist}/site/jetrix-rss.xml" out="${dist}/site//news.html" style="src/site/jetrix-rss.xsl"/>
<replace file="${dist}/site/news.html">
<replacefilter token="&gt;" value=">"/>
<replacefilter token="&lt;" value="<"/>
<replacefilter token="<br>" value="<br />"/>
</replace>
<replaceregexp file="${dist}/site/news.html" byline="true">
<regexp pattern="\(<a href=.*comments</a>\)"/>
<substitution expression=" "/>
</replaceregexp>
<tar destfile="${dist}/site.tar.bz2" compression="bzip2">
<tarfileset dir="${dist}/site"/>
</tar>
<property name="username" value="smanux,jetrix"/>
<property name="deploy.dir" value="/home/groups/j/je/jetrix"/>
<input addproperty="password" message="SourceForge Password:"/>
<scp file="${dist}/site.tar.bz2" todir="${username}:${password}@web.sourceforge.net:${deploy.dir}" trust="true"/>
<sshexec host="shell.sf.net" username="${username}" password="${password}" trust="true" command="create"/>
<sshexec host="shell.sf.net" username="${username}" password="${password}" trust="true" command="tar -jxf ${deploy.dir}/site.tar.bz2 --directory=${deploy.dir}/htdocs "/>
</target>
<target name="clean">
<!-- Delete the ${build} directory tree -->
<delete dir="${dist}"/>
<delete dir="${build}"/>
<delete dir="${deploy}"/>
</target>
</project>