I'm writing an ant build.xml file which does the following:
An extract of the code from build.xml:
<!-- Unzip SDK to a temporary directory -->
<unzip src="${zipFile}" dest="tmp"/>
<!-- pull in the files from another directory -->
<copy todir="tmp/someDirectory" >
<fileset dir="${addedFiles}" />
</copy>
<!-- Zip up modified SDK -->
<zip destfile="${destDir}" basedir="tmp"/>
This all works perfectly, except that the permissions set for the zipped files prior to running the ant build are lost in the zip file created by the ant build. For example, files which were previously executable no longer are.
So my question: is it possible to use ant to add files to a zip archive without destroying the permissions of the already present files?
I'm using Ant 1.7.1
You can't get the zip task to preserve file permissions, but you can set them explicitly:
<zip destfile="installer.zip" >
<zipfileset filemode="755" dir="../" includes="artisan/install.*" />
</zip>
(This worked for me on Windows and OSX)
I encountered same issue when using Ant unzip target:
<unzip src="${project.build.directory}/${project.build.finalName}.zip" dest="${user.home}/apps" overwrite="true" />
The permission of shell scripts inside the zip file was lost when using the unzip target above.
After some investigation, I use the follow 'exec' ant target with unzip command line parameters, it worked.
<!-- Use command line unzip to keep file permissions -->
<exec executable="unzip" spawn="true">
<arg line="-o ${project.build.directory}/${project.build.finalName}.zip -d ${user.home}/apps" />
</exec>
I hope this can help someone else when encountering this kind of issues.
Thanks, J
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With