forked from MinimallyCorrect/TickThreading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
256 lines (208 loc) · 8.33 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
<!--suppress AntResolveInspection -->
<project name="TickThreading" default="main" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<property environment="env"/>
<!-- Properties -->
<property name="build.dir" value="build"/>
<property name="src.dir" value="src"/>
<property name="lib.dir" value="libs"/>
<property name="download.dir" value="download"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="target"/>
<property name="forge.dir" value="${build.dir}/forge"/>
<property name="mcp.dir" value="${forge.dir}/mcp"/>
<property name="mcpsrc.dir" value="${mcp.dir}/src"/>
<property name="mc.version" value="1.5.2"/>
<property name="forge.version" value="7.8.1.737"/>
<property name="forge.name" value="minecraftforge-src-${mc.version}-${forge.version}.zip"/>
<property name="maven-ant-tasks.name" value="maven-ant-tasks-2.1.3.jar"/>
<property name="maven-ant-tasks.url" value="http://apache.mirrors.timporter.net/maven/ant-tasks/2.1.3/binaries/${maven-ant-tasks.name}"/>
<available property="forge-exists" file="${download.dir}/${forge.name}"/>
<available property="maven-ant-tasks-exists" file="${lib.dir}/${maven-ant-tasks.name}"/>
<condition property="out-of-date">
<not>
<and>
<available file="${download.dir}/${forge.name}"/>
<available file="${mcpsrc.dir}"/>
</and>
</not>
</condition>
<path id="class.path">
<fileset dir="${mcp.dir}/lib">
<include name="**/*.jar"/>
</fileset>
</path>
<mkdir dir="${download.dir}"/>
<mkdir dir="${lib.dir}"/>
<mkdir dir="${build.dir}"/>
<!-- Targets -->
<!-- Clear build directory -->
<target name="clean">
<delete dir="${build.dir}"/>
<mkdir dir="${build.dir}"/>
</target>
<!-- Set full version -->
<target name="initialize-version" depends="version-provided,version-not-provided">
<property name="project.version.full" value="${mc.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>
<!-- Download necessary files -->
<target name="download-files" depends="download-forge,download-maven-ant-tasks"/>
<!-- Download Maven Ant Tasks -->
<target name="download-maven-ant-tasks" unless="maven-ant-tasks-exists">
<get src="${maven-ant-tasks.url}" dest="${lib.dir}/${maven-ant-tasks.name}"/>
</target>
<!-- 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>
<!-- Downloads libs -->
<target name="download-libs">
<path
id="maven-ant-tasks.classpath"
path="${lib.dir}/${maven-ant-tasks.name}"/>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath">
</typedef>
<artifact:dependencies filesetId="dependency.fileset"
versionsId="dependency.versions">
<artifact:dependency groupId="org.javassist" artifactId="javassist" version="3.17.1-GA"/>
<artifact:dependency groupId="com.github.stephenc.high-scale-lib" artifactId="high-scale-lib" version="1.1.4"/>
<artifact:dependency groupId="org.codehaus.jackson" artifactId="jackson-core-lgpl" version="1.9.12"/>
<artifact:dependency groupId="org.codehaus.jackson" artifactId="jackson-mapper-lgpl" version="1.9.12"/>
</artifact:dependencies>
<copy todir="${lib.dir}">
<fileset refid="dependency.fileset"/>
<mapper classpathref="maven-ant-tasks.classpath"
classname="org.apache.maven.artifact.ant.VersionMapper"
from="${dependency.versions}" to="flatten"/>
</copy>
</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="prepatch">
<mkdir dir="${classes.dir}"/>
<javac includeantruntime="false" srcdir="${src.dir}/nmsprepatcher" destdir="${classes.dir}" debug="on" source="1.6">
<classpath>
<path refid="class.path"/>
</classpath>
</javac>
<java classname="nallar.nmsprepatcher.Main">
<classpath>
<path refid="class.path"/>
<pathelement location="${classes.dir}"/>
</classpath>
<arg value="${src.dir}/common/nallar/patched"/>
<arg value="${mcpsrc.dir}/minecraft"/>
</java>
</target>
<target name="compile" depends="initialize-version,setup,download-libs,prepatch">
<delete dir="${classes.dir}"/>
<mkdir dir="${classes.dir}"/>
<!-- Copy sources -->
<copy todir="${mcpsrc.dir}/minecraft">
<fileset dir="${src.dir}/common"/>
<filterset>
<filter token="MC_VERSION" value="${mc.version}"/>
<filter token="MOD_VERSION" value="${project.version.full}"/>
<filter token="MOD_ID" value="${ant.project.name}"/>
<filter token="MOD_NAME" value="${ant.project.name}"/>
</filterset>
</copy>
<!-- Copy libs -->
<copy todir="${mcp.dir}/lib">
<fileset dir="${lib.dir}"/>
</copy>
<!-- Recompile -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows" failifexecutionfails="true">
<arg line="/c recompile.bat"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix" failifexecutionfails="true">
<arg value="recompile.sh"/>
</exec>
<!-- Reset src dir to post-forge-install state -->
<parallel>
<delete dir="${mcpsrc.dir}/minecraft/me/nallar"/>
<delete dir="${mcpsrc.dir}/minecraft/nallar"/>
<delete dir="${mcpsrc.dir}/minecraft/javassist"/>
<delete file="${mcpsrc.dir}/minecraft/net/minecraft/network/packet/IPacketHandler.java"/>
</parallel>
<fail message="MCP failed to build">
<condition>
<resourcecontains resource="${mcp.dir}/logs/client_compile.log" substring=" error"/>
</condition>
</fail>
<!-- Reobfuscate -->
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c reobfuscate.bat"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="reobfuscate.sh"/>
</exec>
<!-- Copy classes -->
<copy todir="${classes.dir}">
<fileset dir="${mcp.dir}/reobf/minecraft"/>
</copy>
</target>
<target name="packageDependencies">
<mkdir dir="${classes.dir}/mappings/"/>
<copy todir="${classes.dir}/mappings">
<fileset dir="${mcp.dir}/conf/">
<include name="methods.csv"/>
<include name="fields.csv"/>
<include name="packaged.srg"/>
</fileset>
</copy>
<unzip dest="${classes.dir}/" src="${lib.dir}/javassist.jar"/>
<unzip dest="${classes.dir}/" src="${lib.dir}/high-scale-lib.jar"/>
<unzip dest="${classes.dir}/" src="${lib.dir}/jackson-core-lgpl.jar"/>
<unzip dest="${classes.dir}/" src="${lib.dir}/jackson-mapper-lgpl.jar"/>
<delete file="${classes.dir}/net/minecraft/server/MinecraftServer.class"/>
<delete dir="${classes.dir}/META-INF"/>
<delete dir="${classes.dir}/net/minecraftforge"/>
<delete dir="${classes.dir}/cpw/"/>
<delete>
<fileset dir="${classes.dir}">
<include name="*.class"/>
</fileset>
</delete>
</target>
<!-- Package the compiled files -->
<target name="package" depends="initialize-version">
<!-- Copy resources -->
<copy todir="${classes.dir}">
<fileset dir="resources"/>
<filterset>
<filter token="MC_VERSION" value="${mc.version}"/>
<filter token="MOD_VERSION" value="${project.version.full}"/>
<filter token="MOD_ID" value="${ant.project.name}"/>
<filter token="MOD_NAME" value="${ant.project.name}"/>
</filterset>
</copy>
<delete dir="${jar.dir}"/>
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}"/>
<copy file="${jar.dir}/${ant.project.name}.jar" tofile="${jar.dir}/${ant.project.name}-${project.version.full}.jar"/>
</target>
<!-- Default target to run -->
<target name="main" depends="compile,packageDependencies,package"/>
</project>