Skip to content

Commit bb8ee6a

Browse files
ivoshVladimir Kotal
authored andcommitted
Download junit and hamcrest jar files automatically by ant.
hamcrest is a dependency for junit, so check that first. Fix also README.md instructions.
1 parent b265abf commit bb8ee6a

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ lib/jrcs.jar
3232
lib/lucene-*
3333
lib/servlet-api-*
3434
lib/junit-*
35+
lib/hamcrest-core-*
3536
derby.log
3637
opengrok*.log
3738
nbproject/genfiles.properties

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -684,16 +684,16 @@ being executed on) under the `dist/` directory.
684684

685685
### 8.1 Unit testing
686686

687-
**Note**: For full coverage report your system has to provide proper junit test
688-
environment, that would mean:
687+
**Note**: For full coverage report, a proper junit test environment is required.
688+
That would mean:
689689

690-
* you have to use Ant 1.9 and above
691-
* at least `junit-4.12.jar` has to be in ant's classpath (e.g. in `./lib`)
692-
693-
* your `PATH` must contain directory with exuberant ctags binary
690+
* You have to use Ant 1.9 and above
691+
* At least `junit-4.12.jar` and its dependencies have to be in ant's
692+
classpath (e.g. in `./lib`). The test task will download them automatically.
693+
* Your `PATH` must contain directory with exuberant ctags binary
694694
* **Note**: make sure that the directory which contains exuberant ctags binary
695695
is prepended before the directory with plain ctags program.
696-
* your `PATH` variable must contain directories which contain binaries of
696+
* Your `PATH` variable must contain directories which contain binaries of
697697
appropriate SCM software which means commands hg, sccs, cvs, git, bzr, svn
698698
(svnadmin too). They must be available for the full report.
699699

build.xml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
119119

120120
<property name="junit.version" value="4.12"/>
121121
<property name="junit.jar" value="junit-${junit.version}.jar"/>
122+
<property name="hamcrest.version" value="1.3"/>
123+
<property name="hamcrest.jar" value="hamcrest-core-${hamcrest.version}.jar"/>
122124

123125
<property name="mvn.repository" value="http://repo1.maven.org/maven2"/>
124126

@@ -565,7 +567,7 @@ Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
565567
</condition>
566568
</target>
567569

568-
<target name="download-junit" depends="-check-junit" if="junit_not_downloaded">
570+
<target name="download-junit" depends="-check-junit,download-hamcrest" if="junit_not_downloaded">
569571
<delete>
570572
<fileset dir="lib">
571573
<include name="junit-*.jar"/>
@@ -575,6 +577,27 @@ Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
575577
dest="lib/${junit.jar}" verbose="true" usetimestamp="true"/>
576578
</target>
577579

580+
<target name="-check-hamcrest" description="Check that hamcrest jar file is present">
581+
<available file="${hamcrest.jar}" type="file" property="hamcrest.jar.present">
582+
<filepath refid="plainlib.search.path"/>
583+
</available>
584+
<condition property="hamcrest_not_downloaded">
585+
<not>
586+
<isset property="hamcrest.jar.present"/>
587+
</not>
588+
</condition>
589+
</target>
590+
591+
<target name="download-hamcrest" depends="-check-hamcrest" if="hamcrest_not_downloaded">
592+
<delete>
593+
<fileset dir="lib">
594+
<include name="hamcrest-*.jar"/>
595+
</fileset>
596+
</delete>
597+
<get src="${mvn.repository}/org/hamcrest/hamcrest-core/${hamcrest.version}/${hamcrest.jar}"
598+
dest="lib/${hamcrest.jar}" verbose="true" usetimestamp="true"/>
599+
</target>
600+
578601
<target name="-post-jar" depends="-copy-lib-without-netbeans">
579602
<war destfile="${dist.war}" webxml="web/WEB-INF/web.xml">
580603
<fileset dir="web" excludes="META-INF/context.xml"/>
@@ -863,7 +886,7 @@ Portions Copyright (c) 2017, Chris Fraire <[email protected]>.
863886
</jacoco:report>
864887
</target>
865888

866-
<target name="-pre-compile-test" depends="-check-junit"><!-- depends="-set-jacocoagent"> -->
889+
<target name="-pre-compile-test" depends="download-junit"><!-- depends="-set-jacocoagent"> -->
867890
</target>
868891

869892
<!-- <target name="-pre-compile-test-single" depends="-set-jacocoagent"/> -->

0 commit comments

Comments
 (0)