forked from PhantomBot/PhantomBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
225 lines (196 loc) · 9.13 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="PhantomBot" basedir="." default="dist">
<!--
Copyright (C) 2016-2018 phantombot.tv
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="3.0.0" />
<!-- Please see this for version numbers: https://semver.org/ -->
<property name="webpanel.version" value="1.0.0" />
<property name="src" location="source" />
<property name="reference" location="libraries" />
<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" />
<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>
<path id="reference.class.path">
<fileset dir="${reference}">
<include name="*.jar" />
</fileset>
</path>
<condition property="build_type" value="${buildtype}" else="stable">
<and>
<isset property="buildtype" />
<length string="${buildtype}" trim="yes" length="0" when="greater" />
</and>
</condition>
<available file=".git" type="dir" property="git.present"/>
<target name="init">
<mkdir dir="${build}" />
<mkdir dir="${classes}" />
<mkdir dir="${dist}" />
<mkdir dir="${version.folder}" />
<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>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
</target>
<target depends="init,git.revision" name="pre.compile">
<echo>${ant.project.name} Version ${version} (${repository.version}) (${build_type})</echo>
<echo>${ant.project.name} Control Panel Version ${webpanel.version}</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="panelVersion = "(.*)";"
replace="panelVersion = "${webpanel.version}";" />
</target>
<target depends="pre.compile" name="compile.src">
<echo>Compiling with Java Version ${ant.java.version} (${java.version})</echo>
<javac target="1.8" source="1.8" debug="on" destdir="${classes}" srcdir="${src}" includeantruntime="false" >
<compilerarg value="-Xlint:unchecked" />
<compilerarg value="-Xlint:-options" />
<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="1.8" source="1.8" debug="on" destdir="${classes}" srcdir="${src}" includeantruntime="false" >
<compilerarg value="-Xlint:all" />
<compilerarg value="-Xlint:-options" />
<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="panelVersion = "(.*)";"
replace="panelVersion = "@webpanel.version@";" />
</target>
<target depends="compile.src,post.compile,git.revision" 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="${git.revision}" />
<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="${git.revision}" />
<attribute name="Implementation-URL" value="https://phantombot.tv" />
<attribute name="Class-Path" value="${mf.classpath}" />
<attribute name="Main-Class" value="tv.phantombot.PhantomBot" />
</manifest>
</jar>
<mkdir dir="${lib.dir}" />
<copy todir="${lib.dir}">
<fileset dir="./libraries" />
</copy>
<echo level="info" message="staging javascript-source into resources." />
<copy todir="./resources/scripts">
<fileset dir="./javascript-source" />
</copy>
<echo level="info" message="staging lib folder into resources." />
<copy todir="${res.dir}">
<fileset dir="./resources" />
</copy>
<replaceregexp
file="${build.dir}/web/panel/js/utils/helpers.js"
match="helpers\.PANEL_VERSION = "(.*)";"
replace="helpers\.PANEL_VERSION = "${webpanel.version}";" />
<echo level="info" message="staging files into distribution folder." />
<copy todir="${version.folder}">
<fileset dir="${build.dir}" />
</copy>
</target>
<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" depends="git.revision,post.compile">
<delete dir="${build}" />
</target>
<target name="distclean" depends="clean">
<delete dir="${dist}" />
<delete dir="resources/scripts" />
</target>
</project>