如何为现有 Java 项目创建 ant 构建器文件 (build.xml)?
我正在为我所在大学的软件设计课程做 Java 作业。它并不复杂,它包括一些类、接口和 jUnit 测试用例。现在我们被告知应该提供一个 build.xml 文件作为 ant 构建器的输入。我以前从未听说过或使用过 ant。我也看到Eclipse支持它。 我的问题是 - build.xml 有什么作用? Eclipse 如何构建我的项目?为什么不做同样的事情而不是使用 ant?最重要的是 - 如何使用 Eclipse 创建这个文件?
谢谢。
I am working on an Java assignment for a software design course in my university. It's not really complicated and it includes some classes, interfaces and jUnit test cases. We were now told we should supply a build.xml file as an input for an ant builder. I have never heard of, or used ant before. I also saw Eclipse supports it.
My questions are - What does build.xml do? How does Eclipse builds my project and why not do the same instead of using ant? And most important - how to create this file with Eclipse?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Ant是一个基于Java的构建工具。它非常强大,并且与构建任何可以想象的 Java 应用程序可能需要的各种其他工具集成。当使用持续构建服务器部署持续集成环境时,它非常有用。
您正在 Eclipse 中进行构建,并且您的构建过程与您的 IDE 绑定——这对于单人项目来说非常好,但对于团队项目来说可能效率不高。此外,使用 Ant,您可以在一个步骤中完成包括多个组件和复杂依赖项的复杂构建,包括单元测试。
您可以从头开始创建 Ant 构建(这是最好的方法,但需要相当长的时间)。否则,您可以使用 Eclipse 的“文件/导出”菜单(在“常规”下,选择“Ant 构建文件”)来创建它。
Ant is a build tool based on Java. It is very powerful, and integrates with various other tools you might need to build any imaginable Java application. It is very useful when deploying a Continunous Integration environment with a Continuous Build server.
You are building within Eclipse, and your build process is bound to your IDE - which is perfectly fine for a one-man project but might prove unefficient for a team project. Also, with Ant, you can have a complex build including multiple components and intricate dependencies done in a single step, including unit tests.
You can either create your Ant build from scratch (which is the best way, but it takes quite a while). Otherwise, you can create it with Eclipse using the File/Export menu (under General, select Ant buildfiles).
您绝对应该知道如何从头开始创建 build.xml 文件,这样您就知道 Eclipse 在幕后做了什么。
不久前,我教授了一门 Java 课程,其中解释了 ant 的基础知识。
You should definitely know how to crate a build.xml file from scratch, just so you know what Eclipse does behind the scenes.
I taught a Java class a while ago where I explained the basics of ant.