Pramati Technologies

Integrating ANT with Pramati Studio

Overview

ANT is a build tool based on a model, which is extended using Java classes. The configuration files are XML based calling out a target tree where various tasks get executed. An object that implements a particular Task interface runs each task and ANT allows the user to work on any platform.

Use ANT-build-scripts, integrated with Studio to build the EARs from sources and XML files. These can be run independently outside Studio. The compilation scripts take care of the dependencies, and then organizes the compilation. Also create build scripts for nightly builds to enable large-scale application development.

Note: ANT is part of Apache Jakarta Project. For more information, visit
http://jakarta.apache.org/ant/index.html.
Creating ANT XMLs in Studio

Before generating the scripts required, right click on the Desk and select Export as Archive. Using this option refreshes the Java archives, web archives and the enterprise archives. Once the archives have been refreshed, select Build > Update Build Scripts from the main menu.

This opens the dialog which displays the scripts to be updated for the modules and the deskbuild.xml. Select the files to be updated and click OK.

The options available for automatic build script generation are:

The file build.xml for each source root mapped to an EJB module, Java module, or web module, analyzes the dependencies and generates the targets for compiling the sources at the package level. For example, if the package com.pramati has ten files, all the files get compiled at one time using javac -d classes/EJB_Module com/pramati/*.java.

The information about the dependencies in the modules is stored in a file called master.dep under their respective source roots. This file is used to generate the build.xml file. When two packages are inter-dependent, both packages get compiled in one target. For example, if package A depends on package B, and Package B depends on package A, they are compiled using javac -d classes/EJB_Module A/*.java b/*.java.

Updating build.xml for changes to existing packages

The targets compile the sources at the package level. The XML files should be updated when new packages are added, existing packages are deleted, or the dependencies between packages change. For example, package a.b.c1 was compiled before a.b.c2. After some modifications are made to the classes in package a.b.c2, package a.b.c1 uses the classes. These two packages should then be compiled together.

Understanding deskbuild.xml

The file deskbuild.xml builds the entire application by compiling the Java modules, EJB modules and web modules, and packaging the Java archives, web archives, and enterprise archives for the application. This file has a target for each module and archive in the desk.

To compile each module in the desk, the target in the deskbuild.xml file invokes the appropriate targets in the build.xml file of that module. As each module in the desk may contain only a few packages of the source root, it points to only those packages under that module, only the specific target is invoked. Consider the following example:

Packages A and B are under EJBmodule1 and package C is under EJBmodule2. The file deskbuild.xml has targets TargetA for EJBmodule1 and TargetB for EJBmodule2. The file build.xml has one target for compiling package A, one for package B, and one for package C. TargetA in the deskbuild.xml file invokes the targets in build.xml that compile packages A and B, and TargetB invokes the target in build.xml that compiles package C.

The XML files ejb-jar.xml and pramati-j2ee-server.xml in the JARs, web.xml in the WARs, and pramati-j2ee-server.xml and application.xml in the EARs are not generated at the time of execution of deskbuild.xml script. They are extracted from the JAR and stored under the JAR at the time of generation of the script. When this target is executed, the XML files are included along with the built contents. There is also one target each for the JARs, WARs and EARs in the desk.

Updating deskbuild.xml

The XML files of the archives are not generated when the scripts are updated. Therefore each time new beans are added to the Java archive, or JSP files are added to the web archive or the resources changed, update the build scripts.

Running ANT XMLs in Studio

To execute the ANT XML files from inside Studio:

  1. Import the specific ANT XML file in the desk using the Import Files option available on a right click.
  2. Once the file has been imported, right click on the file and select Run.
  3. Select Run to view the list of all the targets in the ANT XML file. The default target is shown as the first item in the list.
  4. Click on a target to run the ANT file. This step performs the same action as executing ant -buildfile FILENAME TARGETNAME where buildfile is the ANT file name and target is the target name.

The output of ANT is shown in the Build output tab. Double click on any error displayed in the ANT output to opens the corresponding file in the Editor with the error highlighted.


Pramati Technologies  © Copyright   TOCPREVNEXTINDEX