Powered by | Fast Ant builds with CodeGuideMichel CASABIANCA - casa@sweetohm.netThis article presents the integration of the Ant Console within CodeGuide to boost significantly build times. For Ant integration and other CodeGuide tips, see this article.
Ant ConsoleThis tool runs Ant in a console (in a terminal or within your favorite IDE) and lets you type commands to run targets of the loaded build file. This method runs much faster than Ant because it saves time to launch the Java Virtual Machine, JIT compilation time and build file loading. You can run builds up to 5 times faster than running Ant on the command line. It is obvious than you save more time on small builds (when time spent in usefull code is small compared to startup time). InstallationDownload SAT that you can get for free on my web site. Go in the bin directory of your Ant installation, copy the ant script (or ant.bat for OS disabled people) to file antc (or antc.bat). Replace org.apache.tools.ant.Main with net.cafebabe.sat.ant.Console. This script will launch the Ant console instead of traditional Ant. Make sure that this script is in your PATH. You must, of course, install SAT by dropping the file sat.jar in the lib directory of your Ant installation. UsageTo run the Ant console, go in the directory of your project (where is living your build.xml file) ant type antc. You will display an help screen typing antc -help on the command line :
When you launch the Ant console, you will be promped as following :
Figure 1: Ant Console running To display an help screen about the console commands, type help in the console :
Note that you can launch a given target by typing its name (this is a shortcut for the target command) provided that this target hasn't the same name than a console command. You can repeat the last command by typing ENTER. You can load a build file using the load command (the path is then relative to the current directory) and search for a build file recursively in the file system with the find command (that behaves like the -find command line argument for Ant). You can also reload the current project with reload. This may be necessary when the build file changes on disk or when the project is corrupted (which happens sometimes after a build error because some tasks don't work after an error). The desc command describes the current project (behaves like the -projecthelp command line parameter for Ant). I have also implemented a timer (to display execution time for builds) that you can switch on or off using the timer command. The result is in milliseconds (because the builds are so fast :o) Integration in CodeGuideI have already said that this IDE is fast and probably the most powerful for real world Java development, Ant is very slow compared to this tool. The goal of this integration is to make Ant run at light speed in CodeGuide. First, make sure that the Ant Console runs properly from the command line (by typing antc in a terminal). Then we will integrate it as an external tool. To do so, open Tools/Configure tools... in the menu. The following window opens to let you configure an external tool:
Figure 2: Tools configuration window Click on the New button and fill fields with the following values:
To run the console, right click on a file (in the ditor pane or in the Project bar) and select the item Ant Console.
Figure 3: Launch the Ant Console on a file This will open a dedicated console where Ant is waiting for your commands. Take a look at the build times (in milliseconds), it screams!
Figure 4: The Ant Console running in CodeGuide The same build using Ant takes about 6 seconds (about 4 times more). Using the latest PowerMac dual G5 2GHz, you could probably compete for the fastest Ant builds on earth :o) Thanks Frédéric for his corrections Enjoy! Last update: 2004-01-06 |