Update JaCoCo
[ant-ivy.git] / build.xml
1 <!--
2 Licensed to the Apache Software Foundation (ASF) under one
3 or more contributor license agreements. See the NOTICE file
4 distributed with this work for additional information
5 regarding copyright ownership. The ASF licenses this file
6 to you under the Apache License, Version 2.0 (the
7 "License"); you may not use this file except in compliance
8 with the License. You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing,
13 software distributed under the License is distributed on an
14 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 KIND, either express or implied. See the License for the
16 specific language governing permissions and limitations
17 under the License.
18 -->
19 <project name="ivy" default="test-report" xmlns:ivy="antlib:org.apache.ivy.ant">
20
21 <property environment="env"/>
22 <property file="version.properties"/>
23 <property file="build.properties"/>
24
25 <property name="final.name" value="ivy.jar"/>
26
27 <target name="init-ivy-user-home" unless="ivy.use.local.home">
28 <condition property="ivy.home" value="${env.IVY_HOME}">
29 <isset property="env.IVY_HOME"/>
30 </condition>
31 <property name="ivy.home" value="${user.home}/.ivy2"/>
32 </target>
33
34 <target name="init-ivy-local-home" if="ivy.use.local.home">
35 <property name="ivy.home" value="${basedir}/.ivy2"/>
36 </target>
37
38 <target name="init-ivy-home" depends="init-ivy-user-home,init-ivy-local-home"/>
39
40 <target name="init-ivy" depends="compile-bootstrap,init-ivy-home">
41 <taskdef resource="org/apache/ivy/ant/antlib.xml"
42 uri="antlib:org.apache.ivy.ant">
43 <classpath>
44 <pathelement location="${core.classes.build.dir}"/>
45 <pathelement location="${bootstrap.classes.build.dir}"/>
46 </classpath>
47 </taskdef>
48
49 <ivy:configure override="true"/>
50 </target>
51
52 <target name="install" depends="jar"
53 description="build Ivy and install it in Ivy user home for builds using Ivy user home to load Ivy jar">
54 <property name="ivy.jar.file" value="${ivy.home}/jars/ivy.jar"/>
55 <copy file="${artifacts.build.dir}/jars/${final.name}" tofile="${ivy.jar.file}"/>
56 </target>
57
58 <target name="install-ant" depends="jar"
59 description="build Ivy and install it in Ant home lib">
60 <condition property="ant.home" value="${env.ANT_HOME}">
61 <isset property="env.ANT_HOME"/>
62 </condition>
63 <fail unless="ant.home" message="ANT_HOME environment variable or ant.home property required"/>
64 <copy file="${artifacts.build.dir}/jars/${final.name}" tofile="${ant.home}/lib/ivy.jar"/>
65 </target>
66
67 <!-- =================================================================
68 PREPARATION, CLEANING AND FLAGS TASKS
69 ================================================================= -->
70 <target name="init">
71 <path id="lib.classpath">
72 <fileset dir="${lib.dir}">
73 <include name="*.jar"/>
74 </fileset>
75 </path>
76 <path id="build.bootstrap.classpath">
77 <pathelement location="${core.classes.build.dir}"/>
78 </path>
79 <path id="build.ant.classpath">
80 <pathelement location="${core.classes.build.dir}"/>
81 <path refid="lib.classpath"/>
82 </path>
83 <path id="build.optional.classpath">
84 <path refid="build.ant.classpath"/>
85 </path>
86 <path id="run.classpath">
87 <pathelement location="${core.classes.build.dir}"/>
88 <pathelement location="${ant.classes.build.dir}"/>
89 <pathelement location="${optional.classes.build.dir}"/>
90 <path refid="lib.classpath"/>
91 </path>
92 <path id="test.classpath">
93 <fileset dir="${lib.dir}" />
94 <pathelement location="${core.classes.build.dir}"/>
95 <pathelement location="${ant.classes.build.dir}"/>
96 <pathelement location="${optional.classes.build.dir}"/>
97 <pathelement path="${test.build.dir}"/>
98 </path>
99 <path id="javadoc.test.classpath">
100 <path refid="run.classpath"/>
101 <pathelement path="${test.build.dir}"/>
102 </path>
103 </target>
104
105 <target name="prepare" depends="init">
106 <mkdir dir="${classes.build.dir}"/>
107 <mkdir dir="${core.classes.build.dir}"/>
108 <mkdir dir="${bootstrap.classes.build.dir}"/>
109 <mkdir dir="${ant.classes.build.dir}"/>
110 <mkdir dir="${optional.classes.build.dir}"/>
111 <mkdir dir="${all.classes.build.dir}"/>
112 <mkdir dir="${test.build.dir}"/>
113 <mkdir dir="${artifacts.build.dir}"/>
114 <mkdir dir="${test.report.dir}"/>
115 </target>
116
117 <target name="clean" description="delete all generated files keeping sources only">
118 <delete dir="${classes.build.dir}"/>
119 <delete dir="${test.build.dir}"/>
120 <delete dir="${artifacts.build.dir}"/>
121 <delete dir="${ivy.report.dir}"/>
122 <delete dir="${test.report.dir}"/>
123 <delete dir="${javadoc.build.dir}"/>
124 <delete dir="${doc.build.dir}"/>
125 <delete dir="${build.dir}"/>
126 </target>
127
128 <target name="clean-lib">
129 <delete dir="${lib.dir}"/>
130 </target>
131
132 <target name="clean-ivy-cache" depends="init-ivy-home">
133 <delete dir="${ivy.home}/cache"/>
134 </target>
135
136 <target name="clean-ivy-home" depends="init-ivy-home">
137 <delete dir="${ivy.home}"/>
138 </target>
139
140 <target name="clean-examples" description="clean all examples">
141 <subant target="clean" failonerror="false">
142 <fileset dir="${example.dir}" includes="**/build.xml"/>
143 </subant>
144 </target>
145
146 <target name="clean-all" depends="clean-examples,clean,clean-lib"/>
147
148 <target name="/noresolve" description="use to skip dependency resolution">
149 <property name="no.resolve" value="true"/>
150 </target>
151
152 <target name="/notest" description="use to skip tests">
153 <property name="skip.test" value="true"/>
154 </target>
155
156 <target name="/nojavadoc" description="use to skip javadoc">
157 <property name="skip.javadoc" value="true"/>
158 </target>
159
160 <target name="/localivy" description="use a local ivy home">
161 <property name="ivy.use.local.home" value="true"/>
162 </target>
163
164 <target name="/offline" depends="/noresolve" description="use to indicate no internet connection is available">
165 <property name="offline" value="true"/>
166 </target>
167
168 <target name="default-version">
169 <tstamp>
170 <format property="pubdate" pattern="yyyyMMddHHmmss"/>
171 </tstamp>
172 <property name="version.prefix" value="${target.ivy.version}-local-"/>
173 <property name="build.version" value="${version.prefix}${pubdate}"/>
174 <property name="bundle.version" value="${target.ivy.bundle.version}.${target.ivy.bundle.version.qualifier}${pubdate}"/>
175 </target>
176
177 <!-- =================================================================
178 DEPENDENCY MNGT, COMPILATION AND JAR
179 ================================================================= -->
180 <target name="resolve" depends="init-ivy" unless="no.resolve">
181 <ivy:retrieve conf="default,test" pattern="${lib.dir}/[artifact].[ext]" sync="yes"/>
182 </target>
183
184 <target name="compile-core" depends="prepare">
185 <javac srcdir="${src.dir}"
186 destdir="${core.classes.build.dir}"
187 sourcepath=""
188 source="${ivy.minimum.javaversion}"
189 target="${ivy.minimum.javaversion}"
190 debug="${debug.mode}"
191 includeantruntime="no">
192 <excludesfile name="ant.patterns"/>
193 <excludesfile name="optional.patterns"/>
194 </javac>
195 <copy todir="${core.classes.build.dir}" includeEmptyDirs="false">
196 <fileset dir="${src.dir}">
197 <exclude name="**/*.java"/>
198 <excludesfile name="ant.patterns"/>
199 <excludesfile name="optional.patterns"/>
200 </fileset>
201 </copy>
202
203 <!-- copy settings files for backward compatibility with ivyconf naming -->
204 <copy file="${core.classes.build.dir}/org/apache/ivy/core/settings/ivysettings-local.xml"
205 tofile="${core.classes.build.dir}/org/apache/ivy/core/settings/ivyconf-local.xml"/>
206 <copy file="${core.classes.build.dir}/org/apache/ivy/core/settings/ivysettings-default-chain.xml"
207 tofile="${core.classes.build.dir}/org/apache/ivy/core/settings/ivyconf-default-chain.xml"/>
208 <copy file="${core.classes.build.dir}/org/apache/ivy/core/settings/ivysettings-main-chain.xml"
209 tofile="${core.classes.build.dir}/org/apache/ivy/core/settings/ivyconf-main-chain.xml"/>
210 <copy file="${core.classes.build.dir}/org/apache/ivy/core/settings/ivysettings-public.xml"
211 tofile="${core.classes.build.dir}/org/apache/ivy/core/settings/ivyconf-public.xml"/>
212 <copy file="${core.classes.build.dir}/org/apache/ivy/core/settings/ivysettings-shared.xml"
213 tofile="${core.classes.build.dir}/org/apache/ivy/core/settings/ivyconf-shared.xml"/>
214 <copy file="${core.classes.build.dir}/org/apache/ivy/core/settings/ivysettings.xml"
215 tofile="${core.classes.build.dir}/org/apache/ivy/core/settings/ivyconf.xml"/>
216 </target>
217
218 <!-- Build the Ant tasks with the current Ant runtime -->
219 <target name="compile-bootstrap" depends="compile-core">
220 <javac srcdir="${src.dir}"
221 destdir="${bootstrap.classes.build.dir}"
222 sourcepath=""
223 classpathref="build.bootstrap.classpath"
224 source="${ivy.minimum.javaversion}"
225 target="${ivy.minimum.javaversion}"
226 debug="${debug.mode}"
227 includeantruntime="yes">
228 <includesfile name="ant.patterns"/>
229 </javac>
230 <copy todir="${bootstrap.classes.build.dir}" includeEmptyDirs="false">
231 <fileset dir="${src.dir}">
232 <includesfile name="ant.patterns"/>
233 <exclude name="**/*.java"/>
234 </fileset>
235 </copy>
236 </target>
237
238 <!-- Build the Ant tasks with the minimal Ant runtime -->
239 <target name="compile-ant" depends="compile-core,resolve">
240 <javac srcdir="${src.dir}"
241 destdir="${ant.classes.build.dir}"
242 sourcepath=""
243 classpathref="build.ant.classpath"
244 source="${ivy.minimum.javaversion}"
245 target="${ivy.minimum.javaversion}"
246 debug="${debug.mode}"
247 includeantruntime="no">
248 <includesfile name="ant.patterns"/>
249 </javac>
250 <copy todir="${ant.classes.build.dir}" includeEmptyDirs="false">
251 <fileset dir="${src.dir}">
252 <includesfile name="ant.patterns"/>
253 <exclude name="**/*.java"/>
254 </fileset>
255 </copy>
256
257 <!-- copy antlib for backward compatibility with fr.jayasoft.ivy package -->
258 <copy file="${ant.classes.build.dir}/org/apache/ivy/ant/antlib.xml"
259 todir="${ant.classes.build.dir}/fr/jayasoft/ivy/ant"/>
260 </target>
261
262 <target name="compile-optional" depends="compile-ant">
263 <javac srcdir="${src.dir}"
264 destdir="${optional.classes.build.dir}"
265 sourcepath=""
266 classpathref="build.optional.classpath"
267 source="${ivy.minimum.javaversion}"
268 target="${ivy.minimum.javaversion}"
269 debug="${debug.mode}"
270 includeantruntime="no">
271 <includesfile name="optional.patterns"/>
272 <includesfile name="ant.patterns"/>
273 </javac>
274 <copy todir="${core.classes.build.dir}" includeEmptyDirs="false">
275 <fileset dir="${src.dir}">
276 <includesfile name="optional.patterns"/>
277 <exclude name="**/*.java"/>
278 </fileset>
279 </copy>
280 </target>
281
282 <!-- =================================================================
283 Create the two jar files (Ivy core and Ivy core + Ant tasks)
284 ================================================================= -->
285 <target name="jar" depends="compile-optional,default-version" description="Create Jar files">
286 <!-- identify compiled ivy version -->
287 <echo message="version=${build.version}${line.separator}" file="${core.classes.build.dir}/module.properties" append="true"/>
288 <echo message="date=${pubdate}${line.separator}" file="${core.classes.build.dir}/module.properties" append="true"/>
289
290 <mkdir dir="${artifacts.build.dir}/jars/"/>
291
292 <!--
293 there is a default Bundle-Version attribute in the source MANIFEST, used to ease
294 development in eclipse.
295 We remove this line to make sure we get the Bundle-Version as set in the jar task
296 -->
297 <copy file="${basedir}/META-INF/MANIFEST.MF" tofile="${artifacts.build.dir}/MANIFEST.MF">
298 <filterchain>
299 <replaceregex pattern="Bundle-Version:.*" replace="Bundle-Version: ${bundle.version}" byline="true"/>
300 </filterchain>
301 </copy>
302
303 <copy todir="${all.classes.build.dir}">
304 <fileset dir="${core.classes.build.dir}"/>
305 <fileset dir="${ant.classes.build.dir}"/>
306 <fileset dir="${optional.classes.build.dir}"/>
307 </copy>
308
309 <jar destfile="${artifacts.build.dir}/jars/${final.name}"
310 manifest="${artifacts.build.dir}/MANIFEST.MF">
311 <metainf dir="${basedir}" includes="LICENSE,NOTICE"/>
312 <manifest>
313 <attribute name="Specification-Title" value="Apache Ivy with Ant tasks"/>
314 <attribute name="Specification-Version" value="${build.version}"/>
315 <attribute name="Specification-Vendor" value="Apache Software Foundation"/>
316 <attribute name="Implementation-Title" value="org.apache.ivy"/>
317 <attribute name="Implementation-Version" value="${build.version}"/>
318 <attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
319 <attribute name="Implementation-Vendor-Id" value="org.apache"/>
320 <attribute name="Extension-name" value="org.apache.ivy"/>
321 <attribute name="Build-Version" value="${build.version}"/>
322 </manifest>
323 <fileset dir="${all.classes.build.dir}"/>
324 </jar>
325 <!-- copy main jar to ease its use as an OSGi bundle -->
326 <copy file="${artifacts.build.dir}/jars/${final.name}"
327 tofile="${artifacts.build.dir}/org.apache.ivy_${bundle.version}.jar"/>
328
329 <!-- clean generated module properties file -->
330 <delete file="${core.classes.build.dir}/module.properties"/>
331 </target>
332
333 <!-- =================================================================
334 PUBLISH LOCAL
335 ================================================================= -->
336 <target name="publish-local" depends="jar,sources" description="publishes Ivy to Ivy local repository">
337 <ivy:publish resolver="local" pubrevision="${build.version}"
338 artifactsPattern="${artifacts.build.dir}/[type]s/[artifact].[ext]"
339 forcedeliver="true"/>
340 </target>
341
342 <!-- =================================================================
343 TESTS
344 ================================================================= -->
345 <target name="build-test" depends="jar">
346 <javac srcdir="${test.dir}"
347 destdir="${test.build.dir}"
348 classpathref="run.classpath"
349 source="${ivy.minimum.javaversion}"
350 target="${ivy.minimum.javaversion}"
351 debug="${debug.mode}"
352 encoding="UTF-8"
353 includeantruntime="no"/>
354 <copy todir="${test.build.dir}">
355 <fileset dir="${test.dir}">
356 <exclude name="**/*.java"/>
357 </fileset>
358 </copy>
359 </target>
360
361 <target name="build-custom-resolver-jar" depends="jar">
362 <mkdir dir="${build.dir}/custom-classpath"/>
363 <javac srcdir="${basedir}/test/custom-classpath"
364 destdir="${build.dir}/custom-classpath"
365 classpathref="run.classpath"
366 source="${ivy.minimum.javaversion}"
367 target="${ivy.minimum.javaversion}"
368 debug="${debug.mode}"
369 includeantruntime="no"/>
370 <jar destfile="${test.dir}/org/apache/ivy/core/settings/custom-resolver.jar"
371 basedir="${build.dir}/custom-classpath"/>
372 </target>
373
374 <target name="init-tests-offline" if="offline">
375 <fileset id="test.fileset" dir="${test.dir}">
376 <include name="**/${test.class.pattern}.java"/>
377 <exclude name="**/Abstract*Test.java"/>
378 <not><contains text="remote.test"/></not>
379 </fileset>
380 </target>
381
382 <target name="init-tests-online" unless="offline">
383 <fileset id="test.fileset" dir="${test.dir}">
384 <include name="**/${test.class.pattern}.java"/>
385 <exclude name="**/Abstract*Test.java"/>
386 </fileset>
387 </target>
388
389 <target name="init-tests" depends="init-tests-offline,init-tests-online"/>
390
391 <target name="prepare-osgi-tests" depends="resolve" unless="skip.test">
392 <ant dir="${basedir}/test/test-repo" target="generate-bundles"/>
393 </target>
394
395 <target name="prepare-test-jar-repositories" unless="skip.test">
396 <mkdir dir="${basedir}/test/jar-repos"/>
397 <jar destfile="${basedir}/test/jar-repos/jarrepo1.jar" >
398 <fileset dir="${basedir}/test/repositories/1"/>
399 </jar>
400 <jar destfile="${basedir}/test/jar-repos/jarrepo1_subdir.jar">
401 <fileset dir="${basedir}/test/repositories" includes="1/**/*"/>
402 </jar>
403 </target>
404
405 <target name="init-jacoco" depends="jar" unless="skip.test">
406 <ivy:cachepath organisation="org.jacoco" module="org.jacoco.ant" revision="0.8.1"
407 inline="true" conf="default" pathid="jacoco.classpath" log="download-only"/>
408 <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"
409 classpathref="jacoco.classpath"/>
410 </target>
411
412 <target name="test-internal" depends="build-test,init-tests,prepare-osgi-tests,prepare-test-jar-repositories,init-jacoco" unless="skip.test">
413 <mkdir dir="${test.xml.dir}"/>
414
415 <!-- multiple runs into the same logfile let the later report generation fail -->
416 <delete file="${jacoco.log}"/>
417 <jacoco:coverage xmlns:jacoco="antlib:org.jacoco.ant" destfile="${jacoco.log}"
418 exclclassloader="sun.reflect.DelegatingClassLoader:javassist.Loader">
419 <junit
420 haltonfailure="off"
421 haltonerror="off"
422 errorproperty="test.failed"
423 failureproperty="test.failed"
424 showoutput="no"
425 printsummary="yes"
426 includeantruntime="no"
427 dir="${basedir}"
428 tempdir="${build.dir}"
429 fork="true">
430 <classpath>
431 <path refid="test.classpath"/>
432 </classpath>
433
434 <!-- pass the proxy properties to the forked junit process to use correct proxy -->
435 <syspropertyset>
436 <propertyref prefix="http"/>
437 </syspropertyset>
438
439 <!-- Added this to test IVY-65 -->
440 <jvmarg value="-Duser.region=TR"/>
441 <jvmarg value="-Duser.language=tr"/>
442
443 <formatter type="xml"/>
444 <batchtest todir="${test.xml.dir}">
445 <fileset refid="test.fileset"/>
446 </batchtest>
447 </junit>
448 </jacoco:coverage>
449 </target>
450
451 <target name="test" depends="test-internal" description="Run the test">
452 <fail if="test.failed"
453 message="At least one test has failed. See logs (in ${test.xml.dir}) for details (use the target test-report to run the test with a report)"/>
454 </target>
455
456 <!-- =================================================================
457 REPORTS AND DOCUMENTATION
458 ================================================================= -->
459 <target name="test-report" depends="test-internal" unless="skip.test"
460 description="run tests with instrumentation and generate coverage report">
461 <junitreport todir="${test.xml.dir}">
462 <fileset dir="${test.xml.dir}">
463 <include name="TEST-*.xml"/>
464 </fileset>
465 <report format="frames" todir="${test.report.dir}"/>
466 </junitreport>
467
468 <mkdir dir="${coverage.report.dir}"/>
469 <jacoco:report xmlns:jacoco="antlib:org.jacoco.ant">
470 <executiondata>
471 <file file="${jacoco.log}"/>
472 </executiondata>
473
474 <structure name="Ivy">
475 <classfiles>
476 <fileset dir="${classes.build.dir}"/>
477 </classfiles>
478 <sourcefiles encoding="UTF-8">
479 <fileset dir="${src.dir}"/>
480 </sourcefiles>
481 </structure>
482
483 <html destdir="${coverage.report.dir}"/>
484 </jacoco:report>
485
486 <fail if="test.failed"
487 message="At least one test has failed. See logs (in ${test.xml.dir}) or report (in ${test.report.dir})"/>
488 </target>
489
490 <target name="coverage-report" depends="test-report"/>
491
492 <target name="ivy-report" depends="resolve">
493 <mkdir dir="${ivy.report.dir}"/>
494 <ivy:report todir="${ivy.report.dir}"/>
495 </target>
496
497 <target name="javadoc" depends="init" unless="skip.javadoc">
498 <tstamp>
499 <format pattern="2007-yyyy" property="years"/>
500 </tstamp>
501 <property name="copyright" value="Copyright &amp;copy;${years} The Apache Software Foundation, Licensed under &lt;a href=&quot;http://www.apache.org/licenses/LICENSE-2.0.txt&quot;&gt;Apache License, Version 2.0&lt;/a&gt;."/>
502 <property name="title" value="Apache Ivy&amp;trade; dependency manager ${target.ivy.version} API"/>
503 <javadoc destdir="${javadoc.build.dir}"
504 useexternalfile="true"
505 windowtitle="Apache Ivy&amp;trade;"
506 doctitle="${title}"
507 bottom="${copyright}"
508 classpathref="lib.classpath">
509 <fileset dir="${src.dir}" includes="**/*.java"/>
510 <arg value="-tag"/>
511 <arg value="pre:a:Precondition:"/>
512 </javadoc>
513 </target>
514
515 <target name="javadoc-test" depends="init" unless="skip.javadoc">
516 <tstamp>
517 <format pattern="2007-yyyy" property="years"/>
518 </tstamp>
519 <property name="copyright" value="Copyright &amp;copy;${years} The Apache Software Foundation, Licensed under &lt;a href=&quot;http://www.apache.org/licenses/LICENSE-2.0.txt&quot;&gt;Apache License, Version 2.0&lt;/a&gt;."/>
520 <property name="title" value="Apache Ivy&amp;trade; dependency manager ${target.ivy.version} API"/>
521 <javadoc destdir="${test.javadoc.build.dir}"
522 useexternalfile="true"
523 windowtitle="Apache Ivy&amp;trade;"
524 doctitle="${title}"
525 bottom="${copyright}"
526 classpathref="javadoc.test.classpath">
527 <fileset dir="${test.dir}" includes="**/*.java"/>
528 </javadoc>
529 </target>
530
531 <target name="sources" depends="default-version" description="Create source archive files">
532 <mkdir dir="${artifacts.build.dir}/sources/"/>
533 <jar destfile="${artifacts.build.dir}/sources/${final.name}">
534 <metainf dir="${basedir}" includes="LICENSE,NOTICE"/>
535 <manifest>
536 <attribute name="Specification-Title" value="Apache Ivy Sources"/>
537 <attribute name="Specification-Version" value="${build.version}"/>
538 <attribute name="Specification-Vendor" value="Apache Software Foundation"/>
539 </manifest>
540 <fileset dir="${src.dir}"/>
541 </jar>
542 </target>
543
544 <target name="fixcrlf">
545 <property name="eol.native.includes"
546 value="**/*.html,**/*.json,**/*.java,**/*.xml,**/*.txt,**/*.MF,**/*.properties,**/*.patterns,**/*.pom,**/*.xsl,**/*.css"/>
547 <property name="eol.native.excludes"
548 value="build/**,bin/**,lib/**"/>
549
550 <fileset id="eol.native.fileset"
551 dir="${basedir}"
552 includes="${eol.native.includes}"
553 excludes="${eol.native.excludes}"/>
554
555 <fixcrlf srcdir="${basedir}"
556 includes="${eol.native.includes}"
557 excludes="${eol.native.excludes}"/>
558 </target>
559
560 <target name="init-checkstyle" depends="jar">
561 <ivy:cachepath organisation="com.puppycrawl.tools" module="checkstyle" revision="7.8.2"
562 inline="true" conf="default" pathid="checkstyle.classpath" log="download-only"/>
563 <taskdef uri="antlib:com.puppycrawl.tools.checkstyle.ant"
564 resource="com/puppycrawl/tools/checkstyle/ant/antlib.xml" classpathref="checkstyle.classpath"/>
565 </target>
566
567 <!-- Checks Ivy codebase according to ${checkstyle.src.dir}/checkstyle-config -->
568 <target name="checkstyle-internal" depends="init-checkstyle">
569 <mkdir dir="${checkstyle.report.dir}"/>
570 <cs:checkstyle xmlns:cs="antlib:com.puppycrawl.tools.checkstyle.ant"
571 config="${checkstyle.src.dir}/checkstyle-config"
572 failOnViolation="false" failureProperty="checkstyle.failed">
573 <classpath>
574 <path refid="run.classpath"/>
575 </classpath>
576 <formatter type="xml" toFile="${checkstyle.report.dir}/checkstyle.xml"/>
577 <fileset dir="${src.dir}">
578 <include name="**/*.java"/>
579 </fileset>
580 <fileset dir="${example.dir}">
581 <include name="**/*.java"/>
582 </fileset>
583 </cs:checkstyle>
584 </target>
585
586 <target name="checkstyle" depends="checkstyle-internal"
587 description="checks Ivy codebase according to ${checkstyle.src.dir}/checkstyle-config">
588 <fail if="checkstyle.failed"
589 message="Checkstyle has errors. See report in ${checkstyle.report.dir}"/>
590 </target>
591
592 <target name="checkstyle-report" depends="checkstyle-internal">
593 <property name="checkstyle.basedir" location="${src.dir}"/>
594 <xslt in="${checkstyle.report.dir}/checkstyle.xml"
595 style="${checkstyle.src.dir}/checkstyle-frames.xsl"
596 out="${checkstyle.report.dir}/output.txt">
597 <param name="basedir" expression="${checkstyle.basedir}"/>
598 <param name="output.dir" expression="${checkstyle.report.dir}"/>
599 </xslt>
600 </target>
601
602 <target name="init-findbugs" unless="findbugs.home">
603 <!-- Findbugs: Getting Findbugs requires unlimited strength crypto policy -->
604 <property name="findbugs.version"
605 value="3.0.1"
606 description="Version of Findbugs to use"/>
607 <property name="findbugs.download.name"
608 value="findbugs-${findbugs.version}"
609 description="Name of the download file without suffix. Also the internal root directory of the ZIP."/>
610 <property name="findbugs.download.file"
611 value="${findbugs.download.name}.zip"
612 description="The filename of the ZIP."/>
613 <property name="findbugs.download.url"
614 value="http://downloads.sourceforge.net/project/findbugs/findbugs/${findbugs.version}/findbugs-${findbugs.version}.zip"
615 description="The download adress at a mirror of Sourceforge."/>
616 <property name="findbugs.download.to"
617 value="${build.dir}/.downloads"
618 description="Where to store the download and 'install' Findbugs."/>
619 <available
620 property="findbugs.home"
621 value="${findbugs.download.to}/${findbugs.download.name}"
622 file="${findbugs.download.to}/${findbugs.download.name}/lib/findbugs.jar"
623 description="Check if Findbugs is already installed."/>
624
625 <!-- Findbugs: Running Findbugs -->
626 <property name="findbugs.reportdir"
627 location="${reports.dir}/findbugs"
628 description="Where to store Findbugs results"/>
629 <property name="findbugs.raw"
630 value="raw.xml"
631 description="Findbugs output xml file"/>
632 <property name="findbugs.xsl"
633 value="fancy.xsl"
634 description="Which XSL to use for generating output: default, fancy, plain, summary"/>
635 <property name="findbugs.jvmargs"
636 value="-Xms128m -Xmx512m"
637 description="JVMArgs for invoking Findbugs"/>
638
639 <mkdir dir="${findbugs.download.to}"/>
640 <get src="${findbugs.download.url}" dest="${findbugs.download.to}/${findbugs.download.file}"
641 usetimestamp="true" skipexisting="true"/>
642 <unzip src="${findbugs.download.to}/${findbugs.download.file}" dest="${findbugs.download.to}"/>
643 <property name="findbugs.home" location="${findbugs.download.to}/${findbugs.download.name}"/>
644 </target>
645
646 <target name="findbugs" description="checks Ivy codebase with Findbugs" depends="init-findbugs,compile-core" xmlns:fb="http://findbugs.sourceforge.net/">
647 <!-- Load the Findbugs AntTasks -->
648 <path id="findbugs.real.classpath">
649 <fileset dir="${findbugs.home}/lib" includes="*.jar"/>
650 </path>
651 <taskdef uri="http://findbugs.sourceforge.net/" resource="edu/umd/cs/findbugs/anttask/tasks.properties" classpathref="findbugs.real.classpath"/>
652
653 <!-- Start Findbugs -->
654 <mkdir dir="${findbugs.reportdir}"/>
655 <fb:findbugs home="${findbugs.home}"
656 classpathref="findbugs.real.classpath"
657 output="xml:withMessages"
658 outputFile="${findbugs.reportdir}/${findbugs.raw}"
659 jvmargs="${findbugs.jvmargs}"
660 projectName="${ant.project.name} ${target.ivy.version}">
661 <class location="${core.classes.build.dir}"/>
662 <sourcePath path="${src.dir}"/>
663 </fb:findbugs>
664
665 <!-- Generate (human) readable output -->
666 <xslt basedir="${findbugs.reportdir}" includes="${findbugs.raw}" destdir="${findbugs.reportdir}">
667 <style>
668 <javaresource name="${findbugs.xsl}" classpathref="findbugs.real.classpath"/>
669 </style>
670 </xslt>
671 </target>
672
673 <target name="docs" depends="test-report,checkstyle-report,findbugs,ivy-report,javadoc"/>
674
675 <!-- =================================================================
676 IDE SPECIFIC
677 ================================================================= -->
678 <available file="${basedir}/.classpath" property="eclipse.classpath.exists"/>
679 <target name="check-eclipse-classpath-overwrite" if="eclipse.classpath.exists">
680 <input message=".classpath file already exists.${line.separator}Are you sure you want to overwrite it and loose your original file?"
681 validargs="Y,N,y,n" addproperty="eclipse.classpath.confirm"/>
682 <condition property="eclipse.classpath.abort">
683 <equals arg1="${eclipse.classpath.confirm}" arg2="N" casesensitive="false"/>
684 </condition>
685 </target>
686
687 <target name="eclipse-default" depends="resolve,check-eclipse-classpath-overwrite"
688 unless="eclipse.classpath.abort"
689 description="creates a default .classpath for Eclipse using jars resolved by this Ant build">
690 <copy file="${basedir}/.classpath.default" tofile="${basedir}/.classpath" overwrite="true"/>
691 </target>
692
693 <target name="eclipse-ivyde" depends="check-eclipse-classpath-overwrite"
694 unless="eclipse.classpath.abort"
695 description="creates a .classpath for Eclipse using Apache IvyDE plugin">
696 <copy file="${basedir}/.classpath.ivyde" tofile="${basedir}/.classpath" overwrite="true"/>
697 </target>
698 </project>