public
Description: A light weight file IO library to ease the use of Java File IO related API and enable the testability.
Homepage: http://cotta.sourceforge.net/
Clone URL: git://github.com/wolfdancer/cotta.git
cotta / build.xml
100644 202 lines (180 sloc) 7.172 kb
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
<project name="cotta.template" default="report.coverage" basedir="core">
  <property file="../build.properties"/>
  <property name="product" value="cotta"/>
  <property name="cfg.coverage.metrics" value="emma.threshold=class:95,method:89,block:87,line:88"/>
  <property name="cfg.javadoc.packagenames" value="net.sf.*"/>
 
  <fileset id="lib.dist" dir="../lib/commons-net">
    <include name="**/*.jar"/>
  </fileset>
 
  <path id="dep.cls.prod">
    <fileset refid="lib.dist"/>
    <fileset dir="../lib/junit">
      <include name="**/*.jar"/>
    </fileset>
    <fileset dir="../lib/hamcrest">
      <include name="**/*.jar"/>
    </fileset>
  </path>
 
  <path id="dep.cls.behaviour">
    <path refid="dep.cls.prod"/>
    <fileset dir="../lib/jmock">
      <include name="**/*.jar"/>
    </fileset>
    <pathelement location="${cls.prod}"/>
  </path>
 
  <path id="dep.cls.ftp.behaviour">
    <path refid="dep.cls.behaviour"/>
    <pathelement location="${cls.behaviour}"/>
    <fileset dir="../lib/commons-io">
      <include name="**/*.jar"/>
    </fileset>
    <fileset dir="../lib/coloradoftp">
      <include name="**/*.jar"/>
    </fileset>
  </path>
 
  <path id="dep.cls.prod.instr">
    <fileset dir="../lib/emma">
      <include name="**/*.jar"/>
    </fileset>
  </path>
 
  <path id="dep.report.coverage">
    <path refid="dep.cls.prod.instr"/>
    <pathelement location="${cls.prod.instr}"/>
    <path refid="dep.cls.behaviour"/>
    <pathelement location="${cls.behaviour}"/>
    <path refid="dep.cls.ftp.behaviour"/>
    <pathelement location="${cls.ftp.behaviour}"/>
  </path>
 
  <taskdef resource="emma_ant.properties" classpathref="dep.cls.prod.instr"/>
 
  <target name="cls.prod">
    <mkdir dir="${cls.prod}"/>
    <javac srcdir="${src.prod}" destdir="${cls.prod}" source="1.5" target="1.5" debug="true"
           classpathref="dep.cls.prod"/>
    <copy todir="${cls.prod}">
      <fileset dir="${src.prod}" excludes="**/*.java"/>
    </copy>
  </target>
 
  <target name="cls.behaviour" depends="cls.prod">
    <mkdir dir="${cls.behaviour}"/>
    <javac srcdir="${src.behaviour}" destdir="${cls.behaviour}" source="1.5"
           target="1.5" debug="true"
           classpathref="dep.cls.behaviour"/>
    <copy todir="${cls.behaviour}">
      <fileset dir="${res.behaviour}"/>
    </copy>
  </target>
 
  <target name="cls.ftp.behaviour" depends="cls.behaviour">
    <mkdir dir="${cls.ftp.behaviour}"/>
    <javac srcdir="${src.ftp.behaviour}" destdir="${cls.ftp.behaviour}" source="1.5"
           target="1.5" debug="true"
           classpathref="dep.cls.ftp.behaviour"/>
    <copy todir="${cls.ftp.behaviour}">
      <fileset dir="${res.ftp.behaviour}"/>
    </copy>
  </target>
 
  <target name="cls.prod.instr" depends="cls.prod">
    <emma enabled="true">
      <instr instrpath="${cls.prod}"
             destdir="${cls.prod.instr}"
             metadatafile="${report.coverage.metadata}"
             merge="true">
        <filter value="${cfg.coverage.includes}"/>
      </instr>
    </emma>
    <copy todir="${cls.prod.instr}">
      <fileset dir="${cls.prod}" excludes="**/*.class"/>
    </copy>
  </target>
 
  <target name="report.coverage" depends="cls.prod.instr, cls.behaviour, cls.ftp.behaviour">
    <mkdir dir="${report.test}/core"/>
    <mkdir dir="${report.test}/ftp"/>
    <junit printsummary="yes" fork="yes" haltonerror="yes" haltonfailure="yes">
      <classpath refid="dep.report.coverage"/>
      <jvmarg line="-Demma.coverage.out.file=${report.coverage}"/>
      <jvmarg line="-Demma.coverage.out.merge=true"/>
      <test name="net.sf.cotta.acceptance.AllTests" todir="${report.test}/core">
        <formatter type="xml"/>
      </test>
    </junit>
    <junit fork="yes" haltonerror="yes" haltonfailure="yes">
      <classpath refid="dep.report.coverage"/>
      <!--<jvmarg line="-Demma.coverage.out.file=${report.coverage}"/>-->
      <!--<jvmarg line="-Demma.coverage.out.merge=true"/>-->
      <jvmarg line="-Xmx512m"/>
      <test name="net.sf.cotta.ftp.FtpFileSystemTest" todir="${report.test}/ftp">
        <formatter type="plain"/>
      </test>
    </junit>
  </target>
 
  <target name="report.coverage.summary" depends="report.coverage">
    <emma enabled="true">
      <report sourcepath="${src.prod}" metrics="${cfg.coverage.metrics}" columns="class,method,block,line,name">
        <fileset dir=".">
          <include name="${report.coverage}"/>
          <include name="${report.coverage.metadata}"/>
        </fileset>
        <txt outfile="${basedir}/${report.covereage.txt}"/>
        <html outfile="${basedir}/${report.covereage.html}"/>
      </report>
    </emma>
    <loadfile srcfile="${basedir}/${report.covereage.txt}" property="report.coverage.summary">
      <filterchain>
        <linecontains>
          <contains value="all classes"/>
        </linecontains>
      </filterchain>
    </loadfile>
    <echo>Coverage Summary:${line.separator}class, method, block, line${line.separator}${report.coverage.summary}
    </echo>
    <condition property="coverage.istoolow">
      <contains string="${report.coverage.summary}" substring="!"/>
    </condition>
    <fail message="Coverage is below threshold: ${cfg.coverage.metrics}" if="coverage.istoolow"/>
  </target>
 
  <target name="report.duplication">
    <taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask">
      <classpath>
        <fileset dir="../lib/pmd">
          <include name="**/*.jar"/>
        </fileset>
      </classpath>
    </taskdef>
    <cpd minimumTokenCount="50" outputFile="${report.duplicaiton}">
      <fileset dir="${src.prod}">
        <include name="**/*.java"/>
      </fileset>
    </cpd>
  </target>
 
  <target name="report.javadoc">
    <echo message="${cfg.javadoc.packagenames}"/>
    <javadoc packagenames="${cfg.javadoc.packagenames}" sourcepath="${src.prod}" destdir="${report.javadoc}"
             access="public"/>
  </target>
 
  <target name="pkg.cls.prod" depends="cls.prod">
    <jar basedir="${cls.prod}" file="${pkg.cls.prod}" index="true"
         manifest="${src.prod}/META-INF/MANIFEST.MF"/>
  </target>
 
  <target name="pkg.src.prod">
    <zip basedir="${src.prod}" destfile="${pkg.src.prod}"/>
  </target>
 
  <target name="dist" depends="pkg.cls.prod, pkg.src.prod">
    <copy file="${pkg.cls.prod}" tofile="../dist/${product}.jar"/>
    <copy file="${pkg.src.prod}" tofile="../dist/${product}-src.zip"/>
    <property name="dir.product" value="../dist/${product}"/>
    <mkdir dir="${dir.product}"/>
    <copy file="${pkg.cls.prod}" tofile="${dir.product}/${product}.jar"/>
    <copy file="${pkg.src.prod}" tofile="${dir.product}/${product}-src.zip"/>
    <copy file="LICENSE.txt" todir="${dir.product}"/>
    <mkdir dir="${dir.product}/lib"/>
    <copy todir="${dir.product}/lib">
      <fileset refid="lib.dist"/>
    </copy>
    <zip basedir="${dir.product}" destfile="../dist/${product}-all.zip"/>
    <delete dir="${dir.product}"/>
  </target>
 
  <target name="clean.env">
    <delete dir="build"/>
  </target>
 
  <target name="reports" depends="report.coverage.summary, report.duplication, report.javadoc"/>
  <target name="all" depends="clean.env, reports, dist"/>
 
</project>