forked from MOEAFramework/MOEAFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
421 lines (338 loc) · 15.6 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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
<?xml version="1.0"?>
<!--
Copyright 2009-2024 David Hadka
This file is part of the MOEA Framework.
The MOEA Framework is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The MOEA Framework is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the MOEA Framework. If not, see <http://www.gnu.org/licenses/>.
Use of these build scripts requires Apache Ant to be installed. See
<http://ant.apache.org/> for instructions on installing Apache Ant.
-->
<project name="MOEA Framework" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<import file="src/macros.xml" />
<!-- Loads properties from properties file and environment -->
<property file="META-INF/build.properties" />
<property environment="env" />
<!-- The working folder for these Ant build targets -->
<property name="build" value="build" />
<!-- The folder where compiled files ready for distribution are saved -->
<property name="dist" value="dist" />
<!-- The folder where generated javadoc files are saved -->
<property name="javadoc" value="javadoc" />
<!-- The base/root folder for organizing distributions -->
<property name="base" value="${build}/${shortname}-${version}" />
<!-- Classpath of third-party libraries used by the MOEA Framework -->
<path id="classpath">
<fileset dir="lib" includes="*.jar" />
</path>
<!-- List of files required in every distribution -->
<path id="requiredfiles">
<fileset file="README.md" />
<fileset file="COPYING" />
</path>
<!-- List of libraries included in every distribution -->
<path id="libraries">
<fileset dir="lib" excludes="junit-*.jar,hamcrest-*.jar,checkstyle-*.jar,nashorn-*.jar,jfreesvg-*.jar,asm-*.jar,jmetal-plugin-*.jar,pisa-plugin-*.jar,gd-*.jar" />
</path>
<!-- Generates the Javadoc webpages -->
<target name="build-javadoc">
<delete dir="${javadoc}" />
<mkdir dir="${javadoc}" />
<javadoc sourcepath="src"
source="${java.major}"
destdir="${javadoc}"
packagenames="org.moeaframework.*"
noindex="true"
nohelp="true"
notree="true"
overview="src/overview.html"
windowtitle="${name} ${version} API">
<header><![CDATA[${name} ${version}<br />API Specification]]></header>
<doctitle><![CDATA[${name} ${version}<br />API Specification]]></doctitle>
<bottom><![CDATA[${copyright}<br />Licensed under the <a href=\"http://www.gnu.org/licenses/lgpl.html\">GNU Lesser General Public License</a>.<br />Return to the <a href=\"${website}\" target=\"_top\">MOEA Framework homepage</a>.]]></bottom>
<classpath>
<path refid="classpath" />
</classpath>
<arg value="-notimestamp" />
</javadoc>
</target>
<!-- Builds the MOEA Framework JAR file -->
<target name="build-binary">
<tstamp />
<delete dir="${build}" />
<mkdir dir="${build}" />
<fail message="Missing or invalid version of JAR file">
<condition>
<not>
<and>
<available file="lib/commons-cli-${commons-cli.version}.jar" />
<available file="lib/commons-io-${commons-io.version}.jar" />
<available file="lib/commons-text-${commons-text.version}.jar" />
<available file="lib/commons-lang3-${commons-lang3.version}.jar" />
<available file="lib/commons-math3-${commons-math3.version}.jar" />
<available file="lib/jcommon-${jcommon.version}.jar" />
<available file="lib/jfreechart-${jfreechart.version}.jar" />
<available file="lib/jna-${jna.version}.jar" />
<available file="lib/rsyntaxtextarea-${rsyntaxtextarea.version}.jar" />
</and>
</not>
</condition>
</fail>
<javac destdir="${build}" srcdir="src" debug="${java.debug}" release="${java.major}"
excludes="**/package-info.java" includeantruntime="false" encoding="UTF-8">
<classpath refid="classpath" />
</javac>
<copy todir="${build}/META-INF">
<fileset dir="META-INF" excludes="ZHANG-LICENSE" />
<path refid="requiredfiles" />
</copy>
<exec executable="git" outputproperty="impl.version" errorproperty="impl.error" failifexecutionfails="false">
<arg value="rev-parse" />
<arg value="--short" />
<arg value="HEAD" />
</exec>
<property name="impl.version" value="Undefined" />
<manifest file="${build}/META-INF/MANIFEST.MF">
<section name="org/moeaframework/">
<attribute name="Specification-Title" value="${name}" />
<attribute name="Specification-Version" value="${version}" />
<attribute name="Specification-Vendor" value="${website}" />
<attribute name="Implementation-Title" value="org.moeaframework" />
<attribute name="Implementation-Version" value="${impl.version}" />
<attribute name="Implementation-Vendor" value="${website}" />
</section>
</manifest>
<copy todir="${build}">
<fileset excludes="**/*.java,overview.html,launch-diagnostic-tool.bat,macros.xml,pom.xml" dir="src" />
</copy>
<jar basedir="${build}" manifest="${build}/META-INF/MANIFEST.MF"
jarfile="${dist}/${shortname}-${version}.jar" />
</target>
<!-- Update the lib/ folder and .classpath file with the latest versions from build.properties -->
<target name="update-libraries">
<delete dir="lib" />
<mkdir dir="lib" />
<secure-get src="${commons-cli.url}" dest="lib/commons-cli-${commons-cli.version}.jar" sha1="${commons-cli.sha1}" />
<secure-get src="${commons-io.url}" dest="lib/commons-io-${commons-io.version}.jar" sha1="${commons-io.sha1}" />
<secure-get src="${commons-lang3.url}" dest="lib/commons-lang3-${commons-lang3.version}.jar" sha1="${commons-lang3.sha1}" />
<secure-get src="${commons-math3.url}" dest="lib/commons-math3-${commons-math3.version}.jar" sha1="${commons-math3.sha1}" />
<secure-get src="${commons-text.url}" dest="lib/commons-text-${commons-text.version}.jar" sha1="${commons-text.sha1}" />
<secure-get src="${jcommon.url}" dest="lib/jcommon-${jcommon.version}.jar" sha1="${jcommon.sha1}" />
<secure-get src="${jfreechart.url}" dest="lib/jfreechart-${jfreechart.version}.jar" sha1="${jfreechart.sha1}" />
<secure-get src="${jna.url}" dest="lib/jna-${jna.version}.jar" sha1="${jna.sha1}" />
<secure-get src="${rsyntaxtextarea.url}" dest="lib/rsyntaxtextarea-${rsyntaxtextarea.version}.jar" sha1="${rsyntaxtextarea.sha1}" />
<replaceregexp file=".classpath" match="lib/([a-zA-Z0-9]+(-[a-zA-Z0-9]+)?)-[0-9]+\.[0-9]+\.([0-9]+)?\.jar"
replace="lib/\1-%\1.version%.jar" byline="true" />
<replace-properties file=".classpath" />
</target>
<!-- Updates code samples used in the docs -->
<target name="update-docs" depends="build-binary">
<java classname="org.moeaframework.util.io.UpdateCodeSamples" fork="true" failonerror="true">
<classpath refid="classpath" />
<classpath path="${build}" />
<classpath path="examples" />
<arg value="--update" />
</java>
</target>
<!-- Validates code samples used in the docs -->
<target name="validate-docs" depends="build-binary">
<java classname="org.moeaframework.util.io.UpdateCodeSamples" fork="true" failonerror="true">
<classpath refid="classpath" />
<classpath path="${build}" />
<classpath path="examples" />
</java>
</target>
<!-- Packages the MOEA Framework JAR file along with javadocs and required files -->
<target name="package-binary" depends="build-binary, build-javadoc"
description="Creates the binary distribution file">
<delete dir="${build}" />
<mkdir dir="${base}" />
<mkdir dir="${base}/docs" />
<mkdir dir="${base}/lib" />
<mkdir dir="${base}/pf" />
<mkdir dir="${base}/licenses" />
<mkdir dir="${base}/examples" />
<copy todir="${base}">
<path refid="requiredfiles" />
<fileset file="moeaframework.properties" />
<fileset file="src/launch-diagnostic-tool.bat" />
</copy>
<copy todir="${base}/licenses">
<fileset dir="META-INF" includes="*-LICENSE" excludes="ZHANG-LICENSE" />
</copy>
<copy todir="${base}/docs">
<fileset dir="docs" />
</copy>
<copy todir="${base}/lib">
<fileset file="${dist}/${shortname}-${version}.jar" />
<path refid="libraries" />
</copy>
<copy todir="${base}/pf">
<fileset dir="pf" excludes="referenceHypervolume" />
</copy>
<copy todir="${base}/javadoc">
<fileset dir="${javadoc}" />
</copy>
<copy todir="${base}/examples">
<fileset dir="examples" excludes="*.exe,*.o,*.a,*.class" />
</copy>
<tar destfile="${dist}/${shortname}-${version}.tar.gz" basedir="${build}" compression="gzip" longfile="gnu" />
</target>
<!-- Packages the MOEA Framework source code, libraries and required files -->
<target name="package-source" description="Creates the source code distribution file">
<delete dir="${build}" />
<mkdir dir="${base}" />
<copy todir="${base}">
<fileset dir=".">
<include name=".project" />
<include name=".classpath" />
<include name="docs/**" />
<include name="examples/**" />
<exclude name="examples/*.exe" />
<exclude name="examples/*.o" />
<exclude name="examples/*.a" />
<include name="META-INF/**" />
<include name="pf/**" />
<include name="src/**" />
<include name="test/**" />
<exclude name="test/checkstyle/checkstyle-*.jar" />
<exclude name="test/org/moeaframework/problem/*.exe" />
<exclude name="test/org/moeaframework/problem/*.o" />
<exclude name="test/org/moeaframework/problem/*.a" />
<include name="website/**" />
<include name="moeaframework.properties" />
<include name="build.xml" />
<include name="test.xml" />
</fileset>
<path refid="requiredfiles" />
</copy>
<copy todir="${base}/lib">
<path refid="libraries" />
</copy>
<replace file="${base}/.project">
<replacefilter token="MOEAFramework" value="MOEAFramework-${version}" />
</replace>
<tar destfile="${dist}/${shortname}-${version}-Source.tar.gz" basedir="${build}" compression="gzip"
longfile="gnu" />
</target>
<!-- Builds the website -->
<target name="package-website" depends="build-javadoc" description="Creates the website">
<delete dir="${build}" />
<mkdir dir="${build}" />
<tstamp>
<format pattern="MMM dd, yyyy" property="today" />
<format pattern="yyyy-MM-dd" property="lastmod" />
</tstamp>
<copy todir="${build}">
<fileset dir="website" excludes="*.partial,xslt/**" />
</copy>
<copy todir="${build}/javadoc">
<fileset dir="${javadoc}" />
</copy>
<xslt basedir="website/xslt" destdir="${build}" style="website/xslt/stylesheet.xsl"
includes="*.xml" filenameparameter="filename">
<param name="version" expression="${version}" />
<param name="today" expression="${today}" />
</xslt>
<replace dir="${build}" includes="**/*.html">
<replacefilter token="%VERSION%" value="${version}" />
</replace>
<replace file="${build}/sitemap.xml">
<replacefilter token="%LASTMOD%" value="${lastmod}" />
</replace>
<copy todir="${build}">
<fileset dir="examples" includes="*.java" excludes="Examples.java" />
</copy>
<copy todir="${build}">
<fileset file="examples/dtlz2.c" />
</copy>
</target>
<!-- Packages the demo distribution -->
<target name="package-demo" depends="build-binary" description="Creates the executable JAR file">
<delete dir="${build}" />
<mkdir dir="${build}" />
<unjar dest="${build}" src="lib/commons-cli-${commons-cli.version}.jar" />
<move file="${build}/META-INF/NOTICE.txt" tofile="${build}/META-INF/${commons-cli.notice_file}.txt" />
<unjar dest="${build}" src="lib/commons-io-${commons-io.version}.jar" />
<move file="${build}/META-INF/NOTICE.txt" tofile="${build}/META-INF/${commons-io.notice_file}.txt" />
<unjar dest="${build}" src="lib/commons-text-${commons-text.version}.jar" />
<move file="${build}/META-INF/NOTICE.txt" tofile="${build}/META-INF/${commons-text.notice_file}.txt" />
<unjar dest="${build}" src="lib/commons-lang3-${commons-lang3.version}.jar" />
<move file="${build}/META-INF/NOTICE.txt" tofile="${build}/META-INF/${commons-lang3.notice_file}.txt" />
<unjar dest="${build}" src="lib/commons-math3-${commons-math3.version}.jar" />
<move file="${build}/META-INF/NOTICE.txt" tofile="${build}/META-INF/${commons-math3.notice_file}.txt" />
<unjar dest="${build}" src="lib/jcommon-${jcommon.version}.jar" />
<unjar dest="${build}" src="lib/jfreechart-${jfreechart.version}.jar" />
<unjar dest="${build}" src="lib/jna-${jna.version}.jar" />
<unjar dest="${build}" src="lib/rsyntaxtextarea-${rsyntaxtextarea.version}.jar" />
<delete dir="${build}/META-INF/maven" />
<delete dir="${build}/META-INF/versions" />
<delete file="${build}/META-INF/LICENSE" />
<delete file="${build}/META-INF/LICENSE.txt" />
<delete file="${build}/META-INF/LGPL2.1" />
<delete file="${build}/META-INF/AL2.0" />
<delete file="${build}/META-INF/MANIFEST.mf" />
<delete dir="${build}/templates" />
<unjar dest="${build}" src="${dist}/${shortname}-${version}.jar" />
<javac destdir="${build}" srcdir="examples" debug="${java.debug}" release="${java.major}"
excludes="**/package-info.java" includeantruntime="false" encoding="UTF-8">
<classpath refid="classpath" />
</javac>
<copy todir="${build}">
<fileset excludes="**/*.java,overview.html,*.exe,*.o,*.a" dir="examples" />
</copy>
<!-- copy the examples source code so it can be seen in the demo GUI -->
<copy todir="${build}/examples">
<fileset dir="examples" excludes="*.exe,*.o,*.a" />
</copy>
<copy todir="${build}/pf">
<fileset dir="pf" />
</copy>
<manifest mode="update" file="${build}/META-INF/MANIFEST.mf">
<attribute name="Main-Class" value="Examples" />
<attribute name="Class-Path" value="." />
</manifest>
<jar destfile="${dist}/${shortname}-${version}-Demo.jar" basedir="${build}"
manifest="${build}/META-INF/MANIFEST.mf" />
</target>
<target name="build-maven" description="Creates a Maven version of this project for testing / publishing">
<delete dir="${build}" />
<mkdir dir="${build}" />
<mkdir dir="${build}/src/main/java" />
<mkdir dir="${build}/src/main/resources" />
<mkdir dir="${build}/src/test/java" />
<mkdir dir="${build}/src/test/resources" />
<mkdir dir="${build}/examples" />
<copy file="src/pom.xml" tofile="${build}/pom.xml" />
<replace-properties file="${build}/pom.xml" />
<copy todir="${build}/src/main/resources/META-INF">
<fileset dir="META-INF" />
<path refid="requiredfiles" />
</copy>
<copy todir="${build}/src/main/resources" includeEmptyDirs="false">
<fileset dir="src" excludes="**/*.java,launch-diagnostic-tool.bat,macros.xml,pom.xml" />
</copy>
<copy todir="${build}/src/main/java">
<fileset excludes="overview.html" dir="src" />
</copy>
<copy todir="${build}/src/test/java">
<fileset dir="test" />
</copy>
<copy todir="${build}/src/test/resources" includeEmptyDirs="false">
<fileset dir="test" excludes="**/*.java" />
</copy>
<copy todir="${build}/examples">
<fileset dir="examples" />
</copy>
<copy todir="${build}/src/main/resources/pf">
<fileset dir="pf" />
</copy>
</target>
</project>