什么可能导致错误消息“目标“1”在项目“xxx”中不存在。在 Windows 上运行 Ant?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/979272/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What could cause the error message 'Target "1" does not exist in the project "xxx".' running Ant on Windows?
提问by Daryl Spitzer
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.)
我在 Windows 2003 Server 上使用 ant.bat(在 Ant 1.7.1 中)在 build.xml 文件中构建 all 目标。(我已将错误消息中的“xxx”替换为该文件中的项目名称。)
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".)
我在 build.xml 中搜索了可能导致此错误的任何内容,但均未成功。(当然,没有目标“1”,也没有可能解析“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.
我希望那里的人可能记得看到这个。我不希望有人为我调试 XML,但是 Google 搜索结果出现了http://simile.mit.edu/mail/ReadMsg?listId=9&msgId=2735,其中包含“我找到了有关此问题的电子邮件线程并将重试。”。我希望我能找到那个线程。
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.
希望它有一些帮助。
回答by Eddie
Do you have any targets that depend on "1
"? Perhaps due to a typo?
你有任何依赖于“ 1
”的目标吗?也许是因为打字错误?
<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 somethingis 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:
因为预计会有一些事情发生'='
。似乎第二个'='
被视为空白,可能是因为 ANT 被混淆了。我不会期望的。做你想做的事情的正确方法是:
-DGOBUILD_AUTO_COMPONENTS="" -DGOBUILD_OFFICIAL_BUILD=1
That way, somethingfollows the equals sign and ANT won't get confused.
这样一来,一些遵循等号和ANT不会混淆。
回答by akf
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.
你能添加你正在使用的命令行吗?可能是蚂蚁同意你没有目标“1”但它相信你正在传递一个。
回答by Doug
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".
项目“null”中不存在目标“listener”。
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:
ANT_ARGS
如果设置了环境变量,ANT 将使用它。我正在使用该-listener
选项并在我的 Windows envvar 中设置此选项,ANT_ARGS
. 当我将选项粘贴到 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
.
这与上面的问题类似,但被我使用了 envvar 的事实所掩盖ANT_ARGS
。
回答by paxdiablo
Ya goose :-) You changed the project to "xxx" in the heading but left it as "vireporting" in the error output.
Ya goose :-) 您在标题中将项目更改为“xxx”,但在错误输出中将其保留为“vireporting”。
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).
所以猫从袋子里出来了。您也可以让我们的生活更轻松并发布 XML,因为我们帮助您(心理调试)的能力非常有限。如果需要,请清理您发布的 XML(比清理原始文件要好,希望如此)。
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 dependencyon that non-existent target.
你的评论('没有目标“1”')是有道理的,因为这就是蚂蚁告诉你的。您可能所做的是无意中创建了对该不存在目标的依赖。
回答by Daryl Spitzer
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".
")
事实证明,此错误消息是-DGOBUILD_AUTO_COMPONENTS= -DGOBUILD_OFFICIAL_BUILD=1
命令行中“ ”的结果。我想在 -D 选项中的 '=' 之后没有任何内容会使 Ant 感到困惑。(作为一个实验,我改变“ -DGOBUILD_OFFICIAL_BUILD=1
”到“-DGOBUILD_OFFICIAL_BUILD=2
在此编程方式生成的命令行和变更为“错误消息” Target "2" does not exist in the project "xxx".
“)
Removing "-DGOBUILD_AUTO_COMPONENTS=
" eliminated the build failure.
删除“ -DGOBUILD_AUTO_COMPONENTS=
”消除了构建失败。
If someone can clearly explain whyAnt 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.
如果有人能清楚地解释为什么Ant 在这种情况下会发出如此奇怪的错误消息(或者也许为什么如果正确看待它并不奇怪),我会接受你的回答。