You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by ch...@googlemail.com on 2010/02/01 21:57:28 UTC

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

I think your question includes the answer. It's the exclude parameter.

Chris
------Original Message------
From: Jonathan Gordon
To: user@ant.apache.org
ReplyTo: Ant Users List
Subject: How can I exclude a directory's contents but not the directory itself?
Sent: 1 Feb 2010 20:53

I have a directory structure that looks like so:

apache-tomcat-6.0.20/
|-- LICENSE
|-- NOTICE
|-- ...
|-- bin
|   |-- bootstrap.jar
|   |-- ...
|-- conf
|-- lib
|-- logs
|   |-- catalina.2010-01-13.log
|   |-- ...
|-- temp
|-- webapps
`-- work
    |-- Catalina

Using the sync command, I would like to sync everything but the
contents of the logs, temp, and work directories but I would like the
actual directory entries. Such that the synced copy looks like:

apache-tomcat-6.0.20/
|-- LICENSE
|-- NOTICE
|-- ...
|-- bin
|   |-- bootstrap.jar
|   |-- ...
|-- conf
|-- lib
|-- logs
|-- temp
|-- webapps
|-- work

This is what I have so far:

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

But unfortunately that excludes the directories as well. Any ideas?

Jonathan

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



Sent using BlackBerry® from Orange

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


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

Posted by Stefan Bodewig <bo...@apache.org>.
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>.
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?

On 2/1/10, chris.green100@googlemail.com <ch...@googlemail.com> wrote:
> I think your question includes the answer. It's the exclude parameter.
>
> Chris
> ------Original Message------
> From: Jonathan Gordon
> To: user@ant.apache.org
> ReplyTo: Ant Users List
> Subject: How can I exclude a directory's contents but not the directory
> itself?
> Sent: 1 Feb 2010 20:53
>
> I have a directory structure that looks like so:
>
> apache-tomcat-6.0.20/
> |-- LICENSE
> |-- NOTICE
> |-- ...
> |-- bin
> |   |-- bootstrap.jar
> |   |-- ...
> |-- conf
> |-- lib
> |-- logs
> |   |-- catalina.2010-01-13.log
> |   |-- ...
> |-- temp
> |-- webapps
> `-- work
>     |-- Catalina
>
> Using the sync command, I would like to sync everything but the
> contents of the logs, temp, and work directories but I would like the
> actual directory entries. Such that the synced copy looks like:
>
> apache-tomcat-6.0.20/
> |-- LICENSE
> |-- NOTICE
> |-- ...
> |-- bin
> |   |-- bootstrap.jar
> |   |-- ...
> |-- conf
> |-- lib
> |-- logs
> |-- temp
> |-- webapps
> |-- work
>
> This is what I have so far:
>
>         <sync todir="${build}/tomcat" failonerror="true" overwrite="true">
>             <fileset dir="${tomcat}">
>                 <exclude name="logs/*"/>
>                 <exclude name="work/*"/>
>                 <exclude name="temp/*"/>
>             </fileset>
>         </sync>
>
> But unfortunately that excludes the directories as well. Any ideas?
>
> Jonathan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>
> Sent using BlackBerry® from Orange

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