You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Bruno Medeiros <br...@gmail.com> on 2010/05/13 19:48:31 UTC

How to echo the empty directories of a fileset ?

Hello. If I do something like this:

	<copy todir="${destination.dir}" verbose="true" >
		<fileset dir="${projects.dir}/" >
			<include name="*" />
		</fileset>
	</copy>

and projects.dir has some empty directories, then those directories
will be copied to destination.dir .
Is this normal behavior? (It seems strange to me that a fileset would
contain empty directories)
And if that's the case, how can I echo the empty directories of a
fileset? I am familiar with this:

	<pathconvert refid="my.fileset" property="my.files.list"> pathsep=","/>
	<echo message="${my.files.list}"/>

But it only prints the files of the fileset, not the directories.

Regards,
Bruno

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


RE: How to echo the empty directories of a fileset ?

Posted by Mario Madunic <Ma...@newflyer.com>.
Isn't there a new task named resourcecount. Maybe you could use this in conjunction with a test and if the resourcecount is 0 then echo it is empty. Or am I missing what you are trying to do?


Marijan (Mario) Madunic
Publishing Specialist
New Flyer Industries

-----Original Message-----
From: Bruno Medeiros [mailto:bruno.do.medeiros@gmail.com] 
Sent: Thursday, May 13, 2010 12:49 PM
To: user@ant.apache.org
Subject: How to echo the empty directories of a fileset ?

Hello. If I do something like this:

	<copy todir="${destination.dir}" verbose="true" >
		<fileset dir="${projects.dir}/" >
			<include name="*" />
		</fileset>
	</copy>

and projects.dir has some empty directories, then those directories
will be copied to destination.dir .
Is this normal behavior? (It seems strange to me that a fileset would
contain empty directories)
And if that's the case, how can I echo the empty directories of a
fileset? I am familiar with this:

	<pathconvert refid="my.fileset" property="my.files.list"> pathsep=","/>
	<echo message="${my.files.list}"/>

But it only prints the files of the fileset, not the directories.

Regards,
Bruno

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


--------------------------------------------------------------------
Please consider the environment before printing this e-mail.

CONFIDENTIALITY STATEMENT: This communication (and  any and all information or material transmitted with this communication) is confidential, may be privileged and is intended only for the use of the intended recipient. If you are not the intended recipient, any review, retransmission, circulation, distribution, reproduction, conversion to hard copy, copying or other use of this communication, information or material is strictly prohibited and may be illegal. If you received this communication in error or if it is forwarded to you without the express authorization of New Flyer, please notify us immediately by telephone or by return email and permanently delete the communication, information and material from any computer, disk drive, diskette or other storage device or media. Thank you.


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


Re: How to echo the empty directories of a fileset ?

Posted by Bruno Medeiros <br...@gmail.com>.
On Mon, May 17, 2010 at 4:06 PM, Matt Benson <gu...@gmail.com> wrote:
>
> On May 15, 2010, at 4:30 AM, Bruno Medeiros wrote:
>
>> On Thu, May 13, 2010 at 7:14 PM, Matt Benson <gu...@gmail.com> wrote:
>>>
>>> On May 13, 2010, at 12:48 PM, Bruno Medeiros wrote:
>>>
>>>> Hello. If I do something like this:
>>>>
>>>>       <copy todir="${destination.dir}" verbose="true" >
>>>>               <fileset dir="${projects.dir}/" >
>>>>                       <include name="*" />
>>>>               </fileset>
>>>>       </copy>
>>>>
>>>> and projects.dir has some empty directories, then those directories
>>>> will be copied to destination.dir .
>>>> Is this normal behavior? (It seems strange to me that a fileset would
>>>> contain empty directories)
>>>> And if that's the case, how can I echo the empty directories of a
>>>> fileset? I am familiar with this:
>>>>
>>>>       <pathconvert refid="my.fileset" property="my.files.list">
>>>> pathsep=","/>
>>>>       <echo message="${my.files.list}"/>
>>>>
>>>> But it only prints the files of the fileset, not the directories.
>>>>
>>>
>>> If you simply want to copy a fileset and not get empty directories,
>>> <copy>
>>> has an includeemptydirs attribute which defaults to true.
>>>
>>> -Matt
>>>
>>
>> The copy code is fine and is just to exemply how I found this fileset
>> behavior.
>> What I want to know is exactly what the title says, how can I echo the
>> empty directories of a fileset? That is possible, right?
>
> Anything is possible... :)  Off the top of my head nothing simple springs to
> mind.  The easiest thing would probably be to write a custom selector (you
> can script them, if memory serves) to select directories with no children.
>
> A hack would be to copy a structure without including empty directories,
> then compare for relative paths that exist in the source structure and not
> the target structure, but that seems a little heavy to me in terms of
> processing required.
>
> HTH,
> Matt
>

I meant possible in a straightforward, direct way. As I suspected, I
guess its not possible: it seems this knowledge that <fileset> has of
empty directories is kinda of a hidden thing that only <copy> (and
perhaps a few other tasks) can make use of.
That being the case, I would rather not try to workaround this quirk,
I'll rather use the other resource types instead, which hopefully are
"purer" in behavior. I took a better look at them, and it seems
wrapping a <fileset> around a <resources> removes the quirky behavior
(ie, keeping the hidden empty directories), so that's good enough for
me.

Thx anyway,
Bruno

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


Re: How to echo the empty directories of a fileset ?

Posted by Matt Benson <gu...@gmail.com>.
On May 15, 2010, at 4:30 AM, Bruno Medeiros wrote:

> On Thu, May 13, 2010 at 7:14 PM, Matt Benson <gu...@gmail.com>  
> wrote:
>> On May 13, 2010, at 12:48 PM, Bruno Medeiros wrote:
>>
>>> Hello. If I do something like this:
>>>
>>>        <copy todir="${destination.dir}" verbose="true" >
>>>                <fileset dir="${projects.dir}/" >
>>>                        <include name="*" />
>>>                </fileset>
>>>        </copy>
>>>
>>> and projects.dir has some empty directories, then those directories
>>> will be copied to destination.dir .
>>> Is this normal behavior? (It seems strange to me that a fileset  
>>> would
>>> contain empty directories)
>>> And if that's the case, how can I echo the empty directories of a
>>> fileset? I am familiar with this:
>>>
>>>        <pathconvert refid="my.fileset" property="my.files.list">
>>> pathsep=","/>
>>>        <echo message="${my.files.list}"/>
>>>
>>> But it only prints the files of the fileset, not the directories.
>>>
>>
>> If you simply want to copy a fileset and not get empty  
>> directories, <copy>
>> has an includeemptydirs attribute which defaults to true.
>>
>> -Matt
>>
>
> The copy code is fine and is just to exemply how I found this  
> fileset behavior.
> What I want to know is exactly what the title says, how can I echo the
> empty directories of a fileset? That is possible, right?

Anything is possible... :)  Off the top of my head nothing simple  
springs to mind.  The easiest thing would probably be to write a  
custom selector (you can script them, if memory serves) to select  
directories with no children.

A hack would be to copy a structure without including empty  
directories, then compare for relative paths that exist in the source  
structure and not the target structure, but that seems a little heavy  
to me in terms of processing required.

HTH,
Matt

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


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


Re: How to echo the empty directories of a fileset ?

Posted by Bruno Medeiros <br...@gmail.com>.
On Thu, May 13, 2010 at 7:14 PM, Matt Benson <gu...@gmail.com> wrote:
> On May 13, 2010, at 12:48 PM, Bruno Medeiros wrote:
>
>> Hello. If I do something like this:
>>
>>        <copy todir="${destination.dir}" verbose="true" >
>>                <fileset dir="${projects.dir}/" >
>>                        <include name="*" />
>>                </fileset>
>>        </copy>
>>
>> and projects.dir has some empty directories, then those directories
>> will be copied to destination.dir .
>> Is this normal behavior? (It seems strange to me that a fileset would
>> contain empty directories)
>> And if that's the case, how can I echo the empty directories of a
>> fileset? I am familiar with this:
>>
>>        <pathconvert refid="my.fileset" property="my.files.list">
>> pathsep=","/>
>>        <echo message="${my.files.list}"/>
>>
>> But it only prints the files of the fileset, not the directories.
>>
>
> If you simply want to copy a fileset and not get empty directories, <copy>
> has an includeemptydirs attribute which defaults to true.
>
> -Matt
>

The copy code is fine and is just to exemply how I found this fileset behavior.
What I want to know is exactly what the title says, how can I echo the
empty directories of a fileset? That is possible, right?

Bruno

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


Re: How to echo the empty directories of a fileset ?

Posted by Matt Benson <gu...@gmail.com>.
On May 13, 2010, at 12:48 PM, Bruno Medeiros wrote:

> Hello. If I do something like this:
>
> 	<copy todir="${destination.dir}" verbose="true" >
> 		<fileset dir="${projects.dir}/" >
> 			<include name="*" />
> 		</fileset>
> 	</copy>
>
> and projects.dir has some empty directories, then those directories
> will be copied to destination.dir .
> Is this normal behavior? (It seems strange to me that a fileset would
> contain empty directories)
> And if that's the case, how can I echo the empty directories of a
> fileset? I am familiar with this:
>
> 	<pathconvert refid="my.fileset" property="my.files.list">  
> pathsep=","/>
> 	<echo message="${my.files.list}"/>
>
> But it only prints the files of the fileset, not the directories.
>

If you simply want to copy a fileset and not get empty directories,  
<copy> has an includeemptydirs attribute which defaults to true.

-Matt

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


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