You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Holger Rauch <ho...@heitec.de> on 2006/05/10 15:07:18 UTC
Neither dirset nor fileset with type selector seem to select directories
Hi!
I've created the following simple directory structure for testing purposes.
I would like to see only dirs below test ("blah" and "blubber") in my
dirset/fileset. The Ant version I'm using is 1.6.5 in conjunction with
JDK 1.5.0_06 on Linux:
test (dir)
|--> blah (dir)
|--> blubber (dir)
|--> hallo (file)
I would like to select only directories, and this, according to the Ant
manual, is possible using either
- dirsets or
- filesets in conjunction with selectors
Given the following simple build file
----------------------------------------
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="test" basedir="." default="pretest">
<target name="pretest">
<dirset id="all-dir" dir="test" />
<property name="myprop" refid="all-dir" />
<echo message="myprop = ${myprop}" />
</target>
</project>
------------------------------------------
the output I get is:
============================
Buildfile: mytest.xml
pretest:
[echo] myprop = hallo
BUILD SUCCESSFUL
Total time: 2 seconds
============================
When using a fileset in conjunction with selectors instead of the dirset,
like
<fileset id="all-dir" dir="test">
<type type="dir" />
</fileset>
the output is
Buildfile: mytest.xml
pretest:
[echo] myprop =
BUILD SUCCESSFUL
Total time: 2 seconds
===> myprop is EMPTY!
Obvious question: Why do neither of those two methods yield the desired
result?
Thanks in advance for any info!
Kind regards,
Holger
Re: Neither dirset nor fileset with type selector seem to select directories
Posted by Holger Rauch <ho...@heitec.de>.
Hi,
first of all, thanks to both Scot and Matt for responding so quickly to my
message. I tried to incorporate your suggestions into my buildfile and, to
be honest, the results are still somewhat interesting:
a) The combination of <fileset> and a <type> selector doesn't seem to work
at all, i.e. the property "myprop" is ALWAYS empty, no matter whether a
<path> wrapper element is used or not and also regardless of whether
<pathconvert> is used or <property refid="" />
<fileset dir="test">
<type type="dir"
</fileset>
If it worked, I would prefer the <fileset>/selector combo since it
would enable to combine various selectors which is useful for choosing
directories in more complex path structures.
Any idea why this particular <fileset>/selector combo doesn't work
at all???
b) <dirset> yields the correct result with or without the <path> wrapper
element if <pathconvert> is used instead of <property refid="" />
c) When using <dirset> in conjunction with <property refid="" />, then the
<path> wrapper element is needed (as Scot suggested), otherwise myprop is
empty.
It would generally help a lot if Ant was telling how it's selecting
files/dirs behind the scenes, especially when taking into accound Matt's
hint with the toString() method. But, unfortunately, not even "-d" seems to
help here. Is there any other way to get more info from Ant???
Here's the path structure I was playing with and my modified build file
(most stuff commented out, so that it can be selectively reenabled for
testing purposes).
> >Holger Rauch wrote:
> [...]
> >>
> >>test (dir)
> >> |--> blah (dir)
> >> |--> blubber (dir)
> >> |--> hallo (file)
> [...]
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="test" basedir="." default="pretest">
<target name="pretest">
<!-- Doesn't work (value of myprop is empty) regardless
of the task used to set the property's value
<path id="all-dir">
<fileset dir="test">
<type type="dir" />
</fileset>
</path>
-->
<!-- Doesn't work either
<fileset id="all-dir" dir="test">
<type type="dir" />
</fileset>
-->
<!-- Works in conjunction with pathconvert
but NOT in conjunction with <property refid="" />!!!
<dirset id="all-dir" dir="test" />
-->
<!-- Works with both <property refid="" /> and pathconvert!!!
<path id="all-dir">
<dirset dir="test" />
</path>
-->
<!--
<pathconvert property="myprop" pathsep=" " refid="all-dir" />
-->
<!--
<property name="myprop" refid="all-dir" />
-->
<echo message="myprop = ${myprop}" />
</target>
</project>
Thanks in advance for any advice!
Kind regards,
Holger
Re: Neither dirset nor fileset with type selector seem to select
directories
Posted by "Scot P. Floess" <fl...@mindspring.com>.
Try this:
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="test" basedir="." default="pretest">
<target name="pretest">
<path id = "all-dir">
<dirset dir="test"/>
</path>
<property name="myprop" refid="all-dir" />
<echo message="myprop = ${myprop}" />
</target>
</project>
Not sure what's going on when you simply use dirset with an id... Your
example threw me for a second :)
Scot P. Floess wrote:
> Holger:
>
> Very odd indeed...I am looking at this and get back to you...but sure
> enough...dirset yields the file instead of the directories...
>
> Holger Rauch wrote:
>> Hi!
>>
>> I've created the following simple directory structure for testing
>> purposes.
>> I would like to see only dirs below test ("blah" and "blubber") in my
>> dirset/fileset. The Ant version I'm using is 1.6.5 in conjunction with
>> JDK 1.5.0_06 on Linux:
>>
>> test (dir)
>> |--> blah (dir)
>> |--> blubber (dir)
>> |--> hallo (file)
>>
>> I would like to select only directories, and this, according to the Ant
>> manual, is possible using either
>>
>> - dirsets or
>> - filesets in conjunction with selectors
>>
>> Given the following simple build file
>>
>> ----------------------------------------
>>
>> <?xml version="1.0" encoding="iso-8859-1"?>
>>
>> <project name="test" basedir="." default="pretest">
>>
>> <target name="pretest">
>> <dirset id="all-dir" dir="test" />
>> <property name="myprop" refid="all-dir" />
>> <echo message="myprop = ${myprop}" />
>> </target>
>>
>> </project>
>>
>> ------------------------------------------
>>
>> the output I get is:
>>
>> ============================
>>
>> Buildfile: mytest.xml
>>
>> pretest:
>> [echo] myprop = hallo
>>
>> BUILD SUCCESSFUL
>> Total time: 2 seconds
>>
>> ============================
>>
>> When using a fileset in conjunction with selectors instead of the
>> dirset,
>> like
>>
>> <fileset id="all-dir" dir="test">
>> <type type="dir" />
>> </fileset>
>>
>> the output is
>>
>> Buildfile: mytest.xml
>>
>> pretest:
>> [echo] myprop =
>> BUILD SUCCESSFUL
>> Total time: 2 seconds
>>
>> ===> myprop is EMPTY!
>>
>> Obvious question: Why do neither of those two methods yield the desired
>> result?
>>
>> Thanks in advance for any info!
>>
>> Kind regards,
>>
>> Holger
>>
>
--
Scot P. Floess
27 Lake Royale
Louisburg, NC 27549
252-478-8087 (Home)
919-754-4592 (Work)
Chief Architect JPlate http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Neither dirset nor fileset with type selector seem to select
directories
Posted by "Scot P. Floess" <fl...@mindspring.com>.
Holger:
Very odd indeed...I am looking at this and get back to you...but sure
enough...dirset yields the file instead of the directories...
Holger Rauch wrote:
> Hi!
>
> I've created the following simple directory structure for testing purposes.
> I would like to see only dirs below test ("blah" and "blubber") in my
> dirset/fileset. The Ant version I'm using is 1.6.5 in conjunction with
> JDK 1.5.0_06 on Linux:
>
> test (dir)
> |--> blah (dir)
> |--> blubber (dir)
> |--> hallo (file)
>
> I would like to select only directories, and this, according to the Ant
> manual, is possible using either
>
> - dirsets or
> - filesets in conjunction with selectors
>
> Given the following simple build file
>
> ----------------------------------------
>
> <?xml version="1.0" encoding="iso-8859-1"?>
>
> <project name="test" basedir="." default="pretest">
>
> <target name="pretest">
> <dirset id="all-dir" dir="test" />
> <property name="myprop" refid="all-dir" />
> <echo message="myprop = ${myprop}" />
> </target>
>
> </project>
>
> ------------------------------------------
>
> the output I get is:
>
> ============================
>
> Buildfile: mytest.xml
>
> pretest:
> [echo] myprop = hallo
>
> BUILD SUCCESSFUL
> Total time: 2 seconds
>
> ============================
>
> When using a fileset in conjunction with selectors instead of the dirset,
> like
>
> <fileset id="all-dir" dir="test">
> <type type="dir" />
> </fileset>
>
> the output is
>
> Buildfile: mytest.xml
>
> pretest:
> [echo] myprop =
>
> BUILD SUCCESSFUL
> Total time: 2 seconds
>
> ===> myprop is EMPTY!
>
> Obvious question: Why do neither of those two methods yield the desired
> result?
>
> Thanks in advance for any info!
>
> Kind regards,
>
> Holger
>
--
Scot P. Floess
27 Lake Royale
Louisburg, NC 27549
252-478-8087 (Home)
919-754-4592 (Work)
Chief Architect JPlate http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Neither dirset nor fileset with type selector seem to select directories
Posted by Matt Benson <gu...@yahoo.com>.
Holger: the <property refid="" /> notation you are
using is not -really- recommended. IIRC is is noted
as experimental in the code; while it is not going
anywhere, in this case you can see it yields
less-than-optimal results. It calls toString() on the
referenced object. DirSet inherits its toString()
implementation from AbstractFileSet, which returns a
Windows-style path of included *files*. I would urge
you to use the pathconvert task instead; it will do
what you want here.
HTH,
Matt
--- Holger Rauch <ho...@heitec.de> wrote:
> Hi!
>
> I've created the following simple directory
> structure for testing purposes.
> I would like to see only dirs below test ("blah" and
> "blubber") in my
> dirset/fileset. The Ant version I'm using is 1.6.5
> in conjunction with
> JDK 1.5.0_06 on Linux:
[snip]
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org