ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Weintraub" <qazw...@gmail.com>
Subject Re: How to undeploy web application if it exists
Date Sun, 09 Dec 2007 03:13:24 GMT
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 <hezjing@gmail.com> 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: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>



-- 
--
David Weintraub
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message