-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.xml
219 lines (187 loc) · 9.36 KB
/
build.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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<project name="funz-core" default="help" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
<property name="funz-root.dir" value="${basedir}/.." />
<property name="funz.properties" location="../funz-profile/funz.properties" />
<!-- funz dependent properties -->
<property file="${funz.properties}" />
<!-- verify that the ${funz.properties} file has been set -->
<fail message="Set the funz properties file ${funz.properties} from funz-profile">
<condition>
<not>
<and>
<available file="${funz.properties}" type="file" />
</and>
</not>
</condition>
</fail>
<!-- funz core dependent properties -->
<property file="funz-core.properties"/>
<path id="antcontrib.classpath">
<pathelement location="../funz-profile/lib/ant-contrib-0.6.jar" />
</path>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="../funz-profile/lib/jacocoant.jar"/>
</taskdef>
<property name="unit.test.jar" value="../funz-profile/lib/concutest-junit-4.7-withrt.jar" />
<!--property name="unit.test.jar" value="../funz-profile/lib/junit-4.3.jar" /-->
<taskdef name="for" taskname="for" classname="net.sf.antcontrib.logic.For" classpathref="antcontrib.classpath" />
<taskdef name="if" taskname="if" classname="net.sf.antcontrib.logic.IfTask" classpathref="antcontrib.classpath" />
<taskdef name="propertycopy" taskname="propertycopy" classname="net.sf.antcontrib.property.PropertyCopy" classpathref="antcontrib.classpath" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="antcontrib.classpath" />
<property name="constants.java" location="${src.dir}/org/funz/Constants.java" />
<property name="constants.tmpl" location="${src.dir}/org/funz/Constants.tmpl" />
<!-- pathes and classpathes -->
<path id="root.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="compile.path" >
<path refid="root.classpath" />
</path>
<!-- clean targets -->
<target name="clean-build" description="clean up">
<delete dir="${build.dir}" failonerror="false" />
<delete dir="${build.ide.dir}" failonerror="false" />
</target>
<target name="clean-dist" description="clean up">
<delete dir="${dist.dir}" failonerror="false" />
</target>
<target name="clean-doc" description="">
<delete dir="${doc.dir}" failonerror="false" />
</target>
<target name="clean" depends="clean-build, clean-dist, clean-doc" />
<target name="compile" description="compile the source ">
<copy file="${constants.tmpl}" tofile="${constants.java}" overwrite="true" />
<echo message="Version: ${core.version}"/>
<replace file="${constants.java}" token="__VERSION__" value="${core.version}" />
<tstamp>
<format property="build.date" pattern="dd/MM/yyyy HH:mm"/>
</tstamp>
<echo message="Build date: ${build.date}"/>
<replace file="${constants.java}" token="__BUILDATE__" value="${build.date}" />
<!--replace file="${constants.java}" token="__PROTOCOL__" value="${protocol}"/-->
<mkdir dir="${build.dir}" />
<javac srcdir="${src.dir}" destdir="${build.dir}" encoding="ISO-8859-1" source="${java.compiler.version}" target="${java.compiler.version}" >
<classpath refid="root.classpath" />
</javac>
</target>
<target name="compile-test" depends="compile" description="compile the source ">
<mkdir dir="${build.dir}" />
<javac srcdir="${test.dir}" destdir="${build.dir}" encoding="ISO-8859-1" source="${java.compiler.version}" target="${java.compiler.version}" >
<classpath refid="root.classpath" />
<classpath path="${build.dir}" />
<classpath path="${unit.test.jar}" />
</javac>
<copy todir="." >
<fileset file="${test.resources.dir}/*"/>
</copy>
<chmod perm="a+x">
<fileset dir=".">
<include name="*.bat" />
<include name="*.sh" />
</fileset>
</chmod>
</target>
<target name="dist" depends="compile" description="generate the distribution">
<mkdir dir="${dist.dir}" />
<mkdir dir="${dist.lib.dir}" />
<copy todir="${dist.lib.dir}">
<fileset dir="${lib.dir}">
<include name="*" />
</fileset>
</copy>
<jar destfile="${dist.lib.dir}/${core.jar}">
<fileset dir="${build.dir}">
<include name="org/funz/**/*.class" />
<exclude name="org/funz/**/*Test.class" />
</fileset>
<fileset dir="${src.dir}">
<include name="org/funz/**/*.java" />
<exclude name="org/funz/**/*Test.java" />
</fileset>
</jar>
</target>
<!-- testing the funz client module -->
<target name="test" depends="compile-test, compile">
<fileset id="tests" dir="${build.dir}" includes="**/*Test.class" />
<!--property name="tests.p" refid="tests"/>
<echo message="${tests.p}"/-->
<pathconvert pathsep="${line.separator}" property="tests.list" refid="tests">
<map from="${build.dir}/" to=""/>
</pathconvert>
<!--echo message="${tests.list}"/>
<echo message="================"/-->
<for list="${tests.list}" param="test.class" delimiter="${line.separator}">
<sequential>
<echo message="@{test.class}"/>
<echo message="======================================="/>
<echo message="============= @{test.class} ============="/>
<echo message="========================================="/>
<propertyregex property="test.class" input="@{test.class}" regexp="\.class" replace="" global="true" override="true"/>
<!--echo message="${test.class}"/-->
<propertyregex property="test.class.id" input="${test.class}" regexp="[/\\]" replace="\." global="true" override="true"/>
<!--echo message="${test.class.id}"/-->
<!--record name="${test.class.id}.txt" action="start" /-->
<jacoco:coverage>
<java classname="${test.class.id}" fork="true" timeout="360000" failonerror="false" resultproperty="@{test.class}.failed">
<classpath refid="root.classpath" />
<classpath path="${build.dir}" />
<classpath path="${unit.test.jar}" />
<assertions>
<enable/>
</assertions>
</java>
</jacoco:coverage>
<!--record name="${test.class.id}.txt" action="stop"/-->
<if>
<equals arg1="${@{test.class}.failed}" arg2="0" />
<then>
</then>
<else>
<property name="failed" value="1" />
<echo message="Failures: @{test.class}" />
</else>
</if>
</sequential>
</for>
<fail message="Test failure detected, check test results." if="failed" />
</target>
<target name="coverage" >
<jacoco:report>
<executiondata>
<file file="jacoco.exec"/>
</executiondata>
<structure name="funz-core">
<classfiles>
<fileset dir="build"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="src/main/java"/>
</sourcefiles>
</structure>
<html destdir="coverage"/>
<xml destfile="jacoco.xml"/>
</jacoco:report>
</target>
<target name="doc-Parser" >
<mkdir dir="${doc.dir}" />
<mkdir dir="${doc.dir}/parser" />
<javadoc sourcepath="${src.dir}" packagenames="org.funz.util.*" classpathref="compile.path" destdir="${doc.dir}/parser" access="public"/>
</target>
<target name="doc" >
<mkdir dir="${doc.dir}" />
<javadoc sourcepath="${src.dir}" packagenames="org.funz.*" classpathref="compile.path" destdir="${doc.dir}" access="public"/>
</target>
<!-- help -->
<target name="help" description="display the help on standard output">
<echo message="********************************" />
<echo message=" Funz core" />
<echo message="********************************" />
<echo />
<echo message="help : display this help" />
<echo message="clean : clean everything that can be generated by ant targets" />
<echo message="dist : generate a distribution" />
<echo message="test : run tests" />
<echo message="doc : generate the code documentation" />
</target>
</project>