source: apps/streaming/java/build.xml @ 1652bb3

Last change on this file since 1652bb3 was 1652bb3, checked in by str4d <str4d@…>, 5 years ago

Fix Cobertura exclusions

  • Property mode set to 100644
File size: 11.4 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<project basedir="." default="all" name="streaming">
3    <target name="all" depends="clean, build" />
4    <target name="build" depends="builddep, jar" />
5    <target name="builddep">
6        <!-- run from top level build.xml to get dependencies built -->
7    </target>
8    <condition property="depend.available">
9        <typefound name="depend" />
10    </condition>
11    <target name="depend" if="depend.available">
12        <depend
13            cache="../../../build"
14            srcdir="./src:./test/junit"
15            destdir="./build/obj" >
16            <!-- Depend on classes instead of jars where available -->
17            <classpath>
18                <pathelement location="../../../core/java/build/obj" />
19                <pathelement location="../../ministreaming/java/build/obj" />
20            </classpath>
21        </depend>
22    </target>
23
24    <!-- only used if not set by a higher build.xml -->
25    <property name="javac.compilerargs" value="" />
26    <property name="javac.version" value="1.6" />
27
28    <target name="compile" depends="depend">
29        <mkdir dir="./build" />
30        <mkdir dir="./build/obj" />
31        <javac
32            srcdir="./src"
33            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}"
34            includeAntRuntime="false"
35            destdir="./build/obj"
36            classpath="../../../core/java/build/i2p.jar:../../ministreaming/java/build/mstreaming.jar" >
37            <compilerarg line="${javac.compilerargs}" />
38        </javac>
39    </target>
40    <target name="builddeptest">
41        <ant dir="../../../core/java" target="jar" />
42        <ant dir="../../../apps/ministreaming/java/" target="jar" />
43    </target>
44    <target name="junit.compileTest" depends="builddeptest, compile">
45
46        <echo message="[DEBUG] ant home is ${ant.home}" />
47        <echo message="[DEBUG] junit home before override is ${junit.home}" />
48        <echo message="[DEBUG] hamcrest home before override is ${hamcrest.home}" />
49        <echo message="[DEBUG] mockito home before override is ${mockito.home}" />
50
51        <property name="junit.home" value="${ant.home}/lib" />
52        <property name="hamcrest.home" value="${ant.home}/lib" />
53        <property name="mockito.home" value="${ant.home}/lib" />
54
55        <echo message="[DEBUG] junit home after override is ${junit.home}" />
56        <echo message="[DEBUG] hamcrest home after override is ${hamcrest.home}" />
57        <echo message="[DEBUG] mockito home after override is ${mockito.home}" />
58
59        <javac
60            srcdir="./test/junit"
61            debug="true" deprecation="on" source="${javac.version}" target="${javac.version}"
62            includeAntRuntime="false"
63            destdir="./build/obj" >
64            <classpath>
65                <pathelement location="../../../core/java/build/i2p.jar" />
66                <pathelement location="../../ministreaming/java/build/mstreaming.jar" />
67                <pathelement location="${junit.home}/junit4.jar" />
68                <pathelement location="${hamcrest.home}/hamcrest.jar" />
69                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
70                <pathelement location="${mockito.home}/byte-buddy.jar" />
71                <pathelement location="${mockito.home}/objenesis.jar" />
72                <pathelement location="${mockito.home}/mockito-core.jar" />
73            </classpath>
74            <compilerarg line="${javac.compilerargs}" />
75        </javac>
76    </target>
77
78    <!-- preparation of code coverage tool of choice -->
79    <target name="prepareClover" depends="compile" if="with.clover">
80        <taskdef resource="clovertasks"/>
81        <mkdir dir="../../../reports/streaming/clover" />
82        <clover-setup initString="../../../reports/streaming/clover/coverage.db"/>
83    </target>
84    <target name="prepareCobertura" depends="compile" if="with.cobertura">
85        <taskdef classpath="${with.cobertura}" resource="tasks.properties" onerror="report" />
86        <mkdir dir="./build/obj_cobertura" />
87        <delete file="./cobertura.ser" />
88        <cobertura-instrument todir="./build/obj_cobertura">
89            <fileset dir="./build/obj">
90                <include name="**/*.class"/>
91                <!-- exclude Test classes -->
92                <exclude name="**/*Test.class" />
93                <exclude name="**/*IT.class" />
94                <exclude name="**/*IT$*.class" />
95                <exclude name="**/StreamingITBase.class" />
96                <exclude name="**/StreamingITBase$*.class" />
97                <!-- exclude anything not in net.i2p.* -->
98                <exclude name="org/cybergarage/**/*.class" />
99                <exclude name="org/freenetproject/**/*.class" />
100                <exclude name="org/xlattice/**/*.class" />
101            </fileset>
102        </cobertura-instrument>
103    </target>
104
105    <target name="prepareTest" depends="prepareClover, prepareCobertura" />
106
107    <target name="junit.test" depends="clean, junit.compileTest, prepareTest">
108        <mkdir dir="../../../reports/streaming/junit/" />
109        <delete>
110            <fileset dir="../../../reports/streaming/junit">
111                <include name="TEST-*.xml"/>
112            </fileset>
113        </delete>
114
115        <property name="junit.home" value="${ant.home}/lib" />
116        <property name="hamcrest.home" value="${ant.home}/lib" />
117        <property name="mockito.home" value="${ant.home}/lib" />
118
119        <junit printsummary="withOutAndErr" fork="yes" showoutput="yes" >
120            <sysproperty key="net.sourceforge.cobertura.datafile" file="./cobertura.ser" />
121            <classpath>
122                <pathelement path="${javac.classpath}" />
123                <pathelement location="${hamcrest.home}/hamcrest-core.jar" />
124                <pathelement location="${hamcrest.home}/hamcrest-library.jar" />
125                <pathelement location="${hamcrest.home}/hamcrest-integration.jar" />
126                <pathelement location="${hamcrest.home}/hamcrest-all.jar" />
127                <pathelement location="${mockito.home}/byte-buddy.jar" />
128                <pathelement location="${mockito.home}/objenesis.jar" />
129                <pathelement location="${mockito.home}/mockito-core.jar" />
130                <pathelement location="${junit.home}/junit4.jar" />
131                <pathelement location="./build/obj_cobertura" />
132                <pathelement location="./build/obj" />
133                <pathelement location="../../../core/java/build/i2ptest.jar" />
134                <pathelement location="../../../core/java/build/i2p.jar" />
135                <pathelement location="../../ministreaming/java/build/mstreaming.jar" />
136                <pathelement location="../../build/jbigi.jar" />
137                <pathelement location="${with.clover}" />
138                <pathelement location="${with.cobertura}" />
139            </classpath>
140            <batchtest todir="../../../reports/streaming/junit/">
141                <fileset dir="./test/junit">
142                    <include name="**/*Test.java" />
143                    <include name="**/*IT.java" if="runIntegrationTests" />
144                </fileset>
145            </batchtest>
146            <formatter type="xml"/>
147        </junit>
148        <!-- set if unset -->
149        <property name="host.fakename" value="i2ptester" />
150        <!-- replace hostname that junit inserts into reports with fake one -->
151        <replaceregexp byline="true"
152            match="(hostname=)&quot;[^&quot;]+&quot;"
153            replace="\1&quot;${host.fakename}&quot;">
154            <fileset dir="../../../reports/streaming/junit/" />
155        </replaceregexp>
156    </target>
157    <target name="test" depends="junit.test"/>
158    <!-- test reports -->
159    <target name="junit.report">
160        <junitreport todir="../../../reports/streaming/junit">
161            <fileset dir="../../../reports/streaming/junit">
162                <include name="TEST-*.xml"/>
163            </fileset>
164            <report format="frames" todir="../../../reports/streaming/html/junit"/>
165        </junitreport>
166    </target>
167    <target name="clover.report" depends="test" if="with.clover">
168        <clover-report>
169            <current outfile="../../../reports/streaming/html/clover">
170                <format type="html"/>
171            </current>
172        </clover-report>
173    </target>
174    <target name="cobertura.report" depends="test" if="with.cobertura">
175        <mkdir dir="../../../reports/streaming/cobertura" />
176        <cobertura-report format="xml" srcdir="./src" destdir="../../../reports/streaming/cobertura" />
177        <mkdir dir="../../../reports/streaming/html/cobertura" />
178        <cobertura-report format="html" srcdir="./src" destdir="../../../reports/streaming/html/cobertura" />
179        <delete file="./cobertura.ser" />
180    </target>
181    <target name="test.report" depends="junit.report, clover.report, cobertura.report"/>
182    <!-- end test reports -->
183    <target name="fulltest" depends="cleandep, test, test.report" />
184    <!-- end unit tests -->
185
186    <target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
187        <exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
188            <arg value="list" />
189            <arg value="changed" />
190            <arg value="." />
191        </exec>
192        <!-- \n in an attribute value generates an invalid manifest -->
193        <exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
194            <arg value="-s" />
195            <arg value="[:space:]" />
196            <arg value="," />
197        </exec>
198    </target>
199
200    <target name="jar" depends="builddep, compile, jarUpToDate, listChangedFiles" unless="jar.uptodate" >
201        <!-- set if unset -->
202        <property name="workspace.changes.tr" value="" />
203        <jar destfile="./build/streaming.jar" basedir="./build/obj" includes="**/*.class" >
204            <manifest>
205                <attribute name="Implementation-Version" value="${full.version}" />
206                <attribute name="Built-By" value="${build.built-by}" />
207                <attribute name="Build-Date" value="${build.timestamp}" />
208                <attribute name="Base-Revision" value="${workspace.version}" />
209                <attribute name="Workspace-Changes" value="${workspace.changes.tr}" />
210            </manifest>
211        </jar>
212    </target>
213
214    <target name="jarUpToDate">
215        <uptodate property="jar.uptodate" targetfile="build/streaming.jar" >
216            <srcfiles dir= "." includes="build/obj/**/*.class" />
217        </uptodate>
218        <condition property="shouldListChanges" >
219            <and>
220                <not>
221                    <isset property="jar.uptodate" />
222                </not>
223                <isset property="mtn.available" />
224            </and>
225        </condition>
226    </target>
227
228    <target name="jarTest" depends="jar, junit.compileTest">
229        <jar destfile="./build/streaming.jar" basedir="./build/obj" includes="**/*Test*.class" update="true" />
230    </target>
231    <target name="javadoc">
232        <mkdir dir="./build" />
233        <mkdir dir="./build/javadoc" />
234        <javadoc
235            sourcepath="./src:../../../core/java/src:../../ministreaming/java/src" destdir="./build/javadoc"
236            packagenames="*"
237            use="true"
238            splitindex="true"
239            windowtitle="Streaming" />
240    </target>
241    <target name="clean">
242        <delete dir="./build" />
243    </target>
244    <target name="cleandep" depends="clean">
245    </target>
246    <target name="distclean" depends="clean">
247    </target>
248</project>
Note: See TracBrowser for help on using the repository browser.