Java Reference
In-Depth Information
<src path="${src.test.dir}"/>
<classpath>
<pathelement location="${target.classes.java.dir}"/>
<pathelement location=”${junit.jar}”/>
</classpath>
</javac>
</target>
[...]
E
<target name="test" depends="compile">
<junit printsummary="yes" haltonerror="yes" haltonfailure="yes"
fork="yes">
<formatter type="plain" usefile="false"/>
<test name="junitbook.example.TestDefaultController"/>
<classpath>
<pathelement location="${target.classes.java.dir}"/>
<pathelement location="${target.classes.test.dir}"/>
<pathelement location=”${junit.jar}”/>
</classpath>
</junit>
</target>
[...]
We start by declaring the ivy namespace B and calling the Ivy Ant task to retrieve the
dependencies listed in the ivy.xml file from the public repository C . After we retrieve
the junit.jar with Ivy, the archive is in the lib folder of our project. Next, we define the
junit.jar property to point to the JAR file we just downloaded D . We include the JAR
in the classpath of the javac task E and in the classpath of the junit task F . We no
longer need the junit.jar in the ${ ANT_HOME }/lib folder, so we can delete it.
The file ivy.xml defines the project dependencies as shown in listing 9.5.
F
Listing 9.5
The ivy.xml file with the listed dependencies
B
<ivy-module version="2.0">
<info organisation="junitbook" module="example-ivy"/>
<dependencies>
<dependency org="junit" name="junit" rev="4.6"/>
</dependencies>
</ivy-module>
First, the root tag ivy-module B defines the version of Ivy we want to use (in this case
2.0). Then, the info tag C defines the organization and the module name for which
we're defining dependencies. Finally, the dependencies nested element D is where
we specify our dependencies. Our module has only one dependency listed: JU nit.
Invoking Ant again gives us the same result (figure 9.2) as when junit.jar was in
the ${ ANT_HOME }/lib folder, but this time we see Ivy invoked and resolve the proj-
ect dependencies.
In the next section, we try out another kind of report.
C
D
 
 
 
Search WWH ::




Custom Search