Ant 简明教程

Ant - Eclipse Integration

如果您已经下载并安装了 Eclipse,您几乎不用做任何事情就可以开始。Eclipse 与 Ant 插件捆绑在一起,开箱即用。

按照如下简单步骤,可将 Ant 集成到 Eclipse 中。

  1. 确保 build.xml 是您 Java 项目的一部分,且不位于项目外部某个位置。

  2. 遵照 Window → Show View → Other → Ant → Ant 来启用 Ant View。

  3. 打开 Project Explorer,将 build.xml 拖到 Ant View 中。

您的 Ant 视口与此给定视口类似 −

eclipse ant

点击 target,build/clean/usage 将使用 target 运行 Ant。

点击“传真”将执行默认 target - usage

Ant Eclipse 插件还带有适合编辑 build.xml 的好编辑器。该编辑器了解 build.xml 架构并且可以帮助您完成代码。

要使用 Ant 编辑器,右击您的 build.xml(来自 Project Explorer),然后选择 Open with > Ant Editor。Ant 编辑器应类似此样式 −

ant editor

Ant 编辑器在右侧列出 target。target 列表用作书签,以允许您直接跳到特定 target 编辑中。