, but I would really...">

Is there an ant task that can copy without losing access rights

I know that I can <exec executable="cp" failonerror="true">, but I would really have a task that I can call from any OS that can use all (or at least most) of the attributes in copy, but which does not suck unix permissions.

I am wondering if there is a solution there, or I will have to write my own copy2.

As I was afraid, there is nothing “off the shelf”. We have this code, but it only processes a directory to copy a directory or file to a copy of the file, has custom attributes and does not make any other neat copies.

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

I also wrote this.

<!-- ==================================================================== -->
<!-- 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>
+5
source share
2 answers

. Ant, , JRE. Ant

Java 7 , , , Ant . , , , , Ant Java 5 1.9.

, , , ?

+3
+2

All Articles