Ant says "buildtests" doesn't exist, but I don't understand why it is looking for "buildtests"

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

Mistake:

STRICTLY MALFUNCTION Target "buildtests" does not exist in project "null".

I am running Ant through eclipse.

Ant script:

<?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 issues like this with Ant where it seems like the error is caused by something that was never declared in my script.

+2


source to share


5 answers


It sounds strange. Did you get Ant from Apache? Are there build.xml files next to "buildtests" in them? Is this on a unix based OS? If so, find the Ant script by executing "which" and then view its contents to see if it is trying to call a different build file.



+1


source


I copied the script to an empty directory and I was able to successfully call the script after the folder was created src

.

This means that this script is not the problem.



You can use ant -p

to display all available targets and make sure they match the script you intend to execute.

+1


source


If you are using Ant through Eclipse, have you checked the build properties setting for your Ant Builder project?

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 Ant Builder? If so, select it and click Edit ..., then check the Targets tab to make sure it doesn't trigger any targets you don't expect.

Much of the oddity I run into when building via Ant in Eclipse can be traced back to some incorrectly set or overridden properties in the Ant Builder I am using.

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

Alternatively, if you have not configured your Ant XML to be used with the Ant constructor and you just call the Ant file directly, right click on the Ant file and check the Run Configuration ... checkbox under Run As "to make sure nothing is okay. This could be a reuse of settings from a previous "build.xml" file you had.

+1


source


I had a similar problem when I wrote an Ant script to execute a list of JUnit test cases. Part of the script:

<test name="${test.entry}" methods="${test.methods}"/>

      

where test.entry specifies the test class and test.methods specifies a "comma separated list of test case method names" [see p. junit task]

However, when I run this script with -Dtest.methods = "foo, bar" it throws the error "Target ... does not exist in the project" null "as your problem.

I solved this problem by simply removing the space between "foo, bar" in "foo, bar". The problem is gone!

So, you might want to check if this problem is caused by unnecessary spaces in your arguments.

+1


source


On Windows, if your Eclipse project name (and therefore the path / location) contains spaces, try renaming the project to use underscores.

0


source







All Articles