![]() ![]() Now I finally do a fourth ant command, and it has to both compile and run my program, since the class file had been deleted. This causes the “clean” rule to be executed, which deletes the class file. Then in the third ant command, I bypass the default target and supply “clean” as the target. But just like make, in the second ant command, Ant recognizes that an up-to-date class file already exists, and so it does not compile it again, it only runs it (there is no action after the “compile:” tag in the output). The first ant command causes Ant to both compile the code and then run it (the default target action is set to “run” in the build.xml file). Notice what happens as the ant commands are performed. With this Ant build file you can then do (each command-line command is in bold): prompt> lsīuildfile: /home/jcook/ws/classes/cs371/examples/helloworld/build.xmlīuild.xml HelloWorld.class HelloWorld.java That is, if you just type the command ant, it will look for a file named build.xml in the current directory, and it will perform the build actions that are described in that file.īelow is a simpler Ant build file for your Hello World program for lab 0 (assuming you named your class HelloWorld): But just like make, in the second ant command, Ant recognizes that an up-to-date class file already exists, and so it does not compile it again, it only runs it (there is no action after the compile. ![]() Just like make takes a Makefile, ant takes a build file – but Ant build files are written in XML, and the default file name to use is build.xml. The first ant command causes Ant to both compile the code and then run it (the default target action is set to run in the build.xml file). Its “Example Buildfile” contains an example that initializes the build directory, compiles the source code (that is in a src/ directory) into class files (in the build/ directory), and that packages up the compiled code into a jarfile for distribution! And it can clean up after itself (deletes class files)! It has a full manual, which is probably overkill, but if you go to “Using Apache Ant” and then “Writing a Simple Buildfile”, there is an example in that page that is kind-of simple, but not quite as simple as possible. The official Ant home is and this is a good place to start. Ant (or Ant) is the Java world’s equivalent of make, the old standby build tool in the C/C++ world.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |