Have another target called "_undeploy-test". This target will use test
whether or not the product is actually deployed. You can the
<condition> or <available> task to test whether or not your project is
deployed. The <available> task is defined here:
<http://ant.apache.org/manual/CoreTasks/available.html>. The
<condition> task is described here:
<http://ant.apache.org/manual/CoreTasks/condition.html>. Supported
conditions are described here:
<http://ant.apache.org/manual/CoreTasks/conditions.html>.
Next, have your <deploy> target depend upon the <undeploy> target.
This can be done via the "depends" parameter of your target.
Finally, set your <undeploy> task to depend upon the <_undeploy-test>
target. This target should set a property if the module is deployed.
Have the undeploy target depend upon this property be defined. Here's
an example layout:
<project name="foo" default="deploy" basedir=".">
<property name="deploy.dir" value="?"/>
[...]
<target name=_undeploy-test">
<available file="${deploy.dir}" type="dir"
property="module.deployed">
</target>
<target name="undeploy"
depends="_undeploy-test"
if="module.deployed">
<delete dir="${deploy.dir}"/>
</target>
<target name="deploy"
depends="undeploy">
[...]
</target>
</project>
Note that when you run the "deploy" target, it will first run the
"undeploy" target automatically. The "undeploy" target will
automatically run the "_undeploy-test" target first, if that target
doesn't set the "module.deployed" property, the "undeploy" target
won't execute. However, the "deploy" target will still run.
On Dec 8, 2007 9:39 PM, hezjing <[EMAIL PROTECTED]> wrote:
> Hi
>
> How do I check if an web application already installed in Tomcat 5.5.x?
>
> I have a DeployTask and UndeployTask configured in build.xml, and I
> want Ant to undeploy the existing web application automatically before
> it deploys the new one.
>
> Currently, I have to run Ant with 2 targets like > ant undeploy deploy.
> This still cause problem when the application has been removed by
> someone else :-(
>
>
> --
>
> Hez
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
--
David Weintraub
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]