| Sun Java System Application Server |
Sun Java System Application Server includes a Java-based build tool called Ant, developed by the Apache Software Foundation.
Many server side Java developers have found Ant to useful for accelerating
development of J2EE applications. Ant contains
many built-in functions that relieve the burden of repetitive development
tasks. As described in the Ant documentation,
"In theory it is like make without make's wrinkles".
For more information about Ant, see the Apache Ant Project.
In the Ant environment, build.xml
files are analogous to Makefiles. A build.xml file can define
various targets that are used to compile and assemble a J2EE application.
To use Ant with the sample applications provided as part of the
application server, you need to ensure that your PATH includes the
install_dir/bin
directory of your application server installation. A simple wrapper
script named asant(.bat)
is located in this directory. No further set up is required.
The following build targets
are represented in the build.xml files accompanying
the sample applications. The presence or absence of a target depends
on the type of J2EE application.
| Target | Function |
|---|---|
| compile | Compiles all Java source code. |
| war | Assembles the WAR file in sample_dir/build/assemble/war/ |
| ear | Assembles the EAR file insample_dir/build/assemble/ear/ |
| core (default) | Compiles all sources, builds stubs/skeletons
and assembles EJB[tm] JAR, WAR and EAR files. This is the
default target for all build.xml files shipped
in the application server. |
| docs | Creates Java docs in <sample_dir>/javadocs |
| all | Builds both core and javadocs, verifies, registers resources and deploys app. |
| deploy | Registers resources, deploys app, but does not install Javadocs. |
| deploy_common | Application deployment only. No resource registration. |
| verify | Verifies application binaries. |
| undeploy | Removes the deployed sample from application server. |
| clean | Removes appname/build/
content. |
Follow these steps to use Ant for the first time:
The install_dir/bin
directory must be in your PATH environment variable.
On UNIX platforms, you
will need to add theinstall_dir/bin
directory to your PATH environment variable.
On Windows platforms, after
installation of the application server, set the System path
by adding install_dir\bin
to your user PATH environment variable.
To deploy sample applications, you must set property values in the
install_dir/samples/common.properties file
to the appropriate values for your environment.
If a property contained in this file is not set, you will be prompted for the property's
value during the deployment of a sample application.
See Creating Your Own Samples Environment section for
a description of the common.properties file.
Using the blueprints/petstore1.4
sample as an example, execute several of the build targets.
Change to the blueprints/petstore1.4/src directory:
cd install_dir/samples/blueprints/petstore1.4/src
Execute the compile target to compile the Java sources:
asant core
This target assembles the J2EE module files and the EAR files.
Alternatively, you could
accomplish all of these tasks by simply executing either the
core or all targets:
asant all
Since the default build
target is core,
you could execute ant without arguments to rebuild the entire application:
asant
The following examples demonstrate how to use the build facility to quickly accomplish common development and deployment tasks:
asant all
asant core asant deploy
asant ear asant deploy_common
|
|
The Application Server comes with custom Ant tasks that are part of the build environment
for all samples. The following tasks are used in the sample build.xml
files:
| Custom Ant Task | Function |
| sun-appserv-deploy |
Deploys
J2EE components to the Application Server. |
| sun-appserv-undeploy | Undeploys J2EE components from the Application Server. |
| sun-appserv-admin | Enables arbitrary administrative commands and scripts to be executed on the Application Server. |
For more information about these Ant tasks and for a full list of the custom Ant tasks, please see the Administrator's Guide on docs.sun.com.
Netbeans 4.1 includes support for Ant build files. To use the IDE to execute the targets contained in the sample application build.xml files, you must add the JAR file containing the custom Ant tasks for Application Server to the IDE's classpath. Follow this procedure:
install_dir/lib/sun-appserv-ant.jar from the application server's
installation directory to the
ide_install_dir/ide5/ant/patches/org-apache-tools-ant-module/ directory and
restart the IDE.
samples_dir/quickstart
quickstart/ directory to list the targets
available in the sample's build.xml file.
To deploy a sample application, ensure that you modify the
samples/common.properties andf set the admin.password to the appropriate value.
Copyright © 2006 Sun Microsystems, Inc. All rights reserved.