Java Reference
In-Depth Information
10.7.3
Compiling with Ant
Perhaps you're lucky enough to be working under agile methodologies and you
have a test machine continuously integrating your code, syncing up to your
source code repository and running a full build and test multiple times a day. The
build is running as a series of Ant scripts. How can that process mimic IDEA 's abil-
ity to process form XML files into byte code, if it isn't running a build from within
the IDEA program itself?
IDEA includes, in its redistributable JAR s, com.intellij.uiDesigner.ant.
Javac2 . This class is a custom Ant task that provides access to the form XML -to-
Java process. If you include a few libraries in your Classpath and define this cus-
tom task, as in listing 10.8, an Ant process can handle GUI Designer forms easily.
Listing 10.8
Defining a custom Ant task and using it in lieu of the standard
Javac task
...
<path id="compile.classpath">
...
</path>
<path id="uiDesigner.classpath">
<path refid="project.classpath"/>
<pathelement location="C:\Intellij-IDEA-4.5\lib\bcel.jar"/>
<pathelement location="C:\Intellij-IDEA-4.5\lib\jdom.jar"/>
<pathelement location=
"C:\Intellij-IDEA-4.5\redist\javac2.jar"/>
</path>
<taskdef name="javac2"
classname="com.intellij.uiDesigner.ant.Javac2"
classpathref="uiDesigner.classpath"/>
<target name="...">
<javac2 srcdir="..." destdir="..."
classpathref="compile.classpath" />
</target>
...
This example creates a custom task, javac2 , which uses libraries shipped with
IDEA . Then you use this new task as a replacement for the normal javac task,
and it automatically compiles the .form files and performs the necessary bind-
ing operations.
 
 
Search WWH ::




Custom Search