简体   繁体   English

如何为现有Java项目创建ant构建器文件(build.xml)?

[英]How do I create an ant builder file (build.xml) for an existing Java project?

I am working on an Java assignment for a software design course in my university. 我正在为我大学的软件设计课程编写Java作业。 It's not really complicated and it includes some classes, interfaces and jUnit test cases. 它并不是很复杂,它包括一些类,接口和jUnit测试用例。 We were now told we should supply a build.xml file as an input for an ant builder. 我们现在被告知我们应该提供一个build.xml文件作为ant构建器的输入。 I have never heard of, or used ant before. 我以前从未听说过,或曾经使用过蚂蚁。 I also saw Eclipse supports it. 我也看到Eclipse支持它。 My questions are - What does build.xml do? 我的问题是 - build.xml有什么作用? How does Eclipse builds my project and why not do the same instead of using ant? Eclipse如何构建我的项目,为什么不这样做而不是使用ant? And most important - how to create this file with Eclipse? 最重要的是 - 如何使用Eclipse创建此文件?

Thanks. 谢谢。

Ant is a build tool based on Java. Ant是一个基于Java的构建工具。 It is very powerful, and integrates with various other tools you might need to build any imaginable Java application. 它非常强大,并且可以与构建任何可以想象的Java应用程序所需的各种其他工具集成。 It is very useful when deploying a Continunous Integration environment with a Continuous Build server. 在使用Continuous Build服务器部署Continunous Integration环境时,它非常有用。

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. 您正在Eclipse中构建,并且您的构建过程绑定到您的IDE - 这对于单人项目来说非常好,但对于团队项目来说可能效率不高。 Also, with Ant, you can have a complex build including multiple components and intricate dependencies done in a single step, including unit tests. 此外,使用Ant,您可以拥有一个复杂的构建,包括多个组件和复杂的依赖关系,包括单元测试。

You can either create your Ant build from scratch (which is the best way, but it takes quite a while). 您可以从头开始创建Ant构建(这是最好的方法,但需要很长时间)。 Otherwise, you can create it with Eclipse using the File/Export menu (under General, select Ant buildfiles). 否则,您可以使用File / Export菜单在Eclipse中创建它(在General下,选择Ant buildfiles)。

You should definitely know how to crate a build.xml file from scratch, just so you know what Eclipse does behind the scenes. 您肯定应该知道如何从头开始创建build.xml文件,这样您就知道Eclipse在幕后做了什么。

I taught a Java class a while ago where I explained the basics of ant . 我刚才教过Java课程,在那里我解释了蚂蚁的基础知识。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM