You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Stefan Bodewig <bo...@apache.org> on 2010/02/02 06:18:34 UTC

Re: How can I exclude a directory's contents but not the directory itself?

On 2010-02-01, Jonathan Gordon <an...@kinobe.com> wrote:

> Perhaps I wasn't clear enough. At the bottom of my original mail I
> included the following ant snippet, which is NOT correct for my
> particular situation:

>  <sync todir="${build}/tomcat" failonerror="true" overwrite="true">
>             <fileset dir="${tomcat}">
>                 <exclude name="logs/*"/>
>                 <exclude name="work/*"/>
>                 <exclude name="temp/*"/>
>             </fileset>
>         </sync>

> While that's excluding the directory contents, it's also excluding the
> directories themselves. I would like the excluded directories, but not
> their contents. How can I do that?

I think you need includeemptydirs="true" on the <sync> element as well.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: How can I exclude a directory's contents but not the directory itself?

Posted by Jonathan Gordon <an...@kinobe.com>.
On Mon, Feb 1, 2010 at 9:18 PM, Stefan Bodewig <bo...@apache.org> wrote:
> I think you need includeemptydirs="true" on the <sync> element as well.
>
> Stefan

Thanks Stefan! Here's the working snippet in case anyone else runs
into this problem:

<sync todir="${build.tomcat}" failonerror="true" overwrite="true"
includeemptydirs="true">
    <fileset dir="${tomcat.template}">
	<exclude name="logs/**/*"/>
	<exclude name="work/**/*"/>
	<exclude name="temp/**/*"/>
    </fileset>
</sync>

Unfortunately, once I got this worked out I soon stumbled on ant's
difficulty with permissions, which prevents executing tomcat's scripts
in the bin directory.

--- Begin Reference ---
http://ant.apache.org/manual/CoreTasks/copy.html

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 <exec executable="cp" ... > instead.
--- End Reference ---

So I decided to go with a native call to rsync instead:

<exec executable="rsync" os="Linux" >
    <arg line="-avzC --exclude=/logs/* --exclude=/work/*
--exclude=/temp/* ${tomcat.template}/ ${build.tomcat}"/>
</exec>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org