Developing Web Applications With Ant by Richard Hightower - HTML preview
Download the book in PDF, ePub, Kindle for a complete version.
Building and Deploying the Web Application
This section explains how to build and deploy the Web application. The build file assumes that you have Tomcat (or Resin) installed in the root of your drive. You may need to make adjustments to the build file if you installed Tomcat in another directory or if you are using another J2EE-compliant Web application server.
To build the Web application, follow these steps:1. Navigate to the WebApplication directory, set up the environment, and then enter the following at the command line:
C:\CVS\...\MVCHelloWorld\WebApplication>ant
You will get the following output:
Buildfile: build.xml
setProps:
init:
clean_deploy:
[delete] Could not find file C:\resin\webapps\hello.war to delete. [delete] Could not find file C:\tomcat\webapps\hello.war to delete
[delete] Could not find file C:\tmp\app\dist\hello.war to delete.
prepare:
[mkdir] Created dir: C:\tmp\app\webapps\webclasses [mkdir] Created dir: C:\tmp\app\dist
[javac] Compiling 1 source file to C:\tmp\app\webapps\webclasses package:
[mkdir] Created dir: C:\tmp\app\webapps\meta
prepare_meta_ejb:
prepare_meta_noejb:
prepare_meta:
[copy] Copying 1 file to C:\tmp\app\webapps\meta [war] Building war: C:\tmp\app\dist\hello.war
all:
BUILD SUCCESSFUL
2. Deploy the WAR files to the application server. If you install Tomcat off the root directory, then you can run the deploy target. Otherwise, modify the appropriate deploy properties defined in the init target. To deploy the application with Ant, do the following:
C:\CVS\?.\MVCHelloWorld\WebApplication>ant deployBuildfile: build.xml
...
...
deploy:
[copy] Copying 1 file to C:\resin\webapps
[copy] Copying 1 file to C:\tomcat\webapps
Total time: 0 seconds
3. After we run the application, we start Tomcat, and then hit the site with our browser. We can also clean out the directories when we are ready to deploy a new version:
C:\CVS\...\MVCHelloWorld\WebApplication>ant clean
The output looks like this:
Buildfile: build.xml
init:
clean_deploy:
[delete] Deleting: C:\resin\webapps\hello.war
[delete] Deleting: C:\tomcat\webapps\hello.war
clean:
[delete] Deleting directory C:\tmp\app\webapps [delete] Deleting: C:\tmp\app\dist\hello.war
