问题 任何类似的rsync for Ant?


我需要一些模拟 rsync 为了蚂蚁。问题是将文件从源目录复制到先前使用脚本完成的子目录集

rsync -r --ignore-existing $BASE_DIR/common/config/* $BASE_DIR/config

谢谢你的帮助


7476
2018-06-20 09:17


起源



答案:


您可以使用 EXEC 打电话 来自Ant的rsync,你可以使用 java的 打电话的任务 Jarsync 要么 Java的同步 或者你可以创建一个 自定义ant任务 调用其中一个库。


8
2018-06-20 10:47





僵尸问题但张贴 https://gist.github.com/garethr/878364 如果我再次自己搜索它。粘贴Gist内容以防万一。

<project name="{{ name }}" default="help" basedir=".">
<property name="username" value="{{ username }}"/>
<property name="host" value="{{ host }}"/>
<property name="dir" value="/srv/{{ path }}/"/>

<tstamp>
    <format property="TODAY_UK" pattern="yyyyMMddhhmmss" locale="en,UK"/>
</tstamp>

<target name="help" description="show available commands" >
<exec executable="ant" dir="." failonerror="true">
<arg value="-p"/>
</exec>
</target>
<target name="deploy-to" description="show where we are deploying to" >
<echo>${username}@${host}:${dir}</echo>
</target>

<target name="deploy" description="deploy usng rsync" >
<exec executable="rsync" dir="." failonerror="true">
<arg value="-r"/>
<arg value="."/>
<arg value="${username}@${host}:${dir}"/>
<arg value="--exclude-from=rsync.excludes"/>
<arg value="-v"/>
</exec>
</target>

<target name="deploy-test" description="test deploy usng rsync with the dry run flag set" >
<exec executable="rsync" dir="." failonerror="true">
<arg value="-r"/>
<arg value="."/>
<arg value="${username}@${host}:${dir}"/>
<arg value="--exclude-from=rsync.excludes"/>
<arg value="--dry-run"/>
<arg value="-v"/>
</exec>
</target>

<target name="backup" description="backup site" >
<exec executable="scp" dir="." failonerror="true">
<arg value="-r"/>
<arg value="${username}@${host}:${dir}"/>
<arg value="backups/${TODAY_UK}"/>
</exec>
</target>

</project>

7
2018-01-06 15:59