-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.xml
349 lines (294 loc) · 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
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
<project name="lloverlay" default="main">
<property environment="env" />
<condition property="build_number" value="-${env.BUILD_NUMBER}" else="">
<isset property="env.BUILD_NUMBER" />
</condition>
<!-- Properties -->
<dirname property="imported.basedir" file="${ant.file.lloverlay}" />
<property name="build.dir" value="build" />
<property name="src.dir" value="${imported.basedir}" />
<property name="resources.dir" value="${imported.basedir}/resources" />
<property name="vanilla_src.dir" value="vanilla_src" />
<property name="forge_src.dir" value="forge_src" />
<property name="vanilla_diff.dir" value="vanilla_diff" />
<property name="vanilla_diff.filename" value="${vanilla_diff.dir}/src_minecraft.diff" />
<available property="diff-vanilla-exists" file="${vanilla_diff.filename}" />
<condition property="diff-vanilla-out-of-date">
<not>
<and>
<isset property="diff-vanilla-exists" />
<available file="${vanilla_diff.filename}" />
</and>
</not>
</condition>
<property name="vanilla_classes.dir" value="${build.dir}/vanilla_classes"/>
<property name="forge_classes.dir" value="${build.dir}/forge_classes"/>
<property name="jar.dir" value="packages"/>
<!-- used to download forge & mcp into -->
<property name="download.dir" value="download" />
<!-- used to copy assets from before forge setup -->
<property name="mc.assets" value="${user.home}/.minecraft/assets" />
<property name="mcp.dir" value="${build.dir}/mcp" />
<property name="mcp_src.dir" value="${mcp.dir}/src" />
<property name="forge.dir" value="${build.dir}/forge" />
<property name="forge_mcp.dir" value="${forge.dir}/mcp" />
<property name="forge_mcp_src.dir" value="${forge_mcp.dir}/src" />
<!-- setup versions -->
<property name="lloverlay.version" value="0.23" />
<property name="mc.version" value="1.6.4" />
<property name="mcp.version" value="811" />
<property name="forge.version" value="9.11.0.886" />
<property name="mcp.filename" value="mcp${mcp.version}.zip" />
<property name="forge.filename" value="minecraftforge-src-${mc.version}-${forge.version}.zip" />
<available property="mcp-exists" file="${download.dir}/${mcp.filename}" />
<available property="forge-exists" file="${download.dir}/${forge.filename}" />
<available property="mc-assets-exists" file="${mc.assets}" />
<condition property="mcp-out-of-date">
<not>
<and>
<isset property="mcp-exists" />
<available file="${mcp.dir}" />
</and>
</not>
</condition>
<condition property="forge-out-of-date">
<not>
<and>
<isset property="forge-exists" />
<available file="${forge_mcp_src.dir}" />
</and>
</not>
</condition>
<mkdir dir="${download.dir}" />
<!-- Clear build directory -->
<target name="clean">
<delete dir="${build.dir}"/>
</target>
<!-- download mcp and forge -->
<target name="download-files" depends="download-forge,download-mcp" />
<target name="download-mcp" unless="mcp-exists">
<!-- they no longer provide direct downloads :(
<get src="http://mcp.ocean-labs.de/files/${mcp.filename}" dest="${download.dir}" usetimestamp="True" />
-->
<echo>Download mcp manually! http://mcp.ocean-labs.de/</echo>
</target>
<target name="download-forge" unless="forge-exists">
<get src="http://files.minecraftforge.net/${forge.filename}" dest="${download.dir}" usetimestamp="True" />
</target>
<!-- setup mcp & forge -->
<target name="setup" depends="download-files,unzip-mcp,unzip-forge,copy-assets-forge,setup-mcp,setup-forge" />
<target name="unzip-mcp" if="mcp-out-of-date">
<delete dir="${mcp.dir}" failonerror="false" />
<mkdir dir="${mcp.dir}" />
<unzip dest="${mcp.dir}" src="${download.dir}/${mcp.filename}" />
<chmod dir="${mcp.dir}" perm="ugo+rx" includes="**.sh" />
</target>
<target name="unzip-forge" if="forge-out-of-date">
<delete dir="${forge.dir}" failonerror="false" />
<unzip dest="${forge.dir}/.." src="${download.dir}/${forge.filename}" />
<mkdir dir="${forge_mcp.dir}" />
<unzip dest="${forge_mcp.dir}" src="${download.dir}/${mcp.filename}" />
<chmod dir="${forge.dir}" perm="ugo+rx" includes="**.sh" />
</target>
<!-- copy jars/assets workaround -->
<target name="copy-assets-forge" if="mc-assets-exists">
<echo>copy assets: ${forge_mcp.dir}/jars/assets</echo>
<mkdir dir="${forge_mcp.dir}/jars/assets" />
<copy todir="${forge_mcp.dir}/jars/assets">
<fileset dir="${mc.assets}" />
</copy>
</target>
<target name="setup-mcp" depends="unzip-mcp" if="mcp-out-of-date">
<!-- install forge -->
<exec dir="${mcp.dir}" executable="sh" osfamily="unix" logError="true">
<arg value="decompile.sh"/>
</exec>
</target>
<target name="setup-forge" if="forge-out-of-date">
<!-- install forge -->
<exec dir="${forge.dir}" executable="sh" osfamily="unix" logError="true">
<arg value="install.sh"/>
</exec>
</target>
<!-- copies the mcp decompiled source to vanilla_diff/{src,src_mod}
clumsy hack to automate the process of creating the patch -->
<target name="diff-setup" depends="setup-mcp">
<delete dir="${vanilla_diff.dir}/src" failonerror="false" />
<delete dir="${vanilla_diff.dir}/src_mod" failonerror="false" />
<mkdir dir="${vanilla_diff.dir}/src" />
<copy todir="${vanilla_diff.dir}/src">
<fileset dir="${mcp.dir}/src/minecraft" />
</copy>
<copy todir="${vanilla_diff.dir}/src_mod">
<fileset dir="${vanilla_diff.dir}/src" />
</copy>
</target>
<target name="diff-create">
<exec dir="${vanilla_diff.dir}" executable="diff" osfamily="unix" logError="false" failonerror="false" output="${vanilla_diff.filename}">
<arg line="-rupN src/ src_mod/"/>
</exec>
</target>
<target name="remove-packages">
<delete includeemptydirs="true">
<fileset dir="${jar.dir}" includes="**/*" />
</delete>
<mkdir dir="${jar.dir}" />
</target>
<!-- ****** vanilla ****** -->
<!-- removes all source files present in vanilla_src and mcp/src -->
<target name="vanilla-clean">
<delete failonerror="false">
<fileset dir="${vanilla_src.dir}" />
</delete>
<delete verbose="true">
<fileset dir="${mcp_src.dir}/minecraft">
<present present="both" targetdir="${vanilla_src.dir}" />
</fileset>
</delete>
<!-- reverse vanilla diff -->
<exec dir="${mcp_src.dir}/minecraft" executable="bash" logError="false" failonerror="false">
<arg value="-c"/>
<arg value="patch -p1 -N -R < ../../../../${vanilla_diff.filename}"/>
</exec>
<!-- cleanup reobf directory -->
<delete verbose="true">
<fileset dir="${mcp.dir}/reobf" />
</delete>
</target>
<target name="vanilla-copy-src" depends="vanilla-clean">
<mkdir dir="${vanilla_src.dir}/net/minecraft/src" />
<copy todir="${vanilla_src.dir}/net/minecraft/src" verbose="true">
<fileset dir="${forge_src.dir}/cc/apoc/lloverlay/">
<exclude name="LightLevelOverlayForgeMod.java" />
</fileset>
</copy>
<replaceregexp byline="true">
<regexp pattern="package cc.apoc.lloverlay;"/>
<substitution expression="package net.minecraft.src;"/>
<fileset dir="${vanilla_src.dir}">
<include name="**/*"/>
</fileset>
</replaceregexp>
<replaceregexp byline="true">
<regexp pattern="import net.minecraft.*;"/>
<substitution expression=""/>
<fileset dir="${vanilla_src.dir}">
<include name="**/*"/>
</fileset>
</replaceregexp>
<!-- copy sources -->
<copy todir="${mcp_src.dir}/minecraft" verbose="true">
<fileset dir="${vanilla_src.dir}" />
<filterset>
<filter token="VERSION" value="${lloverlay.version}${build_number}" />
</filterset>
</copy>
<echo>apply vanilla patches</echo>
<exec dir="${mcp_src.dir}/minecraft" executable="bash" logError="true" failonerror="true">
<arg value="-c"/>
<arg value="patch -p1 < ../../../../${vanilla_diff.filename}"/>
</exec>
</target>
<target name="vanilla-compile" depends="setup,vanilla-copy-src">
<!-- recompile -->
<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="vanilla-reobf" depends="vanilla-compile">
<!-- reobfuscate -->
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="reobfuscate.sh" />
</exec>
</target>
<!-- create vanilla package -->
<target name="vanilla-package" depends="vanilla-reobf">
<mkdir dir="${vanilla_classes.dir}" />
<delete includeemptydirs="true">
<fileset dir="${vanilla_classes.dir}" includes="**/*" />
</delete>
<!-- copy classes -->
<copy todir="${vanilla_classes.dir}">
<fileset dir="${mcp.dir}/reobf/minecraft" />
</copy>
<!-- copy resources -->
<copy todir="${vanilla_classes.dir}">
<fileset dir="${resources.dir}">
<exclude name="mcmod.info" />
<exclude name="pack.mcmeta" />
</fileset>
</copy>
<move file="${vanilla_classes.dir}/assets/lloverlay" tofile="${vanilla_classes.dir}/assets/minecraft"/>
<jar destfile="${jar.dir}/lloverlay-v${lloverlay.version}${build_number}-${mc.version}-mcp${mcp.version}-vanilla.zip" basedir="${vanilla_classes.dir}" />
</target>
<!-- ****** forge ****** -->
<target name="forge-clean">
<delete verbose="true">
<fileset dir="${forge_mcp_src.dir}/minecraft">
<present present="both" targetdir="${forge_src.dir}" />
</fileset>
</delete>
<!-- cleanup reobf directory -->
<delete verbose="true">
<fileset dir="${forge_mcp.dir}/reobf" />
</delete>
</target>
<target name="forge-copy-src" depends="forge-clean">
<!-- copy sources -->
<copy todir="${forge_mcp_src.dir}/minecraft" verbose="true">
<fileset dir="${forge_src.dir}" />
<filterset>
<filter token="VERSION" value="${lloverlay.version}${build_number}" />
</filterset>
</copy>
</target>
<target name="forge-compile" depends="setup,forge-copy-src">
<!-- recompile -->
<exec dir="${forge_mcp.dir}" executable="sh" osfamily="unix">
<arg value="recompile.sh" />
</exec>
<!-- check for failure -->
<fail message="MCP failed to build">
<condition>
<resourcecontains resource="${forge_mcp.dir}/logs/client_compile.log" substring="error:" />
</condition>
</fail>
</target>
<target name="forge-reobf" depends="forge-compile">
<!-- reobfuscate -->
<exec dir="${forge_mcp.dir}" executable="sh" osfamily="unix">
<arg value="reobfuscate_srg.sh" />
</exec>
</target>
<!-- create forge package -->
<target name="forge-package" depends="forge-reobf">
<mkdir dir="${forge_classes.dir}" />
<delete includeemptydirs="true">
<fileset dir="${forge_classes.dir}" includes="**/*" />
</delete>
<!-- copy classes -->
<copy todir="${forge_classes.dir}">
<fileset dir="${forge_mcp.dir}/reobf/minecraft" />
</copy>
<!-- copy resources -->
<copy file="${resources.dir}/mcmod.info" toFile="${forge_classes.dir}/mcmod.info">
<filterset>
<filter token="VERSION" value="${lloverlay.version}${build_number}" />
</filterset>
</copy>
<copy todir="${forge_classes.dir}">
<fileset dir="${resources.dir}">
<exclude name="mcmod.info" />
</fileset>
</copy>
<mkdir dir="${jar.dir}" />
<jar destfile="${jar.dir}/lloverlay-v${lloverlay.version}${build_number}-${mc.version}-${forge.version}-forge.zip" basedir="${forge_classes.dir}" />
</target>
<target name="main" depends="remove-packages,vanilla-package,forge-package" />
</project>