Sun Microsystems Logo

 

 

Sun[tm] ONE Web Server 
Using Ant with the Samples
This product does not include the Ant Java[tm]-based build tool developed by the Apache Software Foundation (http://www.apache.org). You must download and install Ant version 1.4.1.

  » Benefits of Using Ant
  » Ant Environment in Sun ONE Web Server
  » Using the Build Facility

Benefits Of Using Ant

Many server-side Java developers have found Ant to be an extremely useful tool for accelerating the development cycle associated with J2EE[tm] 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 kind of like make without make's wrinkles." For more information about Ant, see:

http://jakarta.apache.org/ant/index.html 

Ant Environment in Sun ONE Web Server

The following build targets are represented in the build.xml files that accompany the sample applications.
 
Target Function
usage Lists all of the available targets.
compile Compiles all Java source code.
war Assembles the WAR file in <sample_dir>/assemble/war/.
default  (default)  Compiles all sources, builds stubs/skeletons, and assembles JAR and WAR files. This is the default target for all build.xml files shipped in the web server.
all Builds both default and registers resources and deploys app.
deploy
Application deployment only. No resource registration.
undeploy  Removes the deployed sample from the web server.
clean Removes <appname>/build/ and <appname>/assemble/ content.
list_resource_common
Lists the available resources.
list_apps
Lists the available applications.
create_jdbc_datasource_common.
Creates a jdbc datasource.
create_jdbc_connectionpool_common
Creates a jdbc connection pool.
create_custom_resource_common
Creates a custom resource.
create_external_resource_common
Creates an external resource.
create_javamail_resource_common
Creates a javamail resource.
delete_resource_common
Deletes a resource.
delete_jdbcconnectionpool_common
Deletes a jdbc connection. pool


Using the Build Facility

1. Set Up Your Environment

To use the Ant tool to compile and reassemble the sample applications, you must ensure that the <ANT_HOME>/bin directory is in your environment's path, and that the JAVA_HOME environment variable is set to the directory in which your JDK is installed.

On UNIX platforms, you must add the <ANT_HOME>/bin directory to your PATH environment variable.

On Windows platforms, after installation of the web server, you must set the System path by adding <ANT_HOME>\bin to the user's PATH environment variable.

2. Compile and Assemble a Sample Application

Using the jdbc-simple sample as an example, execute several of the build targets:

Change to the jdbc/simple sample directory:

cd <install_root>/plugins/java/samples/webapps/jdbc/simple/src

Execute the compile target to compile the Java sources:

ant compile

Execute the war target to assemble the J2EE module files and the WAR file:

ant war

Alternatively, you could accomplish all of these tasks by simply executing either the default or all targets:

ant default

Since the default build target is default, you could execute ant without arguments to rebuild the entire application:

ant

3. Additional Build Examples

The following samples demonstrate how you can use the build facility to quickly accomplish recurring development and deployment tasks.

Build everything. Then deploy the application:

ant all

Build everything. Then deploy the application (the most frequently used approach):

ant default (or simply: ant)

ant deploy


common.properties File: To deploy sample applications, property settings in the common.properties file under <install_root>/plugins/java/samples/webapps must be set to the appropriate values for your environment. The file contains default values. If you want to use a different virtual server for these samples, make the necessary changes in common.properties.


 
Company Info   |   Contact   |  Copyright 2003 Sun Microsystems