Buildfile: /.../build.xml
build:
buildtests:
tests:
BUILD FAILED
/.../build.xml:43: Problem: failed to create task or type junit
Cause: Could not load a dependent class org/apache/tools/ant/Task
It is not enough to have Ant's optional JARs
you need the JAR files that the optional tasks depend upon.
Ant's optional task dependencies are listed in the manual.
Action: Determine what extra JAR files are needed, and place them in one of:
-/Applications/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib
-/Users/cjwalsh/.ant/lib
-a directory added on the command line with the -lib argument
Do not panic, this is a common problem.
The commonest cause is a missing JAR.
This is not a bug; it is a configuration problem
Total time: 512 milliseconds
... and I've checked all the recommended directories, and yet I still keep getting this build failure. The specific JAR 'ant.jar', which I've looked into, has the class 'Task', and it is in the '/Applications/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib' directory. Do I need to manually add this classpath to my build.xml as well? Here is my build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="springapp" basedir="." default="build">
<property file="build.properties"></property>
<property name="src.dir" value="src"></property>
<property name="web.dir" value="war"></property>
<property name="build.dir" value="${web.dir}/WEB-INF/classes"></property>
<property name="name" value="springapp"></property>
<property name="test.dir" value="test"></property>
<path id="master-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar" />
</fileset>
<fileset dir="${appserver.lib}">
<include name="servlet*.jar"></include>
</fileset>
<pathelement path="${build.dir}"></pathelement>
</path>
<target name="build" description="Compile main source tree java files">
<mkdir dir="${build.dir}" />
<javac destdir="${build.dir}" source="1.5" target="1.5" debug="true" deprecation="false" optimize="false"
failonerror="true">
<src path="${src.dir}" />
<classpath refid="master-classpath" />
</javac>
</target>
<target name="buildtests" description="Compile test tree java files">
<mkdir dir="${build.dir}" />
<javac destdir="${build.dir}" source="1.5" target="1.5" debug="true"
deprecation="false" optimize="false" failonerror="true">
<src path="${test.dir}"></src>
<classpath refid="master-classpath"></classpath>
</javac>
</target>
<target name="tests" depends="build, buildtests" description="Run tests">
<junit printsummary="on" fork="false" haltonfailure="false" failureproperty="tests.failed"
showoutput="true">
<classpath refid="master-classpath"></classpath>
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="${build.dir}">
<include name="**/*Tests.*" />
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">
tests.failed=${tests.failed}
***********************************************************************
***********************************************************************
**** One or more tests failed! Check the output ... ***************
***********************************************************************
***********************************************************************
</fail>
</target>
<target name="deploy" depends="build" description="Deploy the application">
<copy todir="${deploy.path}/${name}" preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="**/*.*" />
</fileset>
</copy>
</target>
<target name="deploywar" depends="build" description="Deploy application as WAR file">
<war destfile="${name}.war" webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*"></include>
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war"></include>
</fileset>
</copy>
</target>
<path id="catalina-ant-classpath">
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar"></include>
</fileset>
</path>
<taskdef name="install" classname="org.apache.catalina.ant.InstallTask">
<classpath refid="catalina-ant-classpath"></classpath>
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="catalina-ant-classpath"></classpath>
</taskdef>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath" />
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="catalina-ant-classpath"></classpath>
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="catalina-ant-classpath"></classpath>
</taskdef>
<target name="install" description="Install application in Tomcat">
<install url="${tomcat.manager.url}" username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}"
war="${name}" />
</target>
<target name="reload" description="Reload applicatio in Tomcat">
<reload url="${tomcat.manager.url}" username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}" />
</target>
<target name="start" description="Start tomcat application">
<start url="${tomcat.manager.url}" username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}" />
</target>
<target name="stop" description="Stop Tomcat application">
<stop url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}"
path="/${name}" />
</target>
<target name="list" description="List Tomcat applications">
<list url="${tomcat.manager.url}"
username="${tomcat.manager.username}"
password="${tomcat.manager.password}" />
</target>
</project>