Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to preserve exec file in ant copy task

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

like image 855
Neelam Sharma Avatar asked Jan 30 '13 12:01

Neelam Sharma


People also ask

What is FileSet in Ant?

A FileSet is a group of files. These files can be found in a directory tree starting in a base directory and are matched by patterns taken from a number of PatternSets and Selectors. PatternSets can be specified as nested <patternset> elements.

What is PathElement in ant?

Path: This object represents a path as used by CLASSPATH or PATH environment variable. A path might also be described as a collection of unique filesystem resources. and PathElement: Helper class, holds the nested <pathelement> values.

What is target in Ant build?

A target is a container of tasks and datatypes that cooperate to reach a desired state during the build process. Targets can depend on other targets and Apache Ant ensures that these other targets have been executed before the current target.


1 Answers

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).

like image 78
trojanfoe Avatar answered Sep 28 '22 03:09

trojanfoe