Here is my snippet of build.xml
<target name="compile">
<for param="rsync.destination.host" list="${file}" delimiter="${line.separator}">
<sequential>
<echo message="${rsync.ssh.user}@@{rsync.destination.host}:${rsync.destination.base.dir}/"/>
</sequential>
</for>
</target>
I received following output,
compile:
[echo] root@{rsync.destination.host}:/tmp/
[echo] root@{rsync.destination.host}:/tmp/
BUILD SUCCESSFUL
Total time: 0 seconds
So here @{rsync.destination.host}
variable is not interpreted because of double @@ character. If I put space in between them
<echo message="${rsync.ssh.user}@ @{rsync.destination.host}:${rsync.destination.base.dir}/"/>
then variable is resolved as expected.
compile:
[echo] root@ server1:/tmp/
[echo] root@ server2:/tmp/
BUILD SUCCESSFUL
Total time: 0 seconds
Since there is space in username and server it will through exception if we perform ssh here. Any idea how to solve this problem.
There are no variables in (core) ant, but properties and attributes.
@{foo} is the syntax for accessing the value of a macrodef attribute inside a macrodef. As antcontrib for task uses ant macrodef task under the hood it has the same syntax.
Try with :
...
<echo message="${rsync.ssh.user}@@@{rsync.destination.host}:${rsync.destination.base.dir}/"/>
...
means use 3x @ instead of 2x @
The param @{rsync.destination.host}
has to be masked with a second @, so in fact you need to use @ 3 times.