Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-18-2005, 08:29 PM   #1
Registered: May 2004
Distribution: SuSe 10.0
Posts: 154

Rep: Reputation: 30
Question about Apache Ant

I am about to start developing applications using Ant. I have decided to try programming using JUnit (Test-Driven Development). I created the build.xml file that I found on Apache Ant's Documentation page. The only problem that I have is that I do not have a jar package named ant-testutil.jar. I did a goggle search and found a page that told me that in order to create the jar file i needed the source files. I have searched my installation cd's and I can not find the developmental package for Ant. I downloaded the src file from Apache's website. I haven't installed it yet thinking that there will be a conflict with the already installed Ant.

So my question is has anyone used Ant with JUnit and used ant-testutil.jar? Do I need ant-testutil or is there a different jar file I could use?

Running SuSe 9.2 pro
Ant 1.6.2
JUnit 3.8.1-3 ( According to YaST; can't seem to run from command prompt but installed on my system. I think it was installed with eclipse)

Old 02-19-2005, 06:57 AM   #2
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Can you show us the sections of your build file?

Here is an example of a build file I created that does junit testing.

<project name="antlab-resources" default="all" basedir=".">
        Build.xml file for Antlab-resources Project
    <property name="src" location="."/>

    <path id="classpath">
        <pathelement path="${classpath}"/>
        <pathelement path="."/>
        <pathelement location="/net/hu15/cs2335/java/junit/junit.jar"/>

    <target name="compile" description="compile java source" >
        <javac srcdir="." destdir=".">
            <classpath refid="classpath"/>

    <target name="test" depends="compile" description="run tests" >
        <junit printsummary="yes" haltonfailure="yes" haltonerror="yes">
                <pathelement location="${build.tests}"/>
                <pathelement path="${src}"/>

            <formatter type="plain"/>

          <batchtest fork="yes" todir="${src}">
              <fileset dir="${src}">
                  <include name="**/*Test*.java"/>

    <target name="all" depends="compile,test" description="build,
    jar, javadoc, and run" />

Old 02-19-2005, 01:17 PM   #3
Registered: May 2004
Distribution: SuSe 10.0
Posts: 154

Original Poster
Rep: Reputation: 30
Here is my builld.xml file
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Blackjack" basedir="." default="test">

	<property name="src.dir" value="src" />
	<property name="classes.dir" value="classes" />
	<property name="report.dir" value="report"/>
	<property name="ant.test.lib" value="ant-testutil.jar"/>
	<property name="junit.out.dir.xml" value="${report.dir}/junit/xml"/>
	<property name="junit.out.dir.html" value="${report.dir}/junit/html"/>

	<path id="">
		<path path="${java.class.path"/>
		<path location="${}.jar"/>
	<path id="classpath.test">
		<path refid=""/>
		<path location="${ant.test.lib}"/>

	<target name="clean" description="Delete all generated files">
		<delete  failonerror="false" includeEmptyDirs="true"/>
			<fileset dir="." includes="${}".jar />
			<fileset dir="${classes.dir}" />
			<fileset dir="${report.dir}" />

	<target name="compile" description="Compiling all source files">
		<mkdir dir="${classes.dir}"/>
		<javac srcdir="${src.dir}" destdir="${classes.dir" classpath="${ant.test.lib}" />

	<target name="jar" desription="Jar all files" dependson="compile">
		<jar destfile="${}.jar" basedir="${classes.dir}"/>

	<target name="use" description="Use the project" depends="jar">
		<taskdef name="blackjack" classname="Blackjack" classpath="${}.jar"/>
	<target name="junit" description="Running Unit tests" depends="jar">
		<delete dir="${junit.out.dir.xml}" />
		<mkdir dir="${junit.out.dir.xml}" />
		<junit printsummary="yes" haltonfailure="no">
			<classpath refid="classpath.test"/>
			<formatter type="xml"/>
			<batchtest fork="yes" todir="${junit.out.dir.xml}">
				<fileset dir="${src.dir}" includes="**/*"/>
	<target name="junitreport" desription="Creates a report for the rest result">
		<mkdir dir="${junit.out.dir.html}" />
		<junitreport todiir="${junit.out.dir.html}">
			<fileset dir="${junit.out.dir.xml}">
				<include name="*.xml"/>
			<report format="frames" todir="${junit.out.dir.html}" />
	<target name="test"
			depends="junit, junitreport"
			descriiption="Run unit tests and creates a report"


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems about ant simprince Programming 1 11-08-2005 09:53 AM
Apache Ant and Red Hat Enterprise WS 4 AsymptoticOrbit Red Hat 4 08-22-2005 08:02 PM
problem with ant os2 Programming 1 05-20-2005 12:13 AM
creating apache-ant package merchtemeagle Slackware 3 05-11-2005 01:12 PM
Jakarta Ant?? powadha Linux - Software 3 01-19-2004 12:46 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:16 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration