Section "Using Ant"

ant的使用就是这么的简单,更复杂的build.xml的写法可以参考ant的帮助文档

Developing Games in Java值得一看,很多地方虽然是点到即止,但重点绝不漏掉!

Apache Ant is a free Java-based build tool and can be downloaded from http://ant.apache.org. Because Ant is Java-based, Ant build files can be compiled on any platform. Also, Ant is integrated into many Java IDEs, so you can get up and running quickly.

Ant build files are XML files, usually named build.xml. Listing I.1 contains an example build file.

Listing I.1 Sample Ant Build File (CSDN的blog贴不出xml格式文本。。。见下面回复内容)

The sample Ant file almost describes itself. First, two properties are created to specify the srcdir and destdir directories. Properties can be referred to using the ${varName} syntax.

The build file contains four targets: clean, compile, build, and rebuild.

The compile target compiles all Java files in the source directory, putting the compiled class files in the destination directory. The clean target deletes all of these classes.

The build target depends on the compile target, so running the build target automatically runs the compile target first. The build target packs all the compiled class files into a .jar file.

Finally, the rebuild target does nothing by itself, but depends on the clean and build targets to perform a clean build.

After you've got Ant installed, just open a command prompt in the directory of the build file and type in the target you want to execute, like this:

ant compile 

This command loads the build.xml file in the current directory and executes the compile target. If you were to name no target, as in the following, the build target is executed because it's defined to be the default target in the build file:

ant 

Besides running Ant from the command line, Ant is also tightly integrated into many IDEs and text editors, such as JBuilder, jEdit, Eclipse, IDEA, and NetBeans. For example, in jEdit (see Figure I.1), the AntFarm plug-in enables you to browse Ant files, execute targets with the click of the mouse, and even send compile errors to jEdit's ErrorList plug-in so you can click on errors to go directly to the source of the compile error.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值