Section "Using Ant"

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

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.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航