Sun Microsystems Logo

 

 

Sun Java System Web Server 
Using Ant With the Samples
This product does not include the Ant Java technology-based build tool developed by the Apache Software Foundation (http://www.apache.org). You must download and install Ant.

  » Benefits of Using Ant
  » Ant Environment in Sun Java System 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 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 the Apache Ant Project.

Ant Environment in Sun Java System Web Server

The following build targets are represented in the build.xml files that accompany the sample applications.
 
Target Function
usage Lists 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_resource_common Creates a jdbc datasource.
create_auth_realm_common Creates an auth realm element.
set_default_auth_realm_name_common Sets the default auth realm name element.
delete_default_auth_realm_name_common Deletes the default auth realm name element.
create_custom_resource_common Creates a custom resource.
create_external_resource_common Creates an external resource.
create_javamail_resource_common Creates a javamail resource.
set_jvm_classpath_prefix_common Appends the path to the jvm classpath prefix.
set_jvm_classpath_suffix_common Appends the path to the jvm classpath suffix.
set_jvm_options_common Sets the jvm options.
delete_resource_common Deletes a resource.


Using the Build Facility

1. Setting 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. Compiling and Assembling a Sample Application

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

    a. Change to the jdbc/simple sample directory:
    # cd install_root/samples/java/webapps/jdbc/simple/src

    b. Execute the compile target to compile the Java sources:

    # ant compile

    c. 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

Because 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 (the most frequently used approach):

    # ant default (or simply: ant)
    # ant deploy

  • Build everything, then deploy the application:

    # ant all


common.properties File: To deploy sample applications, property settings in the common.properties file under install_root/samples/java/samples/webapps must be set to the appropriate values for your environment. The file contains default values. You need to set the value for instance name, config name, virtual server, and password file path in common.properties.


 
Company Info   |   Contact   |  Copyright 2007 Sun Microsystems, Inc.