Java 如何告诉 Eclipse 忽略 Ant build.xml 中的错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4227028/
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
How to tell Eclipse to ignore errors in an Ant build.xml?
提问by matt b
I have an Eclipse project which is built using Maven, and I'm using the m2eclipse plugin inside Eclipse for it's Maven support.
我有一个使用 Maven 构建的 Eclipse 项目,我在 Eclipse 中使用 m2eclipse 插件来支持 Maven。
However this project also contains a build.xml
which is not used for actually building the project, but just for scripting capabilities as a utility for developers on the project - it is not used in building or packaging the product (just helping to automate some side tasks the developers often have to invoke on the side).
然而,该项目还包含一个build.xml
不用于实际构建项目,而仅用于脚本功能作为项目开发人员的实用程序 - 它不用于构建或打包产品(只是帮助开发人员自动化一些副任务通常必须在侧面调用)。
Whenever this file is opened in an editor in Eclipse, Eclipse notices what it thinks is a problem with some missing declarations in the build.xml and begins to display errors for the project (in the Problems view) along with a red X
icon/marker for the project to show that there are build errors. These aren't even true problems with the build.xml
, just some problems that Eclipse thinks are present because it is not able to import all of the other dependent files this build.xml
is using. There are no "build" errors with the project, just errors in what Eclipse (in it's infinite wisdom) is able to parse about a build.xml
used for auxiliary purposes.
每当在 Eclipse 的编辑器中打开此文件时,Eclipse 都会注意到它认为是 build.xml 中缺少一些声明的问题,并开始显示项目的错误(在问题视图中)以及一个红色X
图标/标记该项目显示存在构建错误。这些甚至不是 . 的真正问题build.xml
,只是 Eclipse 认为存在的一些问题,因为它无法导入build.xml
正在使用的所有其他相关文件。项目没有“构建”错误,只是 Eclipse(在它的无限智慧中)能够解析build.xml
用于辅助目的的错误。
Is there any way to tell Eclipse to ignore a build.xml or ignore Ant warnings in a particular project? Do I need to remove the Java Builder
from the Builders
tab of the project properties?
有没有办法告诉 Eclipse 在特定项目中忽略 build.xml 或忽略 Ant 警告?我需要Java Builder
从Builders
项目属性的选项卡中删除吗?
回答by Bivas
Window-> Preferences -> Ant -> Editor -> Problems (Tab)
check 'Ignore all buildfile problems'
Window-> Preferences -> Ant -> Editor -> Problems (Tab)
勾选“忽略所有构建文件问题”
回答by Mayoares
Go to Window->preferences->Ant->Problems tab. Add "build.xml" to the ignore list.
转到窗口-> 首选项-> Ant-> 问题选项卡。将“build.xml”添加到忽略列表中。
I found this workaround here.
我在这里找到了这个解决方法。
But my recommendation would be (if possible) to rename your build.xml first and only add this new build-filename to the ignore list. Then you avoid to ignore all other build.xml files in your eclipse workspace. That's how I use it :-)
但我的建议是(如果可能)首先重命名 build.xml,然后仅将此新构建文件名添加到忽略列表中。然后避免忽略 eclipse 工作区中的所有其他 build.xml 文件。这就是我使用它的方式:-)
回答by Andreas Dietrich
I found another workaround using the antcontrib task if
-"Dummy-Wrapping"I already had included in our build framework:
我找到了另一种使用 antcontrib 任务的解决方法if
- “Dummy-Wrapping”我已经包含在我们的构建框架中:
<target ...>
<if><istrue value="on" /><then> <!-- remove annoying "tst.local.ant.targets.show.out doesn't exist" warning in Eclipse Problems view and Ant View -->
<loadfile property="in" srcfile="${tmpOut}.out">
<filterchain><expandproperties/></filterchain></loadfile>
</then></if>
...
</target>
回答by kk.
Use javac option
使用 javac 选项
failonerror="false"
失败错误=“假”
<javac includeantruntime="false" srcdir="${src}" destdir="${build}" failonerror="false"/>