<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>pixelnix.com &#187; Apache Ant</title>
	<atom:link href="http://pixelnix.com/category/apache-ant/feed/" rel="self" type="application/rss+xml" />
	<link>http://pixelnix.com</link>
	<description></description>
	<lastBuildDate>Fri, 18 Jun 2010 20:10:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ant Tar task doesn&#8217;t care about your file permissions</title>
		<link>http://pixelnix.com/ant-tar-task-doesnt-care-about-your-file-permissions/</link>
		<comments>http://pixelnix.com/ant-tar-task-doesnt-care-about-your-file-permissions/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 16:36:23 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
				<category><![CDATA[Apache Ant]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://pixelnix.com/?p=55</guid>
		<description><![CDATA[According to the documentation for the Ant Tar task, the &#8220;implicit fileset&#8221; of stuff to be included in your archive can be extended &#8220;to allow control over the access mode, username and groupname.&#8221;  I guess you have to read between the lines (or go with the ol&#8217; trial by error) to find out that not only [...]]]></description>
			<content:encoded><![CDATA[<p>According to <a href="http://ant.apache.org/manual/CoreTasks/tar.html">the documentation</a> for the Ant Tar task, the &#8220;implicit fileset&#8221; of stuff to be included in your archive can be extended &#8220;to allow control over the access mode, username and groupname.&#8221;  I guess you have to read between the lines (or go with the ol&#8217; trial by error) to find out that not only does the implicit fileset provide no control over these properties of your files, it actively reverts the file permissions to some default access mode (644).  Java ftw!</p>
<p>So you are hypothetically deploying your ant-built tar&#8217;d up software release.  Let&#8217;s further say for the sake of argument that it contains some business-critical scripts that must keep their executable mode to be run from cron.  Oops, those files are no longer executable!  You will soon be disappointed at the failure of your cron job to do anything at all, and you may experience some increased email volume accompanied by mild irritation.  If this condition persists, call your doctor, or go back and RTFM again because as the docs imply, this shortcoming can be easily overcome.</p>
<p><span id="more-55"></span>Your job is to identify all the files that need to keep their mode, username, or groupname, and specify said property in a special fileset called tarfileset.  In my ant build, let&#8217;s say the build root is ${builddir} and contains 2 components called src and lib.  I&#8217;ve got one specific file src/foo/exec.sh, and a whole tree of stuff at lib/bar, that have to be executable.  I will need to call the Tar task with two tarfilesets: one to include the executables and set their mode, and a second to include everything else while excluding the executables.</p>
<p>Before:</p>
<pre>&lt;tar destfile="${buildfile.name}"
     basedir="${builddir}"
     longfile="gnu"
     includes="src/**, lib/**"/&gt;</pre>
<p>After:</p>
<pre>&lt;tar destfile="${buildfile.name}" longfile="gnu"&gt;
     &lt;tarfileset dir="${builddir}" filemode="755"&gt;
         &lt;include name="src/foo/exec.sh"/&gt;
         &lt;include name="lib/bar/**"/&gt;
     &lt;/tarfileset&gt;
     &lt;tarfileset dir="${builddir}"&gt;
         &lt;include name="src/**"/&gt;
         &lt;include name="lib/**"/&gt;
         &lt;exclude name="src/foo/exec.sh"/&gt;
         &lt;exclude name="lib/bar/**"/&gt;
     &lt;/tarfileset&gt;
&lt;/tar&gt;</pre>
<p>Works for me!</p>
]]></content:encoded>
			<wfw:commentRss>http://pixelnix.com/ant-tar-task-doesnt-care-about-your-file-permissions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
