tags:

views:

202

answers:

3

I am running an Ant script that is part of a tutorial at http://maestric.com/doc/java/spring/setup

The error is:

BUILD FAILED Target "buildtests" does not exist in the project "null".

I am running Ant through eclipse.

The Ant script is:

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="build">

  <property file="build.properties"/>
  <property name="src.dir" value="src"/>
  <property name="build.dir" value="classes"/>

  <path id="build.classpath">
      <fileset dir="lib">
          <include name="*.jar"/>
      </fileset>
      <fileset dir="${appserver.lib}"> <!-- servlet API classes: -->
          <include name="servlet*.jar"/>
      </fileset>
      <pathelement path="${build.dir}"/>
  </path>  

  <target name="build">
      <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="build.classpath"/>
      </javac>
  </target>

  <target name="clean" description="Clean output directories">
      <delete>
          <fileset dir="${build.dir}">
              <include name="**/*.class"/>
          </fileset>
          </delete>
  </target>

</project>

I often have such problems with Ant, when it seems an error is caused by something that has never been declared in my script.

+1  A: 

This sounds bizarre. Did you get Ant from Apache? Are there any build.xml files nearby with "buildtests" in them? Is this on a unix-based OS? If so, find the Ant script by doing a "which" and then examine its contents to see if it is trying to invoke some other build file.

SingleShot
I am using Ant that is built into eclipse
Ankur
A: 

I copied the script into an empty directory and I was able to invoke the script successfully after having created the src folder.

This means that the problem is not in this script itself.

You can use ant -p to list all the targets available and check that they match with the script you intend to execute.

Vladimir
A: 

If you're running Ant through Eclipse, have you checked the build properties setup for your project's Ant Builder?

Right click on your project in the package explorer and go to "Properties". Then select "Builders" from the list on the left. Do you have an Ant Builder there? If so, highlight it and hit "Edit...", then check the "Targets" tab to make sure it's not invoking any targets you don't expect.

Most of the weirdness I run into when building via Ant in Eclipse can be traced back to some mis-set or unset properties under the Ant Builder I'm using.

==============================

Alternately, if you haven't configured your Ant XML to be used via an Ant builder and you're just invoking the Ant file directly, right click on your Ant file and check the "Run Configuration..." setup under "Run As" to make sure nothing is out of place. It might be re-using settings from a previous "build.xml" file you had.

Brent Nash