Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 460067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:50:09+00:00 2026-05-12T22:50:09+00:00

Hey guys I’ve been trying all day to get an ant file to automatically

  • 0

Hey guys I’ve been trying all day to get an ant file to automatically build my project. The file (appended below) was on a web page I found and is pretty thorough.

My problem is that it works as long as I don’t run the “clean” target. Once the I run the “clean” target the “test” target ceases to work. I get NoClassFound errors on all test classes. Even though it worked earlier.

I’m working on a Macbook (10.5.8) using the latest version of eclipse. This error occurs running the file from eclipse and from a terminal using Ant version 1.7.1

I modified the file slightly to adapt it to my file structure which is as follows:

src/
   packageA.packageB/
                     ClassA.java
                     ...
                     ClassN.java

unittests/
          packageA.packageB/
                            AllClassTests.java
                            ClassATest.java
                            ...
                            ClassNTest.java

lib/
    junit-4.7.jar

The ant file is:

<project name="SampleJUnitTests" default="dist" basedir=".">
<description>
    DataTypes Build File
</description>
<!-- set global properties for this build -->

<property name="project_name" value="DataTypes"/>
<property name="src" location="src"/>
<property name="build" location="bin"/>
<property name="dist"  location="dist"/>
<property name="lib"  location="lib"/>
<property name="reports" location="reports"/>
<property name="tests" location="unittests"/>
<property name="tmp" location="tmp_file"/>

<!-- the names of various distributable files -->
<property name="jar_name" value="${project_name}.jar"/>
<property name="war_name" value="${project_name}.war"/>

<!-- top level targets -->

<target name="compile" depends="init" description="compile the source code " >
    <javac srcdir="${src}" destdir="${build}">
        <classpath>
            <fileset dir="lib">
                <include name="**/*.jar"/>
            </fileset>
        </classpath>
    </javac>
</target>

<target name="dist" depends="compile" description="generate the distributable files " >
    <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
    <jar jarfile="${dist}/${jar_name}" basedir="${build}"/>
</target>

<target name="clean" description="clean up" >
    <!-- Delete the ${build} and ${dist} directory trees -->
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
    <delete dir="${reports}"/>
    <delete dir="${tmp}"/>
</target>

<target name="run-tests" depends="compile" description="run your test suite" >
    <junit printsummary="yes" haltonfailure="no" showoutput="yes" tempdir="${tmp}">
        <classpath>
            <pathelement path="${build}"/>
            <fileset dir="lib">
                <include name="**/*.jar"/>
            </fileset>
        </classpath>
      <batchtest fork="yes" todir="${reports}/raw/">
        <formatter type="xml"/>
        <fileset dir="${tests}">
          <include name="**/*.java"/>
          <exclude name="**/All*Tests.java"/>
        </fileset>
      </batchtest>
    </junit>
</target>

<target name ="test" depends="run-tests">
    <junitreport todir="${reports}">
      <fileset dir="${reports}/raw/">
        <include name="TEST-*.xml"/>
      </fileset>
      <report format="frames" todir="${reports}\html\"/>
    </junitreport>
</target>

<target name ="run" depends="" description="if this project can be run, run it" >
</target>

<!-- supporting targets -->

<target name="init" description="initialize the build environment" >
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create directory structures -->
    <mkdir dir="${build}"/>
    <mkdir dir="${lib}"/>
    <mkdir dir="${dist}/lib"/>
    <mkdir dir="${reports}"/>
    <mkdir dir="${reports}/raw/"/>
    <mkdir dir="${reports}/html/"/>
    <mkdir dir="${tmp}"/>
</target>

<target name="all" depends="clean, test">
</target>

I give up and hope that someone can shine a light on my problem.
Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:50:09+00:00Added an answer on May 12, 2026 at 10:50 pm

    You haven’t got any Ant target which builds the test classes. You could do this as part of the compile target if you wanted:

    <target name="compile" depends="init" description="compile the source code " >
      <javac srcdir="${src}" destdir="${build}">
        <classpath>
          <fileset dir="lib">
            <include name="**/*.jar"/>
          </fileset>
        </classpath>
      </javac>
      <javac srcdir="${tests}" destdir="${build}">
        <classpath>
          <pathelement path="${build}"/>
          <fileset dir="lib">
            <include name="**/*.jar"/>
          </fileset>
        </classpath>
      </javac>
    </target>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys so I am trying to have a loop run to get all
Hey guys I can't seem to get the syntax here right, I'm just trying
Hey guys, I'm trying to get my head around LINQ and FP, so forgive
Hey guys im trying to get a simple button masher up, What i want
Hey guys am having a bit of problems with my jQuery, I have all
Hey guys I'm creating a quick mysql file to create a DB with some
Hey guys I managed to get a text input and select box to updated
Hey Guys I've been struggling with this for the last hour and pouring over
Hey guys I'm building my first website and I cannot figure how to get
Hey guys, I want to make a function loop over all elements that have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.