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

  • Home
  • SEARCH
  • 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 7512167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:47:00+00:00 2026-05-29T23:47:00+00:00

I was building an Ant build file that worked properly in my eclipse project

  • 0

I was building an Ant build file that worked properly in my eclipse project but not on our Jenkins autobuild set-up. I installed ant on my computer and ran the build from the console. It worked, but I realized it didn’t use the junit-4.10.jar in my project lib like I wished but the junit.jar in the ant lib. After renaming the junit.jar files in my ant lib, the ant build didn’t work.

So basically the problem in our Jenkins autobuild setup is that there are no junit.jar in its own ant lib directory. Can I specify the junit task to use the jar in my project lib instead of the one in the ant lib?

EDIT : I have modified my build.xml file and now it looks like this, still doesnt work. My junit-4.10.jar is in the /war/WEB-INF/lib/test directory :

<project name="vlp" default="junit" basedir=".">
    <tstamp />
    <!-- ################# PROPERTIES ################ -->
    <!-- directory properties -->
    <!-- source -->
    <property name="vlp.src" location="src" />
    <property name="vlp.test" location="test" />
    <!-- build -->
    <property name="src.build" location="bin/src" />
    <property name="test.build" location="bin/test" />
    <!-- libraries -->
    <property name="vlp.lib.dir" location="war/WEB-INF/lib" />
    <property name="vlp.testlib.dir" location="war/WEB-INF/lib/test" />
    <!-- compile classpath -->
    <path id="compile.path">
        <fileset dir="${vlp.lib.dir}" includes="*.jar" />
    </path>
    <!-- test classpath -->
    <path id="test.path">
        <fileset dir="${vlp.testlib.dir}" includes="*.jar" />
        <path refid="compile.path" />
    </path>
    <!-- ############### CLEANING ################## -->
    <!-- Cleaning old compile files -->
    <target name="clean" description="Clean all the old build files.">
        <delete dir="${src.build}" />
        <delete dir="${dist}" />
    </target>
    <!-- ############## COMPILATION ############### -->
    <!-- Compile source -->
    <target name="src.compile" depends="clean" description="Compile the source code when everything has been cleaned.">
        <mkdir dir="${src.build}" />
        <javac encoding="utf-8" destdir="${src.build}" nowarn="true">
            <src path="${vlp.src}" />
            <classpath refid="compile.path" />
        </javac>
    </target>
    <!-- Compile test -->
    <target name="test.compile" depends="clean" description="Compile the source code when everything has been cleaned.">
        <mkdir dir="${test.build}" />
        <javac encoding="utf-8" destdir="${test.build}" nowarn="true">
            <src path="${vlp.test}" />
            <classpath>
                <pathelement location="${src.build}" />
                <path refid="test.path" />
            </classpath>
        </javac>
    </target>
    <!-- ########### RUNS JUNIT TEST ############ -->
    <target name="junit" depends="src.compile,test.compile" description="Runs all the unit test in the application. Does not halt build if test are failed.">
        <junit printsummary="on" haltonfailure="false" showoutput="true">
            <formatter type="brief" usefile="false" />
            <classpath>
                <pathelement location="${test.build}" />
                <path refid="test.path" />
            </classpath>
            <batchtest>
                <fileset dir="${vlp.test}">
                    <include name="**/Test*.java" />
                    <exclude name="**/AllTests.java" />
                </fileset>
            </batchtest>
        </junit>
    </target>
</project>

EDIT : Simlar question can be found here with a different answer that works well. Note that it is much easier to install ant-junit on the machine than to try to add it to your libs and everything.

  • 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-29T23:47:02+00:00Added an answer on May 29, 2026 at 11:47 pm

    See the answer to this question:

    H2 database org.h2.Driver ClassNotFoundException

    I normally specify the junit jar to be on a test classpath and then use it when calling the junit ANT task


    Update

    The following build file is an example of a starting template I used for my builds.

    Sets up an infrastructure that uses ivy to manage classpaths. Dependencies are downloaded from the Maven Central repository (by default). Makes build much more portable and repeatable.

    build.xml

    <project name="ivy demo" default="build" xmlns:ivy="antlib:org.apache.ivy.ant">
    
        <!--
        ==========
        Properties
        ==========
        -->
        <property name="build.dir"  location="build"/>
        <property name="class.dir"  location="${build.dir}/classes"/>
        <property name="report.dir" location="${build.dir}/reports"/>
    
        <!-- 
        =======
        Targets
        =======
        -->
        <target name="install-ivy" description="Used to install the ivy task jar">
            <mkdir dir="${user.home}/.ant/lib"/>
            <get dest="${user.home}/.ant/lib/ivy.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar"/>
        </target>
    
        <target name="init" description="Download dependencies, setup project classpaths and create build directories">
            <ivy:resolve/>
    
            <ivy:cachepath pathid="compile.path" conf="compile"/>
            <ivy:cachepath pathid="runtime.path" conf="runtime"/>
            <ivy:cachepath pathid="test.path"    conf="test"/>
    
            <ivy:report todir="${report.dir}" graph="false"/>
    
            <mkdir dir="${class.dir}"/>
        </target>
    
        <target name="build" depends="init" description="Build the project">
            <echo message="Build logic goes here"/>
        </target>
    
        <target name="clean" description="Remove build directories">
            <delete dir="${build.dir}"/>
        </target>
    
        <target name="clean-all" depends="clean" description="Purge ivy cache">
            <ivy:cleancache />
        </target>
    
    </project>
    

    ivy.xml

    This file is used to specify the project’s dependencies. Ivy configurations are used to manage the classpath groupings.

    <ivy-module version="2.0">
        <info organisation="org.demo" module="demo"/>
        <configurations>
            <conf name="compile"/>
            <conf name="runtime" extends="compile"/>
            <conf name="test"    extends="runtime"/>
        </configurations>
        <!--
        Dependencies can be found using Maven Central's search site:
    
            http://search.maven.org/
        -->
        <dependencies>
            <!-- Compile dependencies -->
            <dependency org="org.slf4j" name="slf4j-api" rev="1.6.4" conf="compile->default"/>
    
            <!-- Runtime dependencies -->
            <dependency org="log4j" name="log4j" rev="1.2.16" conf="runtime->default"/>
    
            <!-- Test dependencies -->
            <dependency org="junit" name="junit" rev="4.10" conf="test->default"/>
        </dependencies>
    </ivy-module>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a project using Ant and Ivy. The build.xml file depends on
I have following ant file to build. But unfortunately <project default=build.deploy.start basedir=.> <property name=target.dir
I'm building a project with ant and during the build I'd like to bundle
When I build flex project using ant, the resultant .SWF file size is 329
I'm currently using ANT for building my Java project on a Windows XP machine.
I am new to ant, but am trying to create an ant script that
Please help, I'm going slightly mad!! I'm using Eclipse-generated antfiles to build a project
Whenever I set android.library.reference.1=G\:Projects\Android\library\core\ in ant.properties , I get the following error while building:
Sorry, I'm not terribly experienced with Ant. I like the eclipse Export ant buildfile
I am using Ant > 1.8 + Proguard 4.6 to build my Android project

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.