Any analog of rsync for Ant?

自闭症网瘾萝莉.ら 提交于 2019-12-04 19:23:06

问题


I need some analog of rsync for ant. The issue is to copy files from source directory to the set of subdirectories that was previously accomplished with script

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

Thanks for any help


回答1:


You can use exec to call rsync from Ant, you could use the java task to call Jarsync or java-sync or you could create a custom ant task to call either of those libraries.




回答2:


Zombie question but posting https://gist.github.com/garethr/878364 in case I ever search for it myself again. Pasting Gist content in case something something.

<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>


来源:https://stackoverflow.com/questions/11116363/any-analog-of-rsync-for-ant

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!