나는 <exec executable="cp" failonerror="true">
을 사용할 수 있다는 것을 알고 있지만 실제로 모든 것을 사용할 수있는 모든 운영 체제 (또는 적어도 대부분)에서 호출 할 수있는 작업을 갖고 있습니다. 의 속성을 copy
으로 변경하지만 유닉스에 대한 권한을 앗아가는 것은 아닙니다.사용 권한을 잃지 않고 복사 할 수있는 개미 작업이 있습니까
이미 해결책이 있는지 궁금하거나 copy2
을 작성해야합니다.
나는 두려워했기 때문에 "선반에서 벗어난"것은 없습니다. 우리는이 코드를 가지고 있지만 디렉터리 복사 또는 파일 복사를위한 디렉터리를 처리하고 사용자 지정 특성을 가지며 복사가 수행하는 다른 멋진 작업을 수행하지 않습니다.
<!-- ==================================================================== -->
<!-- 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>
나는 이것을 작성했습니다.
<!-- ==================================================================== -->
<!-- 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>