-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
282 lines (219 loc) · 9.49 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
<project name="QuantumCraft" default="main">
<property environment="env"/>
<!-- Properties -->
<dirname property="imported.basedir" file="${ant.file.QuantumCraft}"/>
<property name="build.dir" value="build"/>
<property name="src.dir" value="${imported.basedir}"/>
<property name="lang.dir" value="../buildcraft.localization"/>
<property name="resources.dir" value="${imported.basedir}/resources"/>
<property name="download.dir" value="download"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/dist"/>
<property name="forge.dir" value="${build.dir}/forge"/>
<property name="mcp.dir" value="${forge.dir}/mcp"/>
<property name="buildcraft.name" value="BuildCraft-mc164"/>
<property name="buildcraft.src" value="${buildcraft.name}.zip"/>
<property name="buildcraft.src.url"
value="https://dl.dropboxusercontent.com/u/5444078/QuantumCraft/apis/${buildcraft.src}"/>
<property name="buildcraft.dir" value="${mcp.dir}/unpack/buildcraft/${buildcraft.name}"/>
<property name="mcpsrc.dir" value="${mcp.dir}/src"/>
<property name="commonsrc.dir" value="${mcpsrc.dir}/minecraft"/>
<property name="mc.version" value="1.6.4"/>
<property name="forge.version" value="9.11.1.942"/>
<!-- <property name="project.version" value="0.0.0"/>-->
<property name="quantumcraft.name" value="quantumcraft"/>
<property name="forge.name" value="minecraftforge-src-${mc.version}-${forge.version}.zip"/>
<available property="forge-exists" file="${download.dir}/${forge.name}"/>
<available file="${src.dir}/.git" type="dir" property="git.present"/>
<available property="bc-exists" file="${download.dir}/${buildcraft.src}"/>
<condition property="out-of-date">
<not>
<and>
<isset property="forge-exists"/>
<available file="${mcpsrc.dir}"/>
</and>
</not>
</condition>
<condition property="api-out-of-date">
<not>
<isset property="bc-exists"/>
</not>
</condition>
<mkdir dir="${download.dir}"/>
<!-- Targets -->
<!-- Clear build directory -->
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<!-- Set full version -->
<target name="initialize-version" depends="version-provided,version-not-provided,git.revision">
<property name="project.version.full" value="${project.version}.${build.number}"/>
</target>
<!-- Set unknown build number -->
<target name="version-not-provided" unless="env.BUILD_NUMBER">
<property name="build.number" value="unknown"/>
</target>
<!-- Set build number from environment -->
<target name="version-provided" if="env.BUILD_NUMBER">
<property name="build.number" value="${env.BUILD_NUMBER}"/>
</target>
<available file="${src.dir}/.git" type="dir" property="git.present"/>
<target name="git.revision">
<exec executable="git" dir="${src.dir}" outputproperty="git.revision" failifexecutionfails="false"
errorproperty="">
<arg value="describe"/>
</exec>
<loadresource property="git.clean.revision">
<propertyresource name="git.revision"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replaceregex pattern="-[a-z0-9]+$" replace=""/>
<replacestring from="-" to="."/>
</tokenfilter>
</filterchain>
</loadresource>
<condition property="project.version" value="${git.clean.revision}" else="0.0.0">
<and>
<isset property="git.clean.revision"/>
<length string="${git.clean.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<condition property="project.complete.version" value="${git.revision}" else="0.0.0">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<echo>Building quantumcraft version ${project.complete.version} (${project.version})</echo>
</target>
<!-- Download necessary files -->
<target name="download-files" depends="download-forge"/>
<!-- Download forge (if it doesn't exist) -->
<target name="download-forge" unless="forge-exists">
<get src="http://files.minecraftforge.net/${forge.name}" dest="${download.dir}" usetimestamp="True"/>
</target>
<!-- setup APIs -->
<target name="download-apis" if="api-out-of-date">
<get src="${buildcraft.src.url}" dest="${download.dir}" usetimestamp="True"/>
</target>
<!-- Setup mcp and forge -->
<target name="setup" depends="download-files" if="out-of-date">
<delete dir="${forge.dir}" failonerror="false"/>
<unzip dest="${forge.dir}/.." src="${download.dir}/${forge.name}"/>
<!-- Fix executable permissions -->
<chmod dir="${forge.dir}" perm="ugo+rx" includes="**.sh"/>
<!-- Install forge -->
<exec dir="${forge.dir}" executable="cmd" osfamily="windows">
<arg line="/c install.cmd"/>
</exec>
<exec dir="${forge.dir}" executable="sh" osfamily="unix">
<arg value="install.sh"/>
</exec>
</target>
<target name="clean-src">
<delete verbose="true">
<fileset dir="${mcpsrc.dir}/minecraft">
<present present="both" targetdir="${src.dir}/qc_common"/>
</fileset>
</delete>
</target>
<target name="copy-src" depends="clean-src,initialize-version">
<!-- Copy sources -->
<copy todir="${mcpsrc.dir}/minecraft" verbose="true">
<fileset dir="${src.dir}/qc_common"/>
<filterset>
<filter token="VERSION" value="${project.complete.version}"/>
<filter token="BUILD_NUMBER" value="${build.number}"/>
</filterset>
</copy>
<unzip dest="${buildcraft.dir}" failOnEmptyArchive="true">
<fileset dir="${download.dir}">
<include name="${buildcraft.src}"/>
</fileset>
</unzip>
<copy todir="${commonsrc.dir}">
<fileset dir="${buildcraft.dir}/common">
<exclude name="**/buildcraft/devel"/>
</fileset>
</copy>
<copy todir="${commonsrc.dir}">
<fileset dir="${buildcraft.dir}/buildcraft_resources">
</fileset>
</copy>
<echo message="Copied BC files"/>
</target>
<target name="compile" depends="initialize-version,setup,download-apis,copy-src">
<mkdir dir="${classes.dir}"/>
<delete includeemptydirs="true">
<fileset dir="${classes.dir}" includes="**/*"/>
</delete>
<!-- Recompile -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c recompile.bat"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="recompile.sh"/>
</exec>
<!-- Check for failure -->
<fail message="MCP failed to build">
<condition>
<resourcecontains resource="${mcp.dir}/logs/client_compile.log" substring="error:"/>
</condition>
</fail>
</target>
<target name="reobf" depends="compile">
<!-- Reobfuscate -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c reobfuscate_srg.bat"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="reobfuscate_srg.sh"/>
</exec>
<!-- Copy classes -->
<copy todir="${classes.dir}">
<fileset dir="${mcp.dir}/reobf/minecraft">
<exclude name="buildcraft/"/>
</fileset>
</copy>
<!-- Copy resources -->
<copy todir="${classes.dir}">
<fileset dir="${resources.dir}">
<exclude name="build.xml"/>
</fileset>
</copy>
<!-- Copy localizations -->
<copy todir="${classes.dir}" failonerror="false">
<fileset dir="${lang.dir}">
<exclude name="README.md"/>
</fileset>
</copy>
<!-- Reset src dir to post-forge-install state -->
<delete dir="${mcpsrc.dir}/minecraft/quantumcraft"/>
</target>
<!-- Package the compiled files -->
<target name="package" depends="reobf">
<mkdir dir="${jar.dir}"/>
<delete includeemptydirs="true">
<fileset dir="${jar.dir}" includes="**/*"/>
</delete>
<condition property="jar.file.name"
value="${jar.dir}/${quantumcraft.name}-${mc.version}-${project.version.full}.jar"
else="${jar.dir}/${quantumcraft.name}-universal-${mc.version}-${project.version.full}.jar">
<isset property="forge-long-name"/>
</condition>
<jar destfile="${jar.file.name}" basedir="${classes.dir}"/>
</target>
<target name="run">
<!-- Start Client -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c startclient.bat"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="startclient.sh"/>
</exec>
</target>
<target name="test-run" depends="compile,run"/>
<!-- Default target to run -->
<target name="main" depends="package"/>
</project>