How to preserve exec file in ant copy task
Asked Answered
I

1

7

I have created Java FX bundle for Mac OS X using Ant. It creating bundle with two files - 1. MyApplication.app 2. MyApplication.dmg

I wish to copy both files at other folder, so I wrote command in my build.xml as -

<copy todir="my_new_folder">
   <fileset dir="old_folder\bundles"/>
</copy>

It copying both files successfully at "my_new_folder". But on running .app from "my_new_folder" not launching my application though it is launching from "old_folder" correctly.

On comparing copied app I found that on exec (Unix Executable File) resided at MacOS folder ("Show Package Contents/Contents/MacOS") not preserving, its kind been changing in document file.

How to preserve its kind to Unix Executable File as I am simply executing simple copy directory.

Thanks, Neelam Sharma

Inconsistent answered 30/1, 2013 at 12:6 Comment(0)
P
8

As noted in the ant copy task guide:

Unix Note: File permissions are not retained when files are copied; they end up with the default UMASK permissions instead. This is caused by the lack of any means to query or set file permissions in the current Java runtimes. If you need a permission-preserving copy function, use this instead:

<exec executable="cp" ... >

So, in your case, replace <copy> with:

<exec executable="cp">
    <arg line="-R old_folder/bundles my_new_folder"/>
</exec>

(note that you should use forward slashes, even if this ant script is being used under Windows).

Potion answered 30/1, 2013 at 13:53 Comment(5)
Great Thanks :) It works, we have to end args tag as <arg line="-R old_folder/bundles my_new_folder"/> otherwise everything fine.Inconsistent
I found on copying using exec command some files are showing 'Permission Denied' for some files, how to resolve it?Inconsistent
"lack of any means to query or set file permissions in the current Java runtimes"? I call bullshit, Java 7 has been out for longer than that.Phonologist
@Trejkaz And what if Ant isn't running under Java 7?Potion
Then they could fall back to the behaviour it exhibits under Java 6. My comment was that they say the current Java runtimes, as if it's impossible under all of them.Phonologist

© 2022 - 2024 — McMap. All rights reserved.