forked from PhantomBot/PhantomBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
194 lines (171 loc) · 7.89 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="PhantomBot" basedir="." default="dist">
<!-- To specify a Nightly Build run as ant -Dnightly=nightly_build -->
<property environment="env" />
<property name="version" value="2.3.6" />
<property name="webpanel.version" value="1.1" />
<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="nightly_build" value="${nightly}" else="not_nightly">
<and>
<isset property="nightly" />
<length string="${nightly}" 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}) (${nightly_build})</echo>
<echo>${ant.project.name} Control Panel Version ${webpanel.version}</echo>
<replaceregexp
file="source/me/mast3rplan/phantombot/RepoVersion.java"
match="repoVersion = "(.*)";"
replace="repoVersion = "${repository.version}";" />
<replaceregexp
file="source/me/mast3rplan/phantombot/RepoVersion.java"
match="nightlyBuild = "(.*)";"
replace="nightlyBuild = "${nightly_build}";" />
<replaceregexp
file="source/me/mast3rplan/phantombot/RepoVersion.java"
match="phantomBotVersion = "(.*)";"
replace="phantomBotVersion = "${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/me/mast3rplan/phantombot/RepoVersion.java"
match="repoVersion = "(.*)";"
replace="repoVersion = "@repository.version@";" />
<replaceregexp
file="source/me/mast3rplan/phantombot/RepoVersion.java"
match="nightlyBuild = "(.*)";"
replace="nightlyBuild = "@nightly.build@";" />
<replaceregexp
file="source/me/mast3rplan/phantombot/RepoVersion.java"
match="phantomBotVersion = "(.*)";"
replace="phantomBotVersion = "@phantombot.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="me.mast3rplan.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/panelUtils.js"
match="PANEL_VERSION = "(.*)";"
replace="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="me.mast3rplan.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}" />
</target>
</project>