summaryrefslogtreecommitdiffstats
path: root/watchmaker/build.xml
blob: 6292b47f05a4870704bb4f923ebe38bf6b689dfa (plain)
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
<!--===========================================================================
  Copyright 2006-2010 Daniel W. Dyer

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  ==========================================================================-->
<project name="watchmaker"
         xmlns:uncommons="antlib:org.uncommons.antlib"
         default="dist"
         basedir=".">
  <description>Ant build file for the Watchmaker framework.</description>

  
<!-- ==================================================================
     GLOBAL BUILD PROPERTIES
=================================================================== -->

  <!-- Project-global locations. -->
  <property name="conf.dir" value="etc" />
  <property name="lib.dir" value="lib" />
  <property name="lib.compiletime" value="${lib.dir}/compiletime" />
  <property name="lib.runtime" value="${lib.dir}/runtime" />
  <property name="dist.dir" value="dist" />
  <property name="docs.dir" value="docs" />
  <property name="checkstyle-results.dir" value="${docs.dir}/checkstyle" />
  <property name="release.dir" value="release" />
  <!-- The "website" directory is a symlink to a copy of the Git repository
       at http://github.com/dwdyer/watchmaker-website. -->
  <property name="web.dir" value="website" />
  <property name="temp.dir" value="temp" />

  <!-- Per-module locations. -->
  <property name="src.dir" value="src" />
  <property name="java.dir" value="${src.dir}/java" />
  <property name="build.dir" value="build"/>


  <!-- Classpath for compilation and tests. -->
  <path id="tool.path">
    <fileset dir="${lib.dir}" includes="**/*.jar" />
  </path>

  <taskdef uri="antlib:org.uncommons.antlib"
           resource="org/uncommons/antlib/antlib.xml"
           classpathref="tool.path"/>


  <property name="version" value="0.7.2"/>
  <property name="artifact.identifier" value="watchmaker-framework-${version}"/>

  <!-- This is the minimum coverage percentage (for both lines and
       branches) that will be tolerated.  This is used to prevent
       regressions in coverage.  The threshold will be raised as
       test coverage improves. -->
  <property name="minimum.coverage" value="80" />


<!-- ==================================================================
     TARGETS FOR BUILDING THE SOFTWARE
=================================================================== -->

  <!-- Builds everything from scratch. -->
  <target name="all"
          depends="clean, dist, test, docs"
          description="Builds everything, excluding docs, from scratch."/>
  
  
  <!-- Deletes all directories and files created by the build process. -->
  <target name="clean"
          description="Remove all files created by the build process." >
    <delete dir="${docs.dir}" />
    <delete dir="${dist.dir}" />
    <delete dir="${release.dir}" />
    <delete dir="${temp.dir}" />
    <uncommons:clean module="examples" />
    <uncommons:clean module="framework" />
    <uncommons:clean module="swing" />
    <uncommons:clean module="book" />
  </target>


  <!-- Builds the core framework JAR. -->
  <target name="framework"
          description="Build the framework module.">
    <uncommons:compile module="framework" />
    <uncommons:jar module="framework" jarfile="${artifact.identifier}.jar" />
  </target>


  <!-- Builds the GUI module. -->
  <target name="swing"
          depends="framework"
          description="Build the GUI module.">
    <uncommons:compile module="swing" />
    <uncommons:jar module="swing" jarfile="watchmaker-swing-${version}.jar" />
  </target>


  <!-- Builds the examples JAR, which depends on each of the other modules. -->
  <target name="examples"
          depends="framework, swing"
          description="Build the examples.">
    <uncommons:compile module="examples" />
    <uncommons:jar module="examples"
                   jarfile="watchmaker-examples-${version}.jar"
                   classpath="${artifact.identifier}.jar lib/uncommons-maths-1.2.2.jar lib/google-collect-1.0.jar watchmaker-swing-${version}.jar lib/jfreechart-1.0.13.jar lib/jcommon-1.0.16.jar"
                   mainclass="org.uncommons.watchmaker.examples.Launcher" />
  </target>


  <!-- Copy all necessary files to distribution directory. -->
  <target name="dist"
          depends="framework, swing, examples"
          description="Generate the project distribution." >
    <uncommons:dist />
    <mkdir dir="${dist.dir}/src" />
    <copy todir="${dist.dir}/src" flatten="true">
      <fileset dir="." includes="**/${build.dir}/*-src.jar"/>
    </copy>
  </target>


  <!-- Build source JAR files for inclusion in the release. -->
  <target name="source" description="Build source JARs.">
    <uncommons:source module="framework" jarfile="${artifact.identifier}-src.jar" />
    <uncommons:source module="swing" jarfile="watchmaker-swing-${version}-src.jar" />
  </target>


  <!-- Create the release artifacts. -->
  <target name="release"
          depends="clean, source, dist, test, checkstyle, docs"
          description="Creates the release archives.">
    <uncommons:release name="${artifact.identifier}">
      <additionalcontents>
        <tarfileset dir="examples/${java.dir}/main"
                    prefix="${artifact.identifier}/examples/src"
                    includes="**/*" />
      </additionalcontents>
    </uncommons:release>
  </target>


  <target name="release-maven"
          depends="clean, dist"
          description="Deploys the software to the Java.net Maven repository.">
    <uncommons:maven-deploy module="framework"
                            version="${version}"
                            username="${maven.user}"
                            password="${maven.password}"/>
    <uncommons:maven-deploy module="swing"
                            version="${version}"
                            username="${maven.user}"
                            password="${maven.password}"/>
  </target>



<!-- ==================================================================
      TARGETS FOR GENERATING TEST REPORTS & DOCUMENTATION
 =================================================================== -->

  <!-- Runs unit tests for all modules. -->
  <target name="test"
          depends="dist"
          description="Run the unit test suite.">
    <!-- Don't run FEST tests in a headless environment (they will fail) -->
    <condition property="tests.file" value="testng-headless.xml" else="testng.xml">
      <isset property="headless" />
    </condition>
    <uncommons:test suites="${conf.dir}/${tests.file}"
                    headless="${headless}"
                    title="Watchmaker Framework Unit Test Report"
                    mincoverage="${minimum.coverage}" />
  </target>


  <target name="checkstyle"
          depends="dist"
          description="Check that coding standard are adhered to.">
    <taskdef resource="checkstyletask.properties" classpathref="tool.path"/>
    <mkdir dir="${checkstyle-results.dir}" />

    <!-- Compiled classes must be available on the classpath to work-around this
         bug (http://jira.codehaus.org/browse/MPCHECKSTYLE-20).  That is why this
         target depends on the 'dist' target. -->
    <path id="checkstyle.path">
      <fileset dir="${dist.dir}" includes="**/*.jar" />
    </path>

    <checkstyle config="${conf.dir}/checks.xml"
                failonviolation="false"
                classpathref="checkstyle.path">
      <fileset dir="." defaultexcludes="yes">
        <include name="**/${java.dir}/main/org/uncommons/**/*.java"/>
      </fileset>
      <formatter type="xml" tofile="${checkstyle-results.dir}/checkstyle_report.xml"/>
    </checkstyle>
    <xslt in="${checkstyle-results.dir}/checkstyle_report.xml"
          out="${checkstyle-results.dir}/checkstyle_report.html"
          style="${conf.dir}/checkstyle-noframes-sorted.xsl" />
  </target>


  <!-- Generates API documentation for all modules. -->
  <target name="docs"
          description="Generates Javadoc API documentation for all modules.">
    <uncommons:javadoc title="Watchmaker Framework for Evolutionary Computation API"
                       version="${version}"
                       excludes="examples/**/*,framework/${java.dir}/main/org/uncommons/util/**/*">
      <additionalconfig>
        <group title="Watchmaker Evolution Framework" packages="org.uncommons.watchmaker.framework:org.uncommons.watchmaker.framework.*"/>
        <group title="Watchmaker Swing Classes" packages="org.uncommons.swing:org.uncommons.swing.*:org.uncommons.watchmaker.swing:org.uncommons.watchmaker.swing.*"/>
        <link href="http://maths.uncommons.org/api/"/>
      </additionalconfig>
    </uncommons:javadoc>
  </target>

  
  <target name="book" description="Generates the PDF user guide.">
    <mkdir dir="book/${build.dir}" />
    <uncommons:docbook classpathref="tool.path"
                       source="book/${src.dir}/xml/book.xml"
                       format="pdf"                       
                       outputDir="book/${build.dir}" >
      <parameter name="paper.type" value="A4" />
      <parameter name="highlight.source" value="1" />
      <parameter name="img.src.path" value="./book/src/resources/" />
    </uncommons:docbook>
  </target>


<!-- ==================================================================
      TARGETS FOR UPDATING THE PROJECT WEBSITE
 =================================================================== -->

  <target name="website-docs"
          description="Re-builds the website Javadocs."
          depends="dist">
    <!-- Delete all existing HTML files and then regenerate the docs over the top. -->
    <delete>
      <fileset dir="${web.dir}">
        <include name="api/**/*.html" />
        <include name="manual/**/*" />
      </fileset>
    </delete>

    <!-- Refresh the API documentation tree for the Watchmaker Framework website. -->
    <uncommons:javadoc dir="${web.dir}/api"
                       title="Watchmaker Framework for Evolutionary Computation API"
                       version="${version}"
                       excludes="examples/**/*,framework/${java.dir}/main/org/uncommons/util/**/*">
      <additionalconfig>
        <group title="Watchmaker Evolution Framework" packages="org.uncommons.watchmaker.framework:org.uncommons.watchmaker.framework.*"/>
        <group title="Watchmaker Swing Classes" packages="org.uncommons.swing:org.uncommons.swing.*:org.uncommons.watchmaker.swing:org.uncommons.watchmaker.swing.*"/>
        <link href="http://maths.uncommons.org/api/"/>
      </additionalconfig>
    </uncommons:javadoc>

    <copy todir="${web.dir}" file="./CHANGELOG.txt">
      <filterset>
        <filter token="VERSION" value="${version}"/>
      </filterset>
    </copy>

    <!-- Copy latest jars into website examples directory. -->
    <copy todir="${web.dir}/examples">
      <fileset dir="${dist.dir}" includes="*.jar" />
    </copy>
    <copy todir="${web.dir}/examples/lib">
      <fileset dir="${dist.dir}/${lib.dir}" includes="*.jar" />
    </copy>

    <!-- Generate user manual from DocBook source. -->
    <uncommons:docbook classpathref="tool.path"
                       source="book/${src.dir}/xml/website.xml"
                       format="html"
                       chunked="true"
                       outputDir="${web.dir}/manual" >
      <parameter name="highlight.source" value="1" />
      <parameter name="img.src.path" value="./" />
      <parameter name="html.stylesheet" value="docbook.css" />
    </uncommons:docbook>
    <copy todir="${web.dir}/manual">
      <fileset dir="book/${src.dir}/resources" includes="**/*"/>
    </copy>
  </target>

</project>