summaryrefslogtreecommitdiffstats
blob: 00f098e604e9a7b67641b0a685f9ef46b6277d47 (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
<!--
 * Copyright (c) 2010-2015, Isode Limited, London, England.
 * All rights reserved.
 -->
<project name="Stroke" default="dist" basedir=".">
    <description>
        XMPP Library porting Swiften to Java.
    </description>
  <property name="src" location="src"/>
  <property name="doc" location="doc"/>
  <property name="src.tests" location="test"/>
  <property name="test.results" location="test-results"/>
  <property name="build" location="build"/>
  <property name="dist"  location="dist"/>
  <property name="jar" value="${dist}/lib/stroke.jar"/>
  <property name="main-class" value="com.isode.stroke.examples.gui.StrokeGUI"/>
  <property name="compile.debug" value="true"/>
  <property name="testsuiteclass" value="com.isode.stroke.unittest.StrokeTestSuite" />
  <property name="aalto-dir" value="../third-party/aalto"/>
  <property name="stax2-dir" value="../third-party/stax2"/>
  <property name="jzlib-dir" value="../third-party/jzlib"/>
  <property name="icu4j-dir" value="../third-party/icu4j"/>
  <property name="dnsjava-dir" value="../third-party/dnsjava"/>
  <property name="cobertura.dir" value="instrumented"/>
  <property name="coveragereport.dir" value="coverage"/>


  <path id="cobertura.classpath">
    <pathelement path="${cobertura-jar}"/>
    <pathelement path="${jakarta-oro-jar}"/>
    <pathelement path="${log4j-jar}"/>
    <pathelement path="${asm-jar}"/>
    <pathelement path="${asm-tree-jar}"/>
  </path>
  <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>

  <path id="classpath">
    <fileset dir="${aalto-dir}" includes="aalto-xml.jar"/>
    <fileset dir="${stax2-dir}" includes="stax2-api.jar"/>
    <fileset dir="${jzlib-dir}" includes="jzlib.jar"/>
    <fileset dir="${icu4j-dir}" includes="icu4j.jar"/>
    <fileset dir="${dnsjava-dir}" includes="dnsjava.jar"/>
  </path>
  <target name="init">
    <tstamp/>
    <mkdir dir="${build}"/>
  </target>

  <target name="-compile-with-examples" depends="init"
        description="compile the source, including examples "
        unless="noexamples">
        <depend
                srcdir="${src}"
                destdir="${build}"
                closure="yes"/>
    <javac srcdir="${src}" destdir="${build}" classpathref="classpath"
	   debug="${compile.debug}" 
           source="1.6" 
           target="1.6">
        <compilerarg line="-encoding utf-8"/>
    </javac>
  </target>

  <target name="-compile-without-examples" depends="init"
        description="compile the source, excluding examples "
        if="noexamples">
        <depend
                srcdir="${src}"
                destdir="${build}"
                closure="yes"/>
    <javac srcdir="${src}" destdir="${build}" classpathref="classpath"
	   debug="${compile.debug}" 
           source="1.6" 
           target="1.6">
      	<exclude name="com/isode/stroke/examples/**"/>
        <compilerarg line="-encoding utf-8"/>
    </javac>
  </target>


  <target name="dist" depends="-dist-with-examples,-dist-without-examples"/>

  <target name="-dist-with-examples" depends="-compile-with-examples"
        description="generate the distribution including examples" 
        unless="noexamples">
    <mkdir dir="${dist}/lib"/>

    <jar jarfile="${jar}" basedir="${build}">
        <manifest>
            <attribute name="Main-Class" value="${main-class}"/>
        </manifest>
    </jar>
  </target>

  <target name="-dist-without-examples" depends="-compile-without-examples"
        description="generate the distribution excluding examples" 
	if="noexamples">
    <mkdir dir="${dist}/lib"/>

    <jar jarfile="${jar}" basedir="${build}">
    </jar>
  </target>


  <target name="compile-tests" depends="dist"
        description="compile the test sources " >
    <depend
            srcdir="${src.tests}"
            classpath="${jar}"
            destdir="${src.tests}"
            closure="yes"/>
    <javac srcdir="${src.tests}" destdir="${src.tests}"
	   debug="${compile.debug}"
           source="1.6" 
           target="1.6">
        <compilerarg line="-encoding utf-8"/>
        <classpath>
            <pathelement location="${jar}"/>
            <pathelement location="${JUNIT_JAR}"/>
            <pathelement location="${HAMCREST_JAR}"/>
            <fileset dir="${icu4j-dir}" includes="icu4j.jar"/>
        </classpath>
    </javac>
  </target>

  <target name="instrument" if="cobertura-jar" depends="compile-tests">
    <delete dir="${cobertura.dir}"/>
    <mkdir dir="${cobertura.dir}"/>
    <cobertura-instrument todir="${cobertura.dir}">
      <fileset dir="test">
        <include name="**/*.class"/>
      </fileset>
    </cobertura-instrument>
  </target>

  <target name="run-tests" depends="compile-tests">
    <delete dir="${test.results}"/>
    <mkdir dir="${test.results}"/>
    <junit fork="yes">
      <formatter type="xml"/>
      <classpath>
        <pathelement location="${cobertura.dir}"/>
        <path refid="cobertura.classpath"/>
      </classpath>
      <classpath>
         <pathelement location="${JUNIT_JAR}"/>
         <pathelement location="${HAMCREST_JAR}"/>
         <pathelement location="${jar}"/>
         <pathelement location="${src.tests}"/>
         <path refid="classpath"/>
      </classpath>
      <batchtest todir="${test.results}">
         <fileset dir="${src.tests}">
           <include name="**/*Test.java"/>
           <!--<exclude name="**/AllTests.java"/>-->
         </fileset>
      </batchtest>
    </junit>
  </target>

  <target name="coverage" if="cobertura-jar" depends="instrument, run-tests">
    <delete dir="${coveragereport.dir}"/>
    <mkdir dir="${coveragereport.dir}"/>
    <cobertura-report format="xml" destdir="${coveragereport.dir}">
      <fileset dir="${src}">
        <include name="**/*.java"/>
      </fileset>
      <fileset dir="${src.tests}">
        <include name="**/*.java"/>
      </fileset>
    </cobertura-report>
  </target>

  <target name="findbugs" if="findbugs.home" depends="dist">
    <path id="findbugs-jar"> 
      <pathelement path="${findbugs.home}/lib/findbugs-ant.jar" /> 
    </path> 
    <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" classpathref="findbugs-jar" /> 
    <findbugs home="${findbugs.home}"
              output="xml"
              outputFile="findbugs.xml" >
      <auxClasspath>
        <path refid="classpath" />
      </auxClasspath>
      <sourcePath path="${src}" />
      <class location="${jar}" />
    </findbugs>
  </target>

  <target name="pmd">
    <path id="pmd-jar"> 
      <fileset dir="${pmd.home}/lib">
        <include name="*.jar" /> 
      </fileset>
    </path> 
    <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd-jar"/>
    <pmd shortFilenames="true">
      <ruleset>pmd-ruleset.xml</ruleset>
      <formatter type="xml" toFile="pmd.xml" />
      <fileset dir="${src}">
        <include name="**/*.java"/>
      </fileset>
    </pmd>
  </target>

  <target name="test" depends="compile-tests, instrument, run-tests, coverage, findbugs, pmd, report-junit-tests">
  </target>

  <target name="clean"
          description="clean up" >
    <delete dir="${build}"/>
    <delete dir="${test.results}"/>
    <delete dir="${dist}"/>
    <delete dir="${doc}"/>
    <delete dir="${coveragereport.dir}"/>
    <delete dir="${cobertura.dir}"/>
    <delete>
         <fileset dir="${src.tests}">
           <include name="**/*.class"/>
         </fileset>
    </delete>
  </target>

  <target name="javadoc" depends="init">
    <!-- Note that this may stall if no network connection is available
         to the Oracle website -->
     <javadoc packagenames="com.isode.**.**"
     sourcepath="${src}"
     destdir="${doc}"
     windowtitle="Stroke">
     <!--<classpath>
       <fileset dir="${xpp-dir}" includes="xpp.jar"/>
     </classpath>-->
     <link href="http://docs.oracle.com/javase/6/docs/api/"/>
   </javadoc>
  </target>



  <target name="run" description="Run the demo" depends="dist">
    <java fork="true" classname="${main-class}">
      <classpath>
        <path refid="classpath"/>
        <path location="${jar}"/>
      </classpath>
    </java>
  </target>

  <target name="report-junit-tests" depends="run-tests">
    <mkdir dir="${test.results}/html"/>
      <junitreport todir="${test.results}">
          <fileset dir="${test.results}">
              <include name="TEST-*.xml"/>
          </fileset>
          <report todir="${test.results}/html"/>
      </junitreport>
  </target>

</project>