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
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
prepare:
[mkdir] Created dir: C:\tmp\app\webapps\webclasses [mkdir] Created dir: C:\tmp\app\dist
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 deploydeploy:
[copy] Copying 1 file to C:\resin\webapps
[copy] Copying 1 file to C:\tomcat\webapps
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
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