File: build.xml

package info (click to toggle)
spring 104.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 47,512 kB
  • sloc: cpp: 391,093; ansic: 79,943; python: 12,356; java: 12,201; awk: 5,889; sh: 1,826; xml: 655; makefile: 486; perl: 405; php: 211; objc: 194; sed: 2
file content (279 lines) | stat: -rw-r--r-- 9,289 bytes parent folder | download | duplicates (7)
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
<?xml version="1.0"?>

<!--
	Do not edit this file!
	But edit ant.properties instead.

	@author: Robin Vobruba <hoijui.quaero@gmail.com>
-->
<project name="JavaSkirmishAI" basedir="../" default="pack">
	<!--
		Targets:
		* compile:       compile java source files
		* doc:           generate javadoc
		* pack,archive:  archive java classes and sources into jar files
		* dist,install:  install these two jar files and the data dir
		* bump-version:  changes the version string in VERSION
		                 and data/AIInfo.lua
		* create-independent:
			Copies this project to a specified location and gives it a new name.
			It is assured that the new project dir then contains everything
			needed to compile the AI.
	-->

	<!-- These can not be changed from within "bin/ant.properties". -->
	<property name="src" location="src"/>
	<property name="bin.dir" location="bin"/>
	<property name="jar.file.name"      value="SkirmishAI"/>
	<property name="jar.file.name.bin"  value="${jar.file.name}.jar"/>
	<property name="jar.file.name.src"  value="${jar.file.name}-src.jar"/>
	<property name="independent.interface.libs.dir"  value="jlibs-interface"/>

	<!-- If it is true, we are in a independent project. -->
	<available file="${independent.interface.libs.dir}" property="independent"/>
		<condition property="proj.dep.type"
				value="independent"
				else="dependent">
			<istrue value="${independent}"/>
		</condition>


	<path id="source.path.id">
		<pathelement path="${src}"/>
	</path>
	<path id="class.path.base">
		<fileset dir="data">
			<include name="jlib/**/*.jar"/>
		</fileset>
	</path>


	<target name="init-dependent" unless="independent">

		<property file="bin/ant.${proj.dep.type}.properties"/>
		<!--
			The following values may be overriden in either
			"bin/ant.dependent.properties" or any other properties file
			which may be specified to ant on the command line like this:
			ant -propertyfile someFile.properties
		-->
		<!-- read content of file VERSION into the property -->
		<loadfile property="skirmish.ai.version"  srcFile="VERSION"/>
		<!-- use the projects root dir name as project name -->
		<basename property="skirmish.ai.name"     file="."/>
		<property name="spring.home"              location="../../.."/>
		<property name="build.home"               location="${spring.home}"/>
		<property name="build.dir"                location="${build.home}/AI/Skirmish/${skirmish.ai.name}"/>
		<property name="build.classes.dir"        location="${build.dir}/classes"/>
		<property name="dist.home"                location="${spring.home}/dist"/>
		<property name="dist.dir"                 location="${dist.home}/AI/Skirmish/${skirmish.ai.name}/${skirmish.ai.version}"/>
		<property name="doc.dir"                  location="${dist.home}/AI/Skirmish/${skirmish.ai.name}/${skirmish.ai.version}/doc/jdoc"/>
		<property name="ai.interface.src.home"    location="${spring.home}/AI/Interfaces/Java"/>
		<property name="ai.interface.build.home"  location="${build.home}/AI/Interfaces/Java"/>
		<property name="ai.interface.jar"         location="${ai.interface.build.home}/AIInterface.jar"/>

		<available file="${ai.interface.jar}" property="ai.interface.jar.exists"/>
		<fail message="File not found: ${ai.interface.jar}" unless="ai.interface.jar.exists">.
File not found: ${ai.interface.jar}
Please make sure to compile the Java AI Interface
before trying to compile this AI, or request
an independent version of this project from
wherever you got this AI from.
		</fail>

		<path id="class.path.id">
			<path refid="class.path.base"/>
			<fileset dir="${ai.interface.src.home}/data">
				<include name="jlib/**/*.jar"/>
			</fileset>
			<fileset dir="${ai.interface.build.home}">
				<include name="AIInterface.jar"/>
			</fileset>
		</path>
	</target>


	<target name="init-independent" if="independent">

		<property file="bin/ant.${proj.dep.type}.properties"/>
		<!--
			The following values may be overriden in either
			"bin/ant.independent.properties" or any other properties file
			which may be specified to ant on the command line like this:
			ant -propertyfile someFile.properties
		-->
		<!-- read content of file VERSION into the property -->
		<loadfile property="skirmish.ai.version"  srcFile="VERSION"/>
		<!-- use the projects root dir name as project name -->
		<basename property="skirmish.ai.name"     file="."/>
		<property name="build.home"               location="build"/>
		<property name="build.dir"                location="${build.home}"/>
		<property name="build.classes.dir"        location="${build.dir}/classes"/>
		<property name="dist.home"                location="dist"/>
		<property name="dist.dir"                 location="${dist.home}/AI/Skirmish/${skirmish.ai.name}/${skirmish.ai.version}"/>

		<path id="class.path.id">
			<path refid="class.path.base"/>
			<fileset dir="${independent.interface.libs.dir}">
				<include name="**/*.jar"/>
			</fileset>
		</path>
	</target>


	<target name="init" depends="init-independent,init-dependent">
		<mkdir dir="${build.dir}"/>
		<mkdir dir="${build.classes.dir}"/>
	</target>


	<target name="bump-version" depends="init">

		<fail message="Please specify the version to bump to, for example: ant bump-version -Dversion.new=0.5">
			<condition>
				<not><isset property="version.new"/></not>
			</condition>
		</fail>

		<property name="skirmish.ai.version.new" value="${version.new}"/>

		<!--
			Set the new version in the files:
			* VERSION
			* data/AIInfo.lua
		-->
		<echo file="VERSION" message="${skirmish.ai.version.new}"/>
		<replace file="data/AIInfo.lua"
				token="'${skirmish.ai.version}', -- AI version"
				value="'${skirmish.ai.version.new}', -- AI version"/>

		<echo level="info">Successfully bumped ${skirmish.ai.name} version from ${skirmish.ai.version} to ${skirmish.ai.version.new}.</echo>
	</target>


	<target name="compile" depends="init">
		<javac destdir="${build.classes.dir}" debug="true">
			<src refid="source.path.id"/>
			<classpath refid="class.path.id"/>
		</javac>
	</target>


	<target name="doc" depends="init">
		<mkdir dir="${doc.dir}"/>
		<javadoc
				destdir="${doc.dir}"
				sourcepathref="source.path.id"
				classpathref="class.path.id"
				Windowtitle="${skirmish.ai.name} ${skirmish.ai.version} javadoc"/>
	</target>


	<target name="pack-bin" depends="compile">
		<jar destfile="${build.dir}/${jar.file.name.bin}">
			<fileset dir="${build.classes.dir}">
				<include name="**/*.class"/>
			</fileset>
		</jar>
	</target>

	<target name="pack-src" depends="init">
		<jar destfile="${build.dir}/${jar.file.name.src}">
			<fileset dir="${src}">
				<include name="**/*.java"/>
			</fileset>
		</jar>
	</target>

	<target name="pack" depends="pack-bin, pack-src"/>
	<target name="archive" depends="pack"/>


	<target name="dist" depends="pack"
				description="install the built jars and the data files" >
		<mkdir dir="${dist.dir}/jlib"/>
		<copy file="${build.dir}/${jar.file.name.bin}"
				todir="${dist.dir}" overwrite="true"/>
		<copy file="${build.dir}/${jar.file.name.src}"
				todir="${dist.dir}/jlib" overwrite="true"/>
		<copy todir="${dist.dir}" overwrite="true">
			<fileset dir="data"/>
		</copy>
	</target>
	<target name="install" depends="dist"/>


	<target name="clean" depends="init">
		<delete dir="${build.dir}"/>
	</target>


	<target name="create-independent" depends="init">

		<fail>.
Please specify either home.new or name.new, for example:
	ant create-independent -Dhome.new=~/projects/SpringSkirmishAIs/
or
	ant create-independent -Dname.new=MyJavaAI
			<condition>
				<and>
					<not><isset property="home.new"/></not>
					<not><isset property="name.new"/></not>
				</and>
			</condition>
		</fail>

		<!-- use the current project name, if no new one was specified -->
		<condition property="skirmish.ai.name.new"
				value="${name.new}"
				else="${skirmish.ai.name}">
			<isset property="name.new"/>
		</condition>

		<!-- use the current project home, if no new one was specified -->
		<dirname property="home.current" file="."/>
		<condition property="skirmish.ai.home.new"
				value="${home.new}"
				else="${home.current}">
			<isset property="home.new"/>
		</condition>

		<property name="project.dir.new"
				location="${skirmish.ai.home.new}/${skirmish.ai.name.new}"/>

		<!-- copy the whole project as it is -->
		<copy todir="${project.dir.new}" overwrite="false">
			<fileset dir="."/>
		</copy>

		<antcall target="create-independent-addons-independent"/>

		<!-- set the new project name in AIInfo.lua -->
		<replace file="${project.dir.new}/data/AIInfo.lua"
				token="'${skirmish.ai.name}'"
				value="'${skirmish.ai.name.new}'"/>
		
		<echo level="info">
Spring source independant Java Skirmish AI project copied to:
	${project.dir.new}

You may want to change your java source package structure
and the data/AIInto.lua file for the new project.
		</echo>

	</target>

	<target name="create-independent-addons-independent" unless="independent">

		<!-- copy the interface jars -->
		<copy todir="${project.dir.new}/${independent.interface.libs.dir}" overwrite="false">
			<fileset dir="${ai.interface.src.home}/data">
				<include name="jlib/**/*.jar"/>
			</fileset>
			<fileset dir="${ai.interface.build.home}"
					includes="AIInterface*.jar"/>
		</copy>

	</target>

</project>