-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.xml
342 lines (300 loc) · 14.4 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
<?xml version="1.0"?>
<!--
This is ant build.xml file for building MaDKit-5 tutorials
Author: Fabien Michel
Version: 2.0
-->
<project name="MaDKit-tutorials" default="release" basedir=".">
<property name="ant.task.src.dir" value="antresources" />
<property name="author" value="Fabien Michel" />
<property name="build.dir" value="build" />
<property name="description" value="The MaDKit-5 tutorials: Illustrating MaDKit-5 with simple source code examples " />
<property name="download.url" value="http://www.madkit.net/ccount212/click.php?id=MaDKit-tutorials" />
<property name="ftp.tuto.dir" value="madkit/tutorials" />
<property name="images.dir" value="images" />
<property name="jnlp.template" value="${ant.task.src.dir}/template.jnlp" />
<property name="jnlps.dir" value="jnlp" />
<property name="lib.dir" value="lib" />
<property name="madkit.lib.dir" value="lib" />
<property name="madkit.version" value="5.3" />
<property name="project.label" value="The MaDKit-5 tutorials" />
<property name="project.website" value="www.madkit.org" />
<property name="project.zip.file" value="${ant.project.name}-project.zip" />
<property name="release.dir" value="docs" />
<property name="src.dir" value="src" />
<property name="tuto.dir" value="html" />
<property name="version" value="1.5" />
<!-- using local specific properties
The corresponding file should initialize the three following properties : jdk.api.dir and mdk.api.dir path-to-ant-contrib
valid values could be:
jdk.api.dir=/usr/share/doc/java8-openjdk/api
mdk.api.dir=${user.home}/MDK_installationDir/docs/api
path-to-ant-contrib=/usr/share/java/apache-ant
-->
<loadproperties srcfile="paths.local.properties" />
<!-- the following is only used in admin deploying tasks -->
<property name="server.info.dir" value="${user.home}/.mdk_keystore" />
<!-- for using param in ant call -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${path-to-ant-contrib}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<!-- - - - - - - - - - - - - - - - - -
target: define-ant-tasks
- - - - - - - - - - - - - - - - - -->
<target name="define-ant-tasks">
<mkdir dir="${build.dir}" />
<javac srcdir="${ant.task.src.dir}" includeantruntime="false" destdir="${build.dir}" classpath="${ant.library.dir}/ant.jar" debug="on" />
<taskdef name="createjnlpfromjavasource" classname="anttask.CreateJnlpFromJavaSource" classpath="${build.dir}" />
<taskdef name="java2html" classname="com.java2html.Java2HTMLTask" classpath="lib/j2h.jar" />
</target>
<!-- =================================
OPTIONAL:
A java web start file (.jnlp) could be also generated if possible.
Here, you can specify the web directory in which you will
put the jar and the jnlp so that it will directly work without editing.
================================= -->
<property name="web.codebase" value="http://www.madkit.net/madkit/tutorials/jnlp" />
<!-- =================================
DO NOT EDIT WHAT FOLLOWS:
This defines the main targets from the madkit jar file.
================================= -->
<import>
<javaresource name="MDK_ANT.xml">
<classpath location="${madkit.lib.dir}/madkit-${madkit.version}.jar" />
</javaresource>
</import>
<!-- =================================
target: clean
================================= -->
<target name="clean" depends="MDK_targets.clean" description="clean builds">
<delete dir="${release.dir}" />
<delete file="${jar.file}" />
</target>
<!-- =================================
target: release
================================= -->
<target name="release" depends="clean,create-tuto-project-zip-file,copy-resources,hello-world,logging,gui,communication,simulation,returncode,madkitoptions,madkitproperties">
<copy tofile="${release.dir}/index.html" file="MaDKit-tutorials.html">
<filterchain>
<expandproperties />
</filterchain>
</copy>
</target>
<!-- - - - - - - - - - - - - - - - - -
create-tuto-project-zip-file
- - - - - - - - - - - - - - - - - -->
<target name="create-tuto-project-zip-file">
<zip destfile="${release.dir}/${project.zip.file}" level="9">
<zipfileset dir="." includes=".project,${madkit.lib.dir}/${madkit.jar.name}" />
<zipfileset dir="." includes="${ant.task.src.dir}/.eclipse.project.classpath" fullpath=".classpath" />
</zip>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: copy-resources
- - - - - - - - - - - - - - - - - -->
<target name="copy-resources">
<copy todir="${release.dir}/${tuto.dir}">
<fileset dir="${images.dir}" />
</copy>
</target>
<!-- =================================
target: build_tuto_files
================================= -->
<target name="build_tuto_files" depends="define-ant-tasks">
<property name="tuto.instruction" value="\<h2\>Examples are structured in packages explicitely named and ordered according to their complexity\</h2\>" />
<property name="html.break" value="\<br/\>\<br/\>\<br/\>\<br/\>\<br/\>\<br/\>" />
<property name="tuto.download.html" value="&nbsp;&nbsp;&nbsp;&nbsp; <a href='${download.url}'><img alt='download project' style='border: 0px ; width: 17px; height: 17px;' src='http://www.madkit.net/madkit/tutorials/html/download.png'></a>" />
<fileset id="java.src.files" dir="${src.dir}/${tuto.src.dir}" includes="**/*.java" />
<java2html title="${tuto.name}" simple="no" tabsize="7" marginsize="0" header="true" footer="true" destination="${release.dir}/${tuto.dir}/${tuto.destination}">
<fileset refid="java.src.files" />
<javadoc localRef="/usr/share/doc/java8-openjdk/api" httpRef="http://docs.oracle.com/javase/8/docs/api/" />
<javadoc localRef="${mdk.api.dir}" httpRef="http://www.madkit.net/madkit/api" />
</java2html>
<!-- inserting jws -->
<replace>
<fileset dir="${release.dir}/${tuto.dir}/${tuto.destination}" includes="**/*java.html" />
<replacefilter token="#jws# " value="<script>deployJava.createWebStartLaunchButton('http://www.madkit.net/${ftp.tuto.dir}/${jnlps.dir}/" />
<replacefilter token=" #jws#" value="', '1.8.0');</script>" />
<replacefilter token=".java</font>" value=".java</font\> ${tuto.download.html}" />
<replacefilter token="/HEAD" value="script src='http://www.madkit.net/js/deployJava.js'></script></HEAD" />
</replace>
<replaceregexp match="#args#(.*)#args#" replace="">
<fileset dir="${release.dir}/${tuto.dir}/${tuto.destination}" includes="**/*java.html" />
</replaceregexp>
<!-- modifying front pages -->
<replace file="${release.dir}/${tuto.dir}/${tuto.destination}/front.html">
<replacefilter token="Instructions:-" value="<a href='http://www.madkit.org/'><img alt='MDK'
src='../MaDKit.png' style='border: 0px solid ; width: 100px; height: 100px;' align='right'></a><h1>${tuto.name}</h1>" />
<replacefilter token="Top-Left Panel Selects a Package" value="${tuto.description}" />
</replace>
<replaceregexp match="\<li\>(Text.*?|Bott.*?)li\>" replace="${html.break}" flags="gs">
<fileset dir="${release.dir}/${tuto.dir}/${tuto.destination}" includes="front.html" />
</replaceregexp>
<replaceregexp match="Credits" replace="${tuto.instruction}${html.break}${html.break}\<hr/\>Credits" flags="gs">
<fileset dir="${release.dir}/${tuto.dir}/${tuto.destination}" includes="front.html" />
</replaceregexp>
<replaceregexp match="\(If you like(.*)em>" replace="\<br/\>" flags="gs">
<fileset dir="${release.dir}/${tuto.dir}/${tuto.destination}" includes="front.html" />
</replaceregexp>
<!-- modifying index pages -->
<replaceregexp match="cols=\p{Punct}30%, 70%\p{Punct}" replace="cols='20%, 80%'" flags="gs">
<fileset dir="${release.dir}/${tuto.dir}/${tuto.destination}" includes="index.html" />
</replaceregexp>
<!-- create-jnlps -->
<property name="files" refid="java.src.files" />
<for list="${files}" delimiter=";" param="file">
<sequential>
<createjnlpfromjavasource srcfile="@{file}" jnlptemplate="${jnlp.template}" destdir="${release.dir}/${jnlps.dir}" />
</sequential>
</for>
<!-- remove jws tags from java source files -->
<copy todir="${release.dir}/${src.dir}/${tuto.src.dir}">
<fileset dir="${src.dir}/${tuto.src.dir}" />
<filterchain>
<linecontains negate="true">
<contains value="#jws#" />
</linecontains>
</filterchain>
<filterchain>
<linecontains negate="true">
<contains value="#args#" />
</linecontains>
</filterchain>
</copy>
<!-- add cleaned java sources to project zip file -->
<zip destfile="${release.dir}/${project.zip.file}" update="true">
<zipfileset dir="${release.dir}/${src.dir}/${tuto.src.dir}" prefix="${src.dir}/${tuto.src.dir}" />
</zip>
</target>
<!-- =================================
target: ftp-push
================================= -->
<target name="ftp-push" depends="release, Java-web-start">
<loadproperties srcFile="${server.info.dir}/MDK.net" />
<copy file="${jnlp.jar.gz}" todir="${release.dir}/${jnlps.dir}" />
<echo>FTP upload of TUTO : target is ${ftp.server}/${ftp.tuto.dir}</echo>
<ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" action="mkdir" remotedir="${ftp.tuto.dir}" verbose="yes" />
<ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" action="put" remotedir="${ftp.tuto.dir}">
<fileset dir="${release.dir}" excludes="${src.dir}/**" />
</ftp>
</target>
<!-- =================================
target: ftp-push-testing
================================= -->
<target name="ftp-push-testing">
<antcall target="ftp-push">
<param name="ftp.tuto.dir" value="madkit/testing/tutorials" />
</antcall>
</target>
<!-- =================================
target: test-jnlp
================================= -->
<target name="test-jnlp" description="test jnlps">
<exec executable="javaws" dir="${release.dir}/${jnlps.dir}">
<arg value="communication.ex05.Agent3.jnlp" />
</exec>
</target>
<!-- ==================================================================
Tutorials descriptions and parameters follow
================================================================== -->
<!-- - - - - - - - - - - - - - - - - -
target: hello-world
- - - - - - - - - - - - - - - - - -->
<target name="hello-world">
<antcall target="build_tuto_files">
<param name="tuto.name" value="Hello world" />
<param name="tuto.src.dir" value="helloworld" />
<param name="tuto.destination" value="hello_world" />
<param name="tuto.description" value="Getting started with MaDKit" />
</antcall>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: logging
- - - - - - - - - - - - - - - - - -->
<target name="logging">
<antcall target="build_tuto_files">
<param name="tuto.name" value="Logging" />
<param name="tuto.src.dir" value="logging" />
<param name="tuto.destination" value="logging" />
<param name="tuto.description" value="Using the agent's logging mechanism of MaDKit" />
</antcall>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: communication
- - - - - - - - - - - - - - - - - -->
<target name="communication">
<antcall target="build_tuto_files">
<param name="tuto.name" value="Communication" />
<param name="tuto.src.dir" value="communication" />
<param name="tuto.destination" value="communication" />
<param name="tuto.description" value="Communication between agents" />
</antcall>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: gui
- - - - - - - - - - - - - - - - - -->
<target name="gui">
<antcall target="build_tuto_files">
<param name="tuto.name" value="GUI with MaDKit" />
<param name="tuto.src.dir" value="gui" />
<param name="tuto.destination" value="gui" />
<param name="tuto.description" value="Basics for building GUIs for your multiagent application" />
</antcall>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: simulation
- - - - - - - - - - - - - - - - - -->
<target name="simulation">
<antcall target="build_tuto_files">
<param name="tuto.name" value="Simulation with MaDKit" />
<param name="tuto.src.dir" value="simulation" />
<param name="tuto.destination" value="simulation" />
<param name="tuto.description" value="Basics for building simulators with MaDKit" />
</antcall>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: conversation
- - - - - - - - - - - - - - - - - -->
<target name="conversation">
<antcall target="build_tuto_files">
<param name="tuto.name" value="Advanced communication" />
<param name="tuto.src.dir" value="conversation" />
<param name="tuto.destination" value="conversation" />
<param name="tuto.description" value="Communication between agents using the replying mechanism" />
</antcall>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: returncode
- - - - - - - - - - - - - - - - - -->
<target name="returncode">
<antcall target="build_tuto_files">
<param name="tuto.name" value="Return codes in MaDKit" />
<param name="tuto.src.dir" value="returncode" />
<param name="tuto.destination" value="returncode" />
<param name="tuto.description" value="Basics for handling some exceptions and return code in MaDKit" />
</antcall>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: madkitproperties
- - - - - - - - - - - - - - - - - -->
<target name="madkitproperties">
<antcall target="build_tuto_files">
<param name="tuto.name" value="MaDKit properties" />
<param name="tuto.src.dir" value="madkitproperties" />
<param name="tuto.destination" value="madkitproperties" />
<param name="tuto.description" value="Introducing MaDKit properties." />
</antcall>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: madkitoptions
- - - - - - - - - - - - - - - - - -->
<target name="madkitoptions">
<antcall target="build_tuto_files">
<param name="tuto.name" value="Options in MaDKit"/><param name="tuto.src.dir" value="madkitoptions"/>
<param name="tuto.destination" value="madkitoptions"/>
<param name="tuto.description" value="Basics for handling MaDKit options"/>
</antcall>
</target>
</project>