forked from walterhiggins/ScriptCraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
217 lines (179 loc) · 7.66 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
<project name="scriptcraft" default="package" basedir=".">
<property file="build.properties"/>
<description>Builds the scriptcraft.jar file - a plugin for bukkit</description>
<property name="src" location="src/main/java"/>
<property name="build" location="target/classes"/>
<property name="dist" location="target/" />
<property name="minecraft.dir" location="${dist}/minecraft" />
<property name="js-plugins-dir" value="scriptcraft"/>
<property name="http.agent" value="'Walter'" />
<target name="init">
<property file="build.local.properties"/>
<tstamp>
<format property="DSTAMP"
pattern="yyyy-MM-dd"
locale="en,UK"/>
</tstamp>
<mkdir dir="${build}"/>
<available file="${minecraft.dir}" property="minecraft.present"/>
<available file="${dist}/js/modules/underscore.js" property="underscore.present"/>
</target>
<target name="test" depends="package" description="Perform unit tests">
</target>
<target name="server-setup" depends="init" description="Downloads the latest bukkit dev jar"
unless="minecraft.present">
<mkdir dir="${minecraft.dir}" />
<echo>Retrieving CraftBukkit artifact info</echo>
<get src="http://dl.bukkit.org/api/1.0/downloads/projects/CraftBukkit/?_accept=application/xml"
verbose="true"
httpusecaches="false"
dest="${minecraft.dir}/bukkit.xml" />
<xslt in="${minecraft.dir}/bukkit.xml"
out="${minecraft.dir}/ant.properties.xml"
style="build/bukkit-to-url.xsl"/>
<xmlproperty file="${minecraft.dir}/ant.properties.xml" keeproot="true"/>
<echo>Retrieving CraftBukkit jar</echo>
<get src="${bukkit.url}"
dest="${minecraft.dir}/craftbukkit.jar"
verbose="true"/>
<echo>Creating default ops.txt for your user</echo>
<echo message="${op.name}" file="${minecraft.dir}/ops.txt" />
</target>
<target name="run" depends="server-setup, package, update-live-cb" description="Starts Bukkit with ScriptCraft">
<echo>Starting Bukkit with ScriptCraft</echo>
<java jar="${minecraft.dir}/craftbukkit.jar" maxmemory="1024m" fork="true" dir="${minecraft.dir}" />
</target>
<target name="compile" depends="init, server-setup" description="compile bukkit plugin source">
<javac includeantruntime="false"
srcdir="${src}"
source="1.6"
target="1.6"
destdir="${build}"
debug="true"
classpath="${minecraft.dir}/craftbukkit.jar" />
</target>
<target name="gendocs" depends="construct-ypgpm, construct-api-ref" description="Generate API documentation">
</target>
<target name="compile-docs" depends="init">
<javac includeantruntime="false"
srcdir="src/docs/java"
destdir="${build}"
/>
</target>
<target name="generate-api-ref-entries" depends="copy-js,compile-docs,init">
<java classname="jscript" failonerror="true" fork="true" output="${dist}/apiref.md">
<classpath>
<pathelement path="${build}"/>
</classpath>
<arg value="src/docs/js/generateApiDocs.js"/>
<arg value="${dist}/js"/>
</java>
</target>
<target name="gen-events-helper" depends="compile-docs,server-setup,init">
<mkdir dir="${dist}/js/lib"/>
<java classname="jscript" failonerror="true" fork="true" output="${dist}/js/lib/events-helper.js" error="${dist}/geneventserror.log">
<classpath>
<pathelement path="${build}"/>
<pathelement path="${minecraft.dir}/craftbukkit.jar"/>
</classpath>
<arg value="src/generateEventsHelper.js"/>
</java>
</target>
<target name="construct-api-ref" depends="gen-toc-apiref,init">
<concat destfile="docs/API-Reference.md">
<header filtering="no" trimleading="yes"># ScriptCraft API Reference
Walter Higgins
[[email protected]][email]
[email]: mailto:[email protected]?subject=ScriptCraft_API_Reference
</header>
<fileset file="${dist}/toc-apiref.md" />
<fileset file="${dist}/apiref.md" />
</concat>
</target>
<target name="gen-toc-apiref" depends="compile-docs,generate-api-ref-entries, init" description="Generate Table of Contents for API Reference">
<java classname="jscript" failonerror="true" fork="true" output="${dist}/toc-apiref.md">
<classpath>
<pathelement path="${build}"/>
</classpath>
<arg value="src/docs/js/generateTOC.js"/>
<arg value="${dist}/apiref.md"/>
</java>
</target>
<target name="gen-toc-ypgpm" depends="compile-docs,init" description="Generate Table of Contents for Young Programmers Guide">
<java classname="jscript" failonerror="true" fork="true" output="${dist}/toc-ypgpm.md">
<classpath>
<pathelement path="${build}"/>
</classpath>
<arg value="src/docs/js/generateTOC.js"/>
<arg value="src/docs/templates/ypgpm.md"/>
</java>
</target>
<!-- Piece together the Young persons' guide from template and generated table of contents -->
<target name="construct-ypgpm" depends="gen-toc-ypgpm,init">
<concat destfile="docs/YoungPersonsGuideToProgrammingMinecraft.md">
<header filtering="no" trimleading="yes"># The Young Person's Guide to Programming in Minecraft
</header>
<fileset file="${dist}/toc-ypgpm.md" />
<fileset file="src/docs/templates/ypgpm.md" />
</concat>
</target>
<target name="zip_js" depends="zip_lib, zip_modules, zip_plugins">
</target>
<target name="copy-js" depends="gen-events-helper,init">
<copy todir="${dist}/js">
<fileset dir="src/main/js"/>
</copy>
</target>
<target name="zip_lib" depends="copy-js">
<delete file="${build}/lib.zip"/>
<zip destfile="${build}/lib.zip"
basedir="${dist}/js"
excludes="modules/**, plugins/**,">
</zip>
</target>
<target name="get_underscore" depends="copy-js" unless="underscore.present">
<!-- download underscore -->
<get src="http://underscorejs.org/underscore.js"
verbose="true"
dest="${dist}/js/modules/underscore.js"/>
</target>
<target name="zip_modules" depends="copy-js, get_underscore">
<delete file="${build}/modules.zip"/>
<zip destfile="${build}/modules.zip"
basedir="${dist}/js"
excludes="lib/**, plugins/**,">
</zip>
</target>
<target name="zip_plugins" depends="copy-js">
<delete file="${build}/plugins.zip"/>
<zip destfile="${build}/plugins.zip"
basedir="${dist}/js"
excludes="lib/**, modules/**">
</zip>
</target>
<target name="package" depends="gendocs,zip_js,compile" description="generate the distribution" >
<!-- ensure plugin.yml is always copied -->
<delete file="${build}/plugin.yml" />
<copy todir="${build}">
<fileset dir="src/main/resources"/>
</copy>
<replace file="${build}/plugin.yml" value="${scriptcraft-version}-${DSTAMP}">
<replacetoken>[[version]]</replacetoken>
</replace>
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<mkdir dir="${dist}/${DSTAMP}" />
<jar jarfile="${dist}/${DSTAMP}/scriptcraft.jar" basedir="${build}"/>
<copy file="${dist}/${DSTAMP}/scriptcraft.jar" tofile="${dist}/scriptcraft.jar"/>
</target>
<target name="clean" description="clean up" >
<delete dir="${dist}"/>
</target>
<target name="update-live-cb" depends="package" description="Copy the built plugin to the live craftbukkit folder for testing.">
<mkdir dir="${minecraft.dir}/plugins" />
<delete>
<fileset dir="${minecraft.dir}/plugins/" includes="scriptcraft*.*"/>
</delete>
<mkdir dir="${minecraft.dir}/plugins" />
<copy file="${dist}/${DSTAMP}/scriptcraft.jar" todir="${minecraft.dir}/plugins"/>
</target>
</project>