Setting a condition on a target:
<target name="build-module-A" if="my-condition">
....
</target>
See: http://ant.apache.org/manu
Main Topics
Browse All TopicsHello,
I have an ant task that does an scp to a couple places:
<target name="copy-lib-jars">
<!-- copy the share jars -->
<scp todir="${user.name}@${host
keyfile="${user.home}/.ssh
passphrase="">
<fileset dir="${share.dir}" includes="*.jar" />
</scp>
<scp todir="${user.name}@${host
keyfile="${user.home}/.ssh
passphrase="">
<fileset dir="${share.dir}" includes="*.jar" />
</scp>
<!-- copy the third party jars -->
<scp todir="${user.name}@${host
keyfile="${user.home}/.ssh
passphrase="">
<fileset dir="${third-party.dir}" includes="*.jar" />
</scp>
<scp todir="${user.name}@${host
keyfile="${user.home}/.ssh
passphrase="">
<fileset dir="${third-party.dir}" includes="*.jar" />
</scp>
</target>
It could be that in share.dir and third-party.dir there are no files to copy. I would like to run a seperate target which will restart a Weblogic server only if there are files to copy in those directories. If no files were are present to copy, the target that restarts the Weblogic server doesn't get executed. Is there any way to do this? Perhaps a third party package?
Here's the task that restarts the weblogic server:
<target name="restart.clusters">
<echo message="Shutting down ${domain.folder} on ${domain.server.1}"/>
<sshexec host="${domain.server.1}"
username="${domain.usernam
keyfile="${user.home}/.ssh
passphrase=""
command="cd ${domain.location}/${domai
failonerror="false"/>
<!-- three more like this one -->
</target>
Thanks,
Tim
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Setting a condition on a target:
<target name="build-module-A" if="my-condition">
....
</target>
See: http://ant.apache.org/manu
If the built in support for conditionals in Ant doesn't meet your requirements, you could try antcontrib:
http://ant-contrib.sourcef
The task definitions are at:
http://ant-contrib.sourcef
Not only does this provide if/else constructs but it can also provide you with a forEach statement which would mean your code above need only to provide a list of machine to iterate over to copy the files to, avoiding the large amount of duplicate code (especially if you add additional nodes to your cluster).
Business Accounts
Answer for Membership
by: gadioPosted on 2005-08-10 at 14:12:13ID: 14646543
Please look at al/CoreTas ks/conditi on.html al/CoreTas ks/conditi ons.html
http://ant.apache.org/manu
and the supported conditions at http://ant.apache.org/manu
You can set a property based on the existance of files and then use that in the task and an execution condition.
G