Ich bin mir bewusst, dass ich <exec executable="cp" failonerror="true">
, aber ich würde wirklich lieber eine Aufgabe haben, die ich von jedem Betriebssystem aufrufen kann alle (oder zumindest die meisten) der Attribute zu copy
, aber die Berechtigungen auf Unix nicht wegsaugen.Gibt es eine Ant-Task, die kopieren kann, ohne Berechtigungen zu verlieren
Ich frage mich, ob es schon eine Lösung gibt, oder werde ich meine eigene copy2
schreiben müssen.
Da ich etwas Angst hatte, gibt es nichts "von der Stange". Wir haben diesen Code, aber er behandelt nur Verzeichnis-zu-Verzeichnis-Kopieren oder Datei-zu-Datei-Kopieren, hat benutzerdefinierte Attribute und tut nichts von den anderen netten Dingen, die Kopie macht.
<!-- ==================================================================== -->
<!-- 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>
Ich schrieb dieses auch.
<!-- ==================================================================== -->
<!-- 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>