Sono consapevole che posso <exec executable="cp" failonerror="true">
, tuttavia, preferirei davvero un compito che posso chiamare da qualsiasi sistema operativo che può utilizzare tutti (o almeno la maggior parte) degli attributi a copy
, ma che non elimina le autorizzazioni su unix.Esiste un'attività ant che può copiare senza perdere le autorizzazioni
Mi chiedo se c'è già una soluzione là fuori, o dovrò scrivere il mio copy2
.
Dato che avevo paura, non c'è niente "da scaffale". Abbiamo questo codice, ma gestisce solo la directory in copia di directory o file in copia di file, ha attributi personalizzati, e non fa nessuna delle altre cose belle che fa la copia.
<!-- ==================================================================== -->
<!-- Copy files from A to B -->
<!-- <copy> would do this job, if it weren't such a useless pile of fail -->
<!-- and could manage to preserve execute bits on Linux -->
<!-- ==================================================================== -->
<macrodef name="internal-copydir">
<attribute name="fromdir" default="NOT SET" />
<attribute name="todir" default="NOT SET" />
<sequential>
<if>
<os family="windows" />
<then>
<copy todir="@{todir}">
<fileset dir="@{fromdir}" />
</copy>
</then>
<else>
<exec executable="rsync" failonerror="true">
<arg value="-a" />
<arg value="@{fromdir}/" />
<arg value="@{todir}/" />
</exec>
</else>
</if>
</sequential>
</macrodef>
<!-- ==================================================================== -->
<!-- Copy file from A to B -->
<!-- <copy> would do this job, if it weren't such a useless pile of fail -->
<!-- and could manage to preserve execute bits on Linux -->
<!-- ==================================================================== -->
<macrodef name="internal-copyfile">
<attribute name="file" default="NOT SET" />
<attribute name="tofile" default="NOT SET" />
<sequential>
<if>
<os family="windows" />
<then>
<copy file="@{file}" tofile="@{tofile}"/>
</then>
<else>
<exec executable="cp" failonerror="true">
<arg value="@{file}" />
<arg value="@{tofile}" />
</exec>
</else>
</if>
</sequential>
</macrodef>
Ho scritto anche questo.
<!-- ==================================================================== -->
<!-- Copy file to a directory -->
<!-- <copy> would do this job, if it weren't such a useless pile of fail -->
<!-- and could manage to preserve execute bits on Linux -->
<!-- ==================================================================== -->
<macrodef name="internal-copyfiletodir">
<attribute name="file" default="NOT SET" />
<attribute name="todir" default="NOT SET" />
<sequential>
<if>
<os family="windows" />
<then>
<copy file="@{file}" todir="@{todir}"/>
</then>
<else>
<exec executable="cp" failonerror="true">
<arg value="@{file}" />
<arg value="@{todir}/" />
</exec>
</else>
</if>
</sequential>
</macrodef>