您的位置:首页 > 其它

Section "Using Ant"

2004-07-22 13:14 453 查看
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 wantto execute, like this:
antcompile
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐