summaryrefslogtreecommitdiffstats
blob: 065cdefd5b01adacba203ba74ed1555133ada124 (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
<!--
 * Copyright (c) 2010, 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="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"/>
  </path>
  <target name="init">
    <tstamp/>
    <mkdir dir="${build}"/>
  </target>

  <target name="compile" depends="init"
        description="compile the source " >
    <javac srcdir="${src}" destdir="${build}" classpathref="classpath" debug="${compile.debug}">
        <compilerarg line="-encoding utf-8"/>
    </javac>
  </target>

  <target name="dist" depends="compile"
        description="generate the distribution" >
    <mkdir dir="${dist}/lib"/>

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

<target name="compile-tests" depends="dist"
        description="compile the test sources " >
    <javac srcdir="${src.tests}" destdir="${src.tests}" debug="${compile.debug}">
        <compilerarg line="-encoding utf-8"/>
        <classpath>
            <pathelement location="${jar}"/>
            <pathelement location="${JUNIT_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="${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">
  </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}"/>

  </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>
</project>