What could cause the error message 'Target “1” does not exist in the project “xxx”.' running Ant on Windows?

StackOverflow https://stackoverflow.com/questions/979272

  •  13-09-2019
  •  | 
  •  

Question

I'm using ant.bat (in Ant 1.7.1) to build the all target in a build.xml file, on Windows 2003 Server. (I've substituted "xxx" in the error message for the project name in that file.)

It builds successfully, but then ends with:

2009-06-10 17:26:03 | all:
2009-06-10 17:26:03 | 
2009-06-10 17:26:03 | BUILD FAILED
2009-06-10 17:26:03 | Target "1" does not exist in the project "xxx". 

...and returns with a non-zero error code.

I've searched build.xml unsuccessfully for anything that might lead to this error. (There is no target "1", of course, nor any dependencies that might resolve "1".)

I'm hoping someone out there might recall seeing this. I don't expect anyone to debug the XML for me, but a Google search turned up http://simile.mit.edu/mail/ReadMsg?listId=9&msgId=2735, which contains "I found an email thread on this problem and will retry.". I wish I could find that thread.

Update - here's the command-line:

D:/build/toolchain/noarch/ant-1.7.1/bin/ant.bat all  -DBRANCH_NAME="main" -DBUILD_NUMBER="66675" -DCHANGE_NUMBER="1061789" -DGOBUILD_AUTO_COMPONENTS= -DGOBUILD_OFFICIAL_BUILD=1 -DGOBUILD_VICLIB_ROOT=d:/build/ob/bora-66675/compcache//viclib/ob-65655/windows -DGOBUILD_VIMBASE_ROOT=d:/build/ob/bora-66675/compcache//vimbase/ob-64494/windows -DOBJDIR="beta" -DPRODUCT_BUILD_NUMBER="82" -DPUBLISH_DIR="d:/build/ob/bora-66675/publish" -DRELTYPE="beta" -DREMOTE_COPY_SCRIPT="D:/build/toolchain/win32/python-2.5/python.exe D:/build/gobuild/script/gobuildc.py bora-66675"'

Hopefully it's of some help.

Was it helpful?

Solution

Do you have any targets that depend on "1"? Perhaps due to a typo?

<target name="SomeTarget" depends="1">
   ....
</target>

Update: You explained (paraphrased) that the error message was a result of the (partial) command-line

-DGOBUILD_AUTO_COMPONENTS= -DGOBUILD_OFFICIAL_BUILD=1

Although there's a space between those two define statements, it's being treated like this:

-DGOBUILD_AUTO_COMPONENTS=-DGOBUILD_OFFICIAL_BUILD=1

because something is expected to follow '='. And it appears that the second '=' is being treated as a whitespace, perhaps because ANT is confused. I would not expect that. The correct way to do what you want to do is:

-DGOBUILD_AUTO_COMPONENTS="" -DGOBUILD_OFFICIAL_BUILD=1

That way, something follows the equals sign and ANT won't get confused.

OTHER TIPS

could you add the commandline you are using. it could be that ant agrees with you that there is no target '1' but that it believes you are passing one in.

This posting helped me resolve this error and wanted to share my version of the problem.

Target "listener" does not exist in the project "null".

ANT will use an environment variable ANT_ARGS if it is set. I was using the -listener option and set this option in my Windows envvar, ANT_ARGS. When I pasted the options into the Env Var:

-listener org.apache.tools.ant.listener.Log4jListener -lib D:\apache-ant-1.7.1\lib

I was missing the 'minus' sign in front of the 'listener' option.

This is similar to the problem above, but was hidden by the fact that I used the envvar ANT_ARGS.

Ya goose :-) You changed the project to "xxx" in the heading but left it as "vireporting" in the error output.

So the cat's out of the bag. You may as well make our life easier and post the XML since our ability to help you (psychic debugging) is greatly limited. If you want, sanitize the XML you post (better than you sanitized the original, hopefully).

And your comment ('There is no target "1"') makes sense since that's what ant is telling you. What you may have done is inadvertently created a dependency on that non-existent target.

It turns out this error message is the result of "-DGOBUILD_AUTO_COMPONENTS= -DGOBUILD_OFFICIAL_BUILD=1" in the command-line. I guess having nothing after the '=' in that -D option confuses Ant. (As an experiment, I changed "-DGOBUILD_OFFICIAL_BUILD=1" to "-DGOBUILD_OFFICIAL_BUILD=2" in this programmatically-generated command-line and the error message changed to "Target "2" does not exist in the project "xxx".")

Removing "-DGOBUILD_AUTO_COMPONENTS=" eliminated the build failure.

If someone can clearly explain why Ant emits such a strange error message in this case (or perhaps why it's not strange if one looks at it correctly), I'll accept your answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top