-
Notifications
You must be signed in to change notification settings - Fork 6
/
ccBuild.xml
205 lines (172 loc) · 7.03 KB
/
ccBuild.xml
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
<project name="BankAccount" basedir="." default="emma">
<!-- Diretorios do projeto -->
<property name="src.dir" value="src"/>
<property name="web.dir" value="WebSite"/>
<property name="bin.dir" value="WebSite/WEB-INF/classes"/>
<property name="teste.dir" value="test"/>
<property name="lib.dir" value="WebSite/WEB-INF/lib"/>
<!-- Diretorios do PMD-->
<property name="pmd.out.dir" value="out/pmd"/>
<!-- Diretorios do JUnit-->
<property name="junit.out.dir" value="out/junit"/>
<!-- Diretorio para gera Deploy-->
<property name="dist.dir" value="out/dist"/>
<property name="tomcat7.dir" value="../lib/apache-tomcat-7.0.23/webapps"/>
<!-- Diretorios do Emma -->
<property name="emma.bin.dir" value="out/bin"/>
<property name="emma.metadado.dir" value="out/metadado"/>
<property name="emma.relatorio.dir" value="out/relatorio"/>
<!-- Suite de Teste -->
<property name="suite.testes" value="com.facensa.bank.model.AllTests"/>
<!-- Flag indicando se o Emma deve ser executado -->
<property name="emma.deveExecutar" value="true"/>
<!-- propriedades do deploy -->
<touch file="deployid.properties"/>
<property file="deployid.properties"/>
<!-- Classpath do projeto -->
<path id="project.classpath">
<pathelement location="${bin.dir}"/>
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<!-- Define tasks do Emma -->
<taskdef resource="emma_ant.properties">
<classpath refid="project.classpath"/>
</taskdef>
<!-- Define tasks do JUnit -->
<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
<classpath refid="project.classpath"/>
</taskdef>
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
<classpath refid="project.classpath"/>
</taskdef>
<taskdef name="fit" classname="com.cmdev.fit.ant.FitTask">
<classpath refid="project.classpath"/>
</taskdef>
<taskdef name="cpd" classname="net.sourceforge.pmd.cpd.CPDTask">
<classpath refid="project.classpath"/>
</taskdef>
<!-- Inicializa o diretorio bin, que armazena as classes compiladas -->
<target name="init">
<delete dir="${bin.dir}"/>
<mkdir dir="${bin.dir}"/>
<mkdir dir="${dist.dir}"/>
<mkdir dir="${emma.bin.dir}"/>
<mkdir dir="${emma.metadado.dir}"/>
<mkdir dir="${emma.relatorio.dir}"/>
<mkdir dir="${pmd.out.dir}"/>
<mkdir dir="${junit.out.dir}"/>
</target>
<!-- Compila a aplicacao -->
<target name="compilaSrc" depends="init">
<javac debug="on" srcdir="${src.dir}" destdir="${bin.dir}">
<classpath refid="project.classpath"/>
</javac>
</target>
<!-- Emma instrumenta as classes compiladas da aplicacao -->
<target name="instrumenta" depends="compilaSrc">
<emma enabled="${emma.deveExecutar}">
<instr instrpath="${bin.dir}" destdir="${emma.bin.dir}"
metadatafile="${emma.metadado.dir}/metadado.emma"
merge="false" mode="fullcopy">
</instr>
</emma>
</target>
<!-- Compila os testes -->
<target name="compilaTeste">
<javac debug="on" srcdir="${teste.dir}" destdir="${bin.dir}">
<classpath refid="project.classpath"/>
</javac>
<copy todir="${bin.dir}">
<fileset dir="${teste.dir}" includes="**/*.xls"/>
</copy>
</target>
<!-- Executa os testes contra as classes da aplicacao instrumentadas pelo Emma -->
<target name="testa" depends="instrumenta, compilaTeste">
<junit haltonfailure="false" haltonerror="false" fork="true" printsummary="yes" failureproperty="unit.test.failure">
<classpath>
<pathelement location="${emma.bin.dir}/classes"/>
<pathelement location="${emma.bin.dir}/lib"/>
<path refid="project.classpath"/>
</classpath>
<formatter type="xml" />
<!--formatter type="plain" usefile="false"/-->
<test name="${suite.testes}" todir="${junit.out.dir}"/>
<jvmarg value="-Demma.coverage.out.file=${emma.metadado.dir}/cobertura.emma"/>
<jvmarg value="-Demma.coverage.out.merge=false"/>
</junit>
<junitreport todir="${junit.out.dir}">
<fileset dir="${junit.out.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${junit.out.dir}/html" />
</junitreport>
<fail message="At least one unit test has failed" if="unit.test.failure" />
</target>
<target name="run-acceptance-tests">
<fit usewiki="false" destdir="${junit.out.dir}">
<fileset dir="${teste.dir}">
<include name="*.html" />
</fileset>
</fit>
</target>
<!-- Gera relatorio do Emma -->
<target name="emma" depends="testa, run-acceptance-tests, pmd, cpd">
<delete dir="${emma.relatorio.dir}"/>
<emma enabled="${emma.deveExecutar}">
<report sourcepath="${src.dir}"
sort="+block,+name,+method,+class"
metrics="method:70,block:80,line:80,class:100">
<fileset dir="${emma.metadado.dir}">
<include name="*.emma"/>
</fileset>
<html outfile="${emma.relatorio.dir}/index.html" depth="method" columns="name,class,method,block,line"/>
</report>
</emma>
<antcall target="clean"/>
</target>
<!-- Deleta diretorios de trabalho do Emma -->
<target name="clean">
<delete dir="${emma.bin.dir}"/>
<delete dir="${emma.metadado.dir}"/>
</target>
<target name="pmd">
<pmd rulesetfiles="rulesets/favorites.xml">
<!--formatter type="net.sourceforge.pmd.renderers.HTMLRenderer" toFile="pmd.html"/-->
<formatter type="net.sourceforge.pmd.renderers.SummaryHTMLRenderer" toFile="${pmd.out.dir}/pmd.html"/>
<formatter type="net.sourceforge.pmd.renderers.VBHTMLRenderer" toFile="${pmd.out.dir}/pmd_vb.html"/>
<formatter type="net.sourceforge.pmd.renderers.XMLRenderer" toFile="${pmd.out.dir}/pmd_xml.xml"/>
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
</pmd>
</target>
<target name="cpd">
<cpd minimumTokenCount="30" outputFile="${pmd.out.dir}/cpd_pmd.txt">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
</cpd>
</target>
<!-- gera o .war e copia para a pasta dist do projeto -->
<target name="war" depends="compilaSrc">
<echo>gerando war file para deploy</echo>
<propertyfile file="deployid.properties">
<entry key="build.count" default="0" type="int" operation="+" value="1" pattern="0000"/>
</propertyfile>
<property file="deployid.properties"/>
<war destfile="${dist.dir}/${ant.project.name}##${build.count}.war" webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"/>
<exclude name="**/*web.xml"/>
</fileset>
</war>
</target>
<!-- Deploy!! Foco em Tomcat 7 -->
<target name="deploy" depends="testa, run-acceptance-tests, pmd, cpd, war">
<move todir="${tomcat7.dir}">
<fileset dir="${dist.dir}" includes="**/*.war"/>
</move>
</target>
</project>