forked from PhantomBot/PhantomBot
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
461 lines (411 loc) · 19.8 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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
<?xml version="1.0" encoding="UTF-8"?>
<project name="PhantomBot" basedir="." default="dist" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:if="ant:if" xmlns:unless="ant:unless">
<!--
Copyright (C) 2016-2024 phantombot.github.io/PhantomBot
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!-- To specify a Nightly Build run as ant -Dbuildtype=nightly_build -->
<!-- To specify a Pre-Release Build run as ant -Dbuildtype=prerelease_build -->
<property environment="env" />
<!-- Please see this for version numbers: https://semver.org/ -->
<property name="version" value="custom" />
<property name="fallback.revision" value="unknown" />
<property name="src" location="source" />
<property name="reference" location="lib" />
<property name="reference.extra" location="lib.extra" />
<property name="build" location="build" />
<property name="classes" location="${build}/classes" />
<property name="dist" location="dist" />
<property name="version.name" value="${ant.project.name}-${version}" />
<property name="version.folder" location="${dist}/${version.name}" />
<property name="build.dir" location="${dist}/build" />
<property name="res.dir" location="${build.dir}" />
<property name="lib.dir" location="${build.dir}/lib" />
<property name="lib.extra.dir" location="${build.dir}/lib.extra" />
<property name="java.source.level" value="17"/>
<!-- Apache Ivy properties -->
<property name="ivy.install.version" value="2.5.1"/>
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME"/>
</condition>
<property name="ivy.home" value="${user.home}/.ant"/>
<property name="ivy.jar.dir" value="${ivy.home}/lib"/>
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/>
<property name="ivy.localfs.dir" location="localfs" />
<tstamp>
<format property="NOW" pattern="MMM dd yyyy HH:mm:ss zzz" timezone="GMT" />
</tstamp>
<path id="classpath">
<fileset dir="${lib.dir}" includes="**/*.jar" />
</path>
<condition property="build_type" value="${buildtype}" else="custom">
<and>
<isset property="buildtype" />
<length string="${buildtype}" trim="yes" length="0" when="greater" />
</and>
</condition>
<condition property="rollbar_token" value="${rollbar_token}" else="notoken">
<and>
<isset property="rollbar_token" />
<length string="${rollbar_token}" trim="yes" length="0" when="greater" />
</and>
</condition>
<condition property="rollbar_endpoint" value="${rollbar_endpoint}" else="">
<and>
<isset property="rollbar_endpoint" />
<length string="${rollbar_endpoint}" trim="yes" length="0" when="greater" />
</and>
</condition>
<condition property="isdocker" value="true" else="false">
<isset property="isdocker" />
</condition>
<condition property="isstresstest" value="true" else="false">
<isset property="isstresstest" />
</condition>
<available file=".git" type="dir" property="git.present"/>
<target name="download-ivy" unless="offline">
<mkdir dir="${ivy.jar.dir}"/>
<!-- download Ivy from web site so that it can be used even without any special installation -->
<get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<target name="init-ivy" depends="download-ivy">
<!-- try to load Ivy here from Ivy home, in case the user has not already dropped
it into Ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
Ivy is in at least one of Ant's lib dir or the local lib dir. -->
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
<target name="init">
<mkdir dir="${build}" />
<mkdir dir="${classes}" />
<mkdir dir="${dist}" />
<mkdir dir="${version.folder}" />
</target>
<target depends="init-ivy" name="ivy-retrieve">
<ivy:settings file="ivysettings.xml"/>
<ivy:retrieve sync="true" conf="default"/>
<ivy:retrieve sync="true" conf="lib.extra" pattern="${reference.extra}/[artifact]-[revision].[ext]"/>
<ivy:report graph="false" todir="resources/licenses/"/>
<exec executable="git" outputproperty="git.ivychange" failifexecutionfails="false" errorproperty="">
<arg value="diff"/>
<arg value="--numstat"/>
<arg value="ivy.xml"/>
</exec>
<exec executable="git" failifexecutionfails="false" errorproperty="" if:blank="${git.ivychange}">
<arg value="checkout"/>
<arg value="resources/licenses/tv.phantombot-phantombot-default.html"/>
<arg value="resources/licenses/tv.phantombot-phantombot-lib.extra.html"/>
</exec>
</target>
<target depends="init-ivy" name="ivy-cleancache">
<ivy:settings file="ivysettings.xml"/>
<ivy:cleancache/>
</target>
<target depends="init-ivy" name="ivy-list-updates">
<ivy:settings file="ivysettings.xml"/>
<ivy:checkdepsupdate/>
</target>
<target depends="init-ivy" name="ivy-list-updates-quiet">
<ivy:settings file="ivysettings.xml"/>
<ivy:checkdepsupdate log="quiet"/>
</target>
<target depends="init-ivy" name="ivy-show-tree">
<ivy:dependencytree/>
</target>
<target name="clearlib">
<delete>
<fileset dir="${reference}" includes="**/*.jar" />
<fileset dir="${reference.extra}" includes="**/*.jar" />
</delete>
</target>
<target depends="clearlib,ivy-cleancache,ivy-retrieve" name="ivy-clean-retrieve" />
<target depends="ivy-retrieve" name="classpaths">
<path id="reference.class.path">
<fileset dir="${reference}">
<include name="*.jar" />
<exclude name="*sources.jar"/>
<exclude name="*javadoc.jar"/>
</fileset>
</path>
<pathconvert property="mf.classpath" pathsep=" ">
<path refid="reference.class.path" />
<mapper>
<chainedmapper>
<flattenmapper/>
<globmapper from="*.jar" to="lib/*.jar" />
</chainedmapper>
</mapper>
</pathconvert>
</target>
<target name="git.revision" if="git.present">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="rev-parse"/>
<arg value="--short"/>
<arg value="HEAD"/>
</exec>
</target>
<target name="repository.version" depends="git.revision">
<condition property="repository.version" value="${git.revision}" else="${fallback.revision}">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
</target>
<target depends="init,ivy-retrieve,classpaths,repository.version" name="pre.compile">
<echo>${ant.project.name} Version ${version} (${repository.version}) (${build_type})</echo>
<replaceregexp
file="source/tv/phantombot/RepoVersion.java"
match="repoVersion = "(.*)";"
replace="repoVersion = "${repository.version}";" />
<replaceregexp
file="source/tv/phantombot/RepoVersion.java"
match="buildType = "(.*)";"
replace="buildType = "${build_type}";" />
<replaceregexp
file="source/tv/phantombot/RepoVersion.java"
match="phantomBotVersion = "(.*)";"
replace="phantomBotVersion = "${version}";" />
<replaceregexp
file="source/tv/phantombot/RepoVersion.java"
match="isDocker = false;"
replace="isDocker = ${isdocker};" />
<replaceregexp
file="source/tv/phantombot/RepoVersion.java"
match="isStressTest = false;"
replace="isStressTest = ${isstresstest};" />
<replaceregexp
file="source/com/gmt2001/RollbarProvider.java"
match="ACCESS_TOKEN = "(.*)";"
replace="ACCESS_TOKEN = "${rollbar_token}";" />
<replaceregexp
file="source/com/gmt2001/RollbarProvider.java"
match="ENDPOINT = "(.*)";"
replace="ENDPOINT = "${rollbar_endpoint}";" />
<sleep seconds="2"/>
</target>
<target depends="pre.compile" name="compile.src">
<echo>Compiling with Java Version ${ant.java.version} (${java.version}) target=${java.source.level}</echo>
<javac target="${java.source.level}" source="${java.source.level}" debug="on" destdir="${classes}" srcdir="${src}" includeantruntime="false" encoding="UTF-8">
<compilerarg value="-Xlint:unchecked" />
<compilerarg value="-Xlint:-options" />
<compilerarg value="-XDenableSunApiLintControl" />
<compilerarg line="--add-exports java.base/sun.security.x509=ALL-UNNAMED" />
<classpath refid="reference.class.path" />
</javac>
</target>
<target depends="pre.compile" name="clean.build.test">
<delete dir="${build}" />
<mkdir dir="${build}" />
<mkdir dir="${classes}" />
</target>
<target depends="clean.build.test" name="compile.src.test">
<javac target="${java.source.level}" source="${java.source.level}" debug="on" destdir="${classes}" srcdir="${src}" includeantruntime="false" encoding="UTF-8">
<compilerarg value="-Xlint:all" />
<compilerarg value="-Xlint:-options" />
<compilerarg value="-XDenableSunApiLintControl" />
<compilerarg line="--add-exports java.base/sun.security.x509=ALL-UNNAMED" />
<classpath refid="reference.class.path" />
</javac>
</target>
<target name="post.compile">
<replaceregexp
file="source/tv/phantombot/RepoVersion.java"
match="repoVersion = "(.*)";"
replace="repoVersion = "@repository.version@";" />
<replaceregexp
file="source/tv/phantombot/RepoVersion.java"
match="buildType = "(.*)";"
replace="buildType = "@buildtype@";" />
<replaceregexp
file="source/tv/phantombot/RepoVersion.java"
match="phantomBotVersion = "(.*)";"
replace="phantomBotVersion = "@phantombot.version@";" />
<replaceregexp
file="source/tv/phantombot/RepoVersion.java"
match="isDocker = (.*);"
replace="isDocker = false;" />
<replaceregexp
file="source/tv/phantombot/RepoVersion.java"
match="isStressTest = (.*);"
replace="isStressTest = false;" />
<replaceregexp
file="source/com/gmt2001/RollbarProvider.java"
match="ACCESS_TOKEN = "(.*)";"
replace="ACCESS_TOKEN = "@access.token@";" />
<replaceregexp
file="source/com/gmt2001/RollbarProvider.java"
match="ENDPOINT = "(.*)";"
replace="ENDPOINT = "@endpoint@";" />
<sleep seconds="2"/>
</target>
<target name="copy-javascript" depends="prepare-javascript-true, prepare-javascript-false">
</target>
<target name="prepare-javascript-true" depends="check-compiled" if="${compiled}">
<echo level="info" message="Phantombot ${version} already compiled, copying javascript"/>
<delete dir="${version.folder}/scripts" />
<copy todir="${version.folder}/scripts">
<fileset dir="./javascript-source" />
</copy>
</target>
<target name="prepare-javascript-false" depends="check-compiled" unless="${compiled}">
<echo level="info" message="Phantombot ${version} has not yet been compiled, compiling now"/>
<antcall target="jar"/>
</target>
<target name="check-compiled">
<available file="${version.folder}/PhantomBot.jar" property="compiled"/>
</target>
<target depends="compile.src,post.compile,repository.version" name="jar-only">
<jar destfile="${version.folder}/${ant.project.name}.jar">
<fileset dir="${classes}" />
<manifest>
<attribute name="Bundle-Name" value="${ant.project.name}" />
<attribute name="Bundle-Version" value="${version}" />
<attribute name="Bundle-Revision" value="${repository.version}" />
<attribute name="Bundle-Date" value="${NOW}" />
<attribute name="Implementation-Title" value="${ant.project.name}" />
<attribute name="Implementation-Version" value="${version}" />
<attribute name="Implementation-Revision" value="${repository.version}" />
<attribute name="Implementation-URL" value="https://phantombot.github.io/PhantomBot" />
<attribute name="Class-Path" value="${mf.classpath}" />
<attribute name="Main-Class" value="tv.phantombot.PhantomBot" />
</manifest>
</jar>
<mkdir dir="${version.folder}/lib" />
<echo level="info" message="staging lib folder into build dir." />
<copy todir="${version.folder}/lib">
<fileset dir="${reference}">
<include name="*.jar" />
<exclude name="*sources.jar"/>
<exclude name="*javadoc.jar"/>
</fileset>
</copy>
<mkdir dir="${version.folder}/lib.extra" />
<copy todir="${version.folder}/lib.extra">
<fileset dir="${reference.extra}">
<include name="*.jar" />
<exclude name="*sources.jar"/>
<exclude name="*javadoc.jar"/>
</fileset>
</copy>
</target>
<target depends="compile.src,post.compile,repository.version" name="jar">
<jar destfile="${build.dir}/${ant.project.name}.jar">
<fileset dir="${classes}" />
<manifest>
<attribute name="Bundle-Name" value="${ant.project.name}" />
<attribute name="Bundle-Version" value="${version}" />
<attribute name="Bundle-Revision" value="${repository.version}" />
<attribute name="Bundle-Date" value="${NOW}" />
<attribute name="Implementation-Title" value="${ant.project.name}" />
<attribute name="Implementation-Version" value="${version}" />
<attribute name="Implementation-Revision" value="${repository.version}" />
<attribute name="Implementation-URL" value="https://phantombot.github.io/PhantomBot" />
<attribute name="Class-Path" value="${mf.classpath}" />
<attribute name="Main-Class" value="tv.phantombot.PhantomBot" />
</manifest>
</jar>
<mkdir dir="${lib.dir}" />
<echo level="info" message="staging lib folder into build dir." />
<copy todir="${lib.dir}">
<fileset dir="${reference}">
<include name="*.jar" />
<exclude name="*sources.jar"/>
<exclude name="*javadoc.jar"/>
</fileset>
</copy>
<mkdir dir="${lib.extra.dir}" />
<copy todir="${lib.extra.dir}">
<fileset dir="${reference.extra}">
<include name="*.jar" />
<exclude name="*sources.jar"/>
<exclude name="*javadoc.jar"/>
</fileset>
</copy>
<echo level="info" message="staging resources folder into build dir." />
<copy todir="${res.dir}">
<fileset dir="./resources" />
</copy>
<echo level="info" message="staging javascript-source folder into build dir." />
<copy todir="${res.dir}/scripts">
<fileset dir="./javascript-source" />
</copy>
<echo level="info" message="staging files into distribution folder." />
<move todir="${version.folder}">
<fileset dir="${build.dir}" />
</move>
</target>
<target depends="clean-no-post,jar" name="clean-jar"/>
<target depends="compile.src.test,post.compile" name="test"/>
<target name="run" depends="jar">
<java fork="true" classname="tv.phantombot.PhantomBot" dir="${build.dir}">
<classpath>
<path refid="classpath" />
<path location="${build.dir}/${ant.project.name}.jar" />
</classpath>
</java>
</target>
<target depends="jar" name="dist">
<delete file="${dist}/${version.name}.zip" />
<zip destfile="${dist}/${version.name}.zip" basedir="${dist}" update="false">
<include name="${version.name}/**" />
</zip>
</target>
<target name="clean-no-post" depends="repository.version">
<delete dir="${build}" />
</target>
<target name="clean" depends="clean-no-post,post.compile">
<delete dir="${build}" />
</target>
<target name="distclean" depends="clean">
<delete dir="${dist}" />
</target>
<target name="javadoc">
<javadoc destdir="${dist}/javadoc"
author="true"
sourcepath="source"
useexternalfile="true"
source="${java.source.level}"
windowtitle="PhantomBot JavaDoc"
additionalparam="--allow-script-in-comments"
docencoding="utf8"
charset="utf8">
<classpath>
<fileset dir="${reference}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<link href="https://docs.oracle.com/en/java/javase/${java.source.level}/docs/api/" />
<link href="https://javadoc.io/doc/com.discord4j/discord4j-common/latest/" />
<link href="https://javadoc.io/doc/com.discord4j/discord4j-core/latest/" />
<link href="https://javadoc.io/doc/com.discord4j/discord4j-rest/latest/" />
<link href="https://stleary.github.io/JSON-java/" />
<link href="https://netty.io/4.1/api/" />
<link href="https://projectreactor.io/docs/core/release/api/" />
<link href="https://projectreactor.io/docs/netty/release/api/" />
<link href="https://www.jooq.org/javadoc/latest/" />
<doctitle><![CDATA[<h1>PhantomBot</h1>]]></doctitle>
<header><![CDATA[
<a id="javadoc-stable" href="/javadoc-stable/index.html">Stable</a> | <a id="javadoc-nightly" href="/javadoc/index.html">Nightly</a>
<script>
document.getElementById('javadoc-' + (window.location.pathname.includes('javadoc-stable') ? 'stable' : 'nightly')).style.fontWeight = 'bold';
</script>
]]></header>
<bottom><![CDATA[<i>Copyright © 2016-2024 phantombot.github.io/PhantomBot</i>]]></bottom>
</javadoc>
</target>
</project>