我在 Eclipse 中有一个项目,该项目目前没有 ANT 构建文件,但即将创建一个(以方便构建 jar)。我想编写构建文件,以便它对两者都适用。我正打算在 ANT 中编写完整版本,但我在 an IBM Help doc 中注意到了这一行.
The Java builder runs the internal Eclipse Java compiler which in turn is responsible for indexing your source so that searching, refactoring and many other features are available. Thus it is not possible to replace the internal Eclipse Java compiler by using a project builder. You can disable the Java builder and you can control when the Java Builder runs with respect to the project builders that you define.
我是否需要编写 ANT 文件,以便它仅在 Eclipse 之外有条件地编译(
javac
)?我是否还需要做其他事情才能使 ANT 和 Eclipse 很好地协同工作?
最佳答案
也许有更复杂的方法,但这是对我有用的方法。只需在 Eclipse 中设置您的 Java 项目,以将类输出到与您的 Ant 构建文件相同的目录。让 Eclipse 使用普通的 Java 编译器编译您的项目。
在典型的开发过程中,您可能会更改 Java 源文件并希望看到它们编译。 Eclipse Java 编译器会处理这个问题。不太频繁地您需要重建 jar 。 Ant 会处理这个问题。当您需要从命令行或 Eclipse 时,您可以启动 Ant 构建。
关于eclipse - 创建 ANT 文件以在 Eclipse 和 CruiseControl 中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6062960/