Statistics
| Revision:

svn-gvsig-desktop / trunk / binaries / ant / utilities.xml @ 19663

History | View | Annotate | Download (7.76 KB)

1
<project name="ant_libs">
2
        <dirname file="${ant.file.ant_libs}" property="ant.file.ant_libs.dir"/>
3

    
4
        <!--
5
                ====================================
6
                Compilation base properties
7
                ====================================
8
        -->
9
        <property name="JUNIT_HOME" location="${ant.file.ant_libs.dir}" />
10
        <property name="JavaSourceVersion" value="1.5"/>
11
        <property name="JavaTargetVersion" value="1.5"/>
12
        <property name="debug" value="on"/>
13
        <property name="debuglevel" value="lines, vars"/>
14
        <property name="encoding" value="ISO_8859_1"/>
15

    
16

    
17

    
18

    
19
        <!--
20
                ====================================
21
                ant4eclipse library load
22
                ====================================
23
        -->
24
        <taskdef resource="net/sf/ant4eclipse/antlib.xml" >
25
                        <classpath>
26
                                <pathelement location="${ant.file.ant_libs.dir}/ant4eclipse-0.5.0.rc1.jar"/>
27
                        </classpath>
28
        </taskdef>
29

    
30

    
31

    
32

    
33
        <!--
34
                ====================================
35
                ant-contrib library load
36
                ====================================
37
        -->
38
        <taskdef resource="net/sf/antcontrib/antlib.xml">
39
                        <classpath>
40
                                <pathelement location="${ant.file.ant_libs.dir}/ant-contrib-1.0b3.jar"/>
41
                                <pathelement location="${ant.file.ant_libs.dir}/bcel-5.1.jar"/>
42
                                <pathelement location="${ant.file.ant_libs.dir}/commons-httpclient-3.0.1.jar"/>
43
                                <pathelement location="${ant.file.ant_libs.dir}/commons-logging-1.0.4.jar"/>
44
                                <pathelement location="${ant.file.ant_libs.dir}/ivy-1.3.1.jar"/>
45
                        </classpath>
46
        </taskdef>
47

    
48

    
49

    
50
        <!--
51
                ====================================
52
                gvSIG ant utilities library load
53
                ====================================
54
        -->
55
        <taskdef name="javacLikeEclipse" classname="org.gvsig.utilities.ant.taskdefs.JavacLikeEclipse">
56
                <classpath>
57
                        <pathelement location="${ant.file.ant_libs.dir}/org.gvsig.utilities.ant.jar"/>
58
                </classpath>
59
        </taskdef>
60

    
61

    
62

    
63
        <!--
64
                ====================================
65
                utilities tasks alias
66
                ====================================
67
        -->
68

    
69
        <!--
70
        ** loadEclipseClasspath Task  **
71

72
        Load the classpath from eclipse into the property 'eclipseClasspath'
73
        of the project recived in 'project' attribute. 'project' must
74
        be a directory of the workspace.
75

76
        - Use 'property="otherProperty"' : for change the return property
77

78
        Example:
79

80

81
        <target name="compile" description="compile the source" >
82
                <loadEclipseClasspath project="${basedir}>
83
                <mkdir dir="${build}" />
84
                <javac  srcdir="${src}"
85
                        destdir="${build}"
86
                        source="${JavaSourceVersion}"
87
                        target="${JavaTargetVersion}"
88
                        debug="${debug}"
89
                        debuglevel="${debuglevel}"
90
                        classpath="${eclipseClasspath}"
91
                        encoding="${encoding}"/>
92
        </target>
93

94
        -->
95
        <presetdef name="loadEclipseClasspath">
96
                <getEclipseClasspath
97
                        property="eclipseClasspath"
98
                        runtime="true"/>
99

    
100
        </presetdef>
101

    
102
        <!--
103
        ** gvSIG-javac Task **
104

105
        Javac whit default values to compile gvSIG proyects
106

107
        Example (minimal syntax):
108

109
        <gvSIG-javac
110
                classpath="${eclipseClasspath}"
111
                />
112

113
        Example with exclude:
114

115
        <gvSIG-javac
116
                classpath="${eclipseClasspath}"
117
                exclude="org/gvsig/test/**"
118
                />
119

120
        -->
121
        <presetdef name="gvSIG-javac">
122
                        <javacLikeEclipse
123
                                srcdir="${src}"
124
                                destdir="${build}"
125
                                source="${JavaSourceVersion}"
126
                                target="${JavaTargetVersion}"
127
                                sourcepath="${eclipseClasspath}"
128
                                encoding="${encoding}">
129
                        </javacLikeEclipse>
130
        </presetdef>
131

    
132
        <!-- generamos siempre el debug
133
        <presetdef name="gvSIG-javac">
134
                        <javacLikeEclipse
135
                                srcdir="${src}"
136
                                destdir="${build}"
137
                                source="${JavaSourceVersion}"
138
                                target="${JavaTargetVersion}"
139
                                debug="${debug}"
140
                                debuglevel="${debuglevel}"
141
                                sourcepath="${eclipseClasspath}"
142
                                encoding="${encoding}">
143
                        </javacLikeEclipse>
144
        </presetdef>
145
        -->
146

    
147
        <!--
148
        ** gvSIG-import-build-number Target **
149

150
        Automate import of build.number gvSIG file
151

152
        Example (minimal syntax):
153

154
        <antcall target="gvSIG-import-build-number"/>
155

156
        -->
157

    
158
        <target name="gvSIG-import-build-number">
159
                <!-- check buildNumberFile property -->
160
                <if>
161
                        <not>
162
                                <and>
163
                                        <isset property="buildNumberFile"/>
164
                                        <available file="${buildNumberFile}" type="file"/>
165
                                </and>
166
                        </not>
167
                        <then>
168
                                <fail message="Error: property buildNumberFile not set or file not available: ${buildNumberFile}"/>
169
                        </then>
170
                </if>
171
                <property name="localBuildNumberFile" value="${basedir}/build.number"/>
172
                <!-- copy the file if is needed-->
173
                <if>
174
                        <not>
175
                        <and>
176
                                <available file="${localBuildNumberFile}" type="file"/>
177
                                <filesmatch file1="${buildNumberFile}" file2="${localBuildNumberFile}"/>
178
                        </and>
179
                        </not>
180
                        <then>
181
                                <copy file="${buildNumberFile}" tofile="${localBuildNumberFile}" overwrite="true"/>
182
                        </then>
183
                </if>
184
        </target>
185

    
186
        <!-- Declare Junit task -->
187
        <taskdef name="gvSIG-junit" classname="org.apache.tools.ant.taskdefs.optional.junit2.JUnitTask" onerror="fail">
188
                <classpath>
189
                        <pathelement location="${ant.file.ant_libs.dir}/junit.jar"/>
190
                        <pathelement location="${ant.file.ant_libs.dir}/gvsig-ant-junit.jar"/>
191
                </classpath>
192
        </taskdef>
193

    
194
        <target name="generic-run-tests">
195
                <!--
196
                        === Input Parameters ===
197
                        JUnitSummaryFile: File to log the success of the project
198
                        JUnitProjectResults: File to log the details of the JUnit execution
199
                        TestSuite.Name: Name of the TestSuite class to run
200

201
                        === Throws ====
202
                        JUnitTestFailed: If any of the tests failed
203
                -->
204
                <!-- define these properties in case they are not already set -->
205
                <property name="JUnitProjectResults" value="JUnitProjectResults"/>
206
                <property name="JUnitProjectResultsFile" value="JUnitProjectResults.txt"/>
207
                <property name="JUnitGlobalResults" value="JUnitGlobalResults"/>
208
                <property name="JUnitGlobalResultsFile" value="JUnitGlobalResults.txt"/>
209
                <property name="JUnitSummaryFile" location="JUnitSummary.txt"/>
210
                <loadEclipseClasspath project="${basedir}"/>
211
                <property name="test-classpath" value="${build-test}:${build}:${eclipseClasspath}"/>
212
                <gvSIG-junit
213
                        fork="yes"
214
                        dir="${basedir}"
215
                        printsummary="on"
216
                        haltonfailure="off"
217
                        errorproperty="gvsig.tests.error"
218
                        failureproperty="gvsig.tests.failure">
219
                                <formatter type="brief" usefile="yes"/>
220
                                <classpath id="test-classpath"
221
                                        path="${build-test}:${build}:${eclipseClasspath}"/>
222
                                <test name="${TestSuite.Name}" outFile="${JUnitProjectResults}" />
223
                </gvSIG-junit>
224
                <!-- define these properties in case they are not already set -->
225
                <property name="gvsig.tests.error" value="false"/>
226
                <property name="gvsig.tests.failure" value="false"/>
227
                <if>
228
                        <and>
229
                                <equals arg1="${gvsig.tests.error}" arg2="false" />
230
                                <equals arg1="${gvsig.tests.failure}" arg2="false" />
231
                        </and>
232
                        <then>
233
                                <echo file="${JUnitSummaryFile}" append="true">JUnitTests for ${target.project.name}: SUCCESS.${line.separator}</echo>
234
                        </then>
235
                        <else>
236
                                <throw id="JUnitTestFailed" message="JUnitTestFailed"/>
237
                        </else>
238
                </if>
239
        </target>
240

    
241
        <target name="concat-test-output">
242
                <property name="target.project.dir" location="../${target.project.name}"/>
243
                <if>
244
                        <available file="${target.project.dir}" type="dir"/>
245
                        <then>
246
                                <echo append="yes" file="${JUnitGlobalResultsFile}">${line.separator}${line.separator} ===== Details for ${target.project.name}: =====${line.separator}</echo>
247
                                <concat  destfile="${JUnitGlobalResultsFile}.tmp"
248
                                                binary="true">
249
                                        <fileset file="${JUnitGlobalResultsFile}"/>
250
                                        <fileset file="${target.project.dir}/${JUnitProjectResultsFile}"/>
251
                                </concat>
252
                                <move file="${JUnitGlobalResultsFile}.tmp" tofile="${JUnitGlobalResultsFile}"/>
253
                                <delete file="${target.project.dir}/${JUnitProjectResultsFile}"/>
254
                        </then>
255
                </if>
256
        </target>
257

    
258
        <target name="compile-tests">
259
                <!-- Create the time stamp -->
260
                <tstamp/>
261
                <!-- Create the build directory structure used by compile -->
262
                <mkdir dir="${build-test}"/>
263
                <!-- Compile the Java code from ${src} to ${build} -->
264
                <loadEclipseClasspath project="${basedir}"/>
265
                <gvSIG-javac
266
                        srcdir="${src-test}"
267
                        destdir="${build-test}"
268
                        classpath="${eclipseClasspath}"/>
269
                <copy todir="${build-test}">
270
                        <fileset dir="${src-test}"
271
                                                excludes="**/*.java"/>
272
                </copy>
273
        </target>
274

    
275
</project>