Integration with IDEs

Although it is important to be able to build the entire application from the command line, the use of a build script should not preclude the use of the productivity features of your favorite integrated development environment (IDE). While is important that an IDE is able to interoperate with a build script, it is equally important that a build script can utilize the features of the IDE.

Chapter 13 covers the advantages of working with an IDE.

Unfortunately, IDEs do not make good build tools. They tend to do only a very small subset of the build tasks required on most projects. They can perform such tasks as compilation and packaging, but fall short of supporting all the build tasks necessary for the development of enterprise software. In contrast, a good build script performs tasks such as stamping JAR files with version numbers, packaging applications ready for deployment, distributing applications into test environments, running unit tests, and so on.

Although IDEs do not perform all the essential build tasks required for a project, they do perform certain build tasks extremely well. Compilation of all source files is one example. A highly useful feature of an IDE is to have it continually compile and syntax-check code as you type. This feature traps syntax errors early on and is very productive.

To support this feature, the IDE must be configured with all the necessary information to compile the application. If the build script is also to perform the compile task, a duplication of effort exists between the IDE and build script. Such a duplication, as well as being an overhead to maintain, is a possible source of build inconsistencies, since different application characteristics may emerge from the different build approaches.

One way to circumvent this problem is to have Ant use the IDE to perform the build. With this method, builds initiated from the IDE are identical to those invoked from the build script.

In order for this approach to work, the IDE must be able to run a build from a shell command, preferably without launching the entire graphical development environment.

Here's how the Ant <exec> task can build the project using Borland's JBuilder.

 <exec dir="."       executable="${jbuilder_home.dir}/jbuilder.exe"       failonerror="true">   <arg line="-build myproject.jpx make"/> </exec> 

This approach relies on using the machinery of the JBuilder IDE, complete with the JBuilder project's classpath settings, to perform the build. This removes the need to duplicate build information between the project file of the IDE and the Ant build file. Check the manual of your favorite IDE to establish how to initiate the build process from the command line.

    Rapid J2EE Development. An Adaptive Foundation for Enterprise Applications
    Rapid J2EEв„ў Development: An Adaptive Foundation for Enterprise Applications
    ISBN: 0131472208
    EAN: 2147483647
    Year: 2005
    Pages: 159
    Authors: Alan Monnox © 2008-2017.
    If you may any questions please contact us: