You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Scot P. Floess" <fl...@mindspring.com> on 2005/10/19 19:46:07 UTC

Problem converting path to property when a fileset's dir does not exist

I was wondering if anyone can please help me?  I am having trouble 
converting a path to a property when a fileset's dir does not exist.  
The error I received from ant is:  "XXX not found." where XXX is the 
value of LIB_HOME as listed below:
 
   <path id = "JAVA_CLASS_PATH_REF_ID">
        <pathelement location = "${JAVA_CLASSES_HOME}"/>

        <fileset dir = "${LIB_HOME}">
            <include name = "**.jar"/>
        </fileset>

    </path>

    <property name = "JAVA_CLASS_PATH" refid = "JAVA_CLASS_PATH_REF_ID"/>

I have tried a number of different things from using a <selector> to 
examining the Path.java defined in taskdefs.  The source indicates that 
if the directory does not exist, the error I see is raised (well the 
message is raised in an exception).

The only reason I am wanting to do this is to <echo> the path in a 
"print-properties" task I have written.  I considered using 
<echoproperties/> but apparently it does not list paths.

Any and all help is greatly appreciated.

Thanks,

Scot

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087      (home)
919-319-1099 x117 (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: Problem converting path to property when a fileset's dir does not exist

Posted by "Scot P. Floess" <fl...@mindspring.com>.
Dominique:

Thanks for the reply.  I followed the links and sure enough there is 
mention of this issue.  I incorrectly referred to Path.java when, in 
fact, the class I had been looking at was AbstractFileSet.java (as seen 
in the link you provided).

 From what I gather it looks like in 1.7 I can use something called 
<files> (I think its new).  I'll just wait until 1.7 and worry about 
this issue then.  Its really not a "show stopper" for me...more of an 
annoyance but tolerable :D

Thanks for the reply....

Dominique Devienne wrote:

>On 10/19/05, Scot P. Floess <fl...@mindspring.com> wrote:
>  
>
>>I'm not sure why the source behind Path.java is coded to raise and
>>exception if the directory is not there...or more to the point why I
>>can't simply specify to <path> something like "ignore-non-existants"
>>    
>>
>
><path> does ignore non-existent files, but the <fileset> within
>*requires* it's dir attribute to be a valid directory. <path> is
>basically asking <fileset> for the files it selects, and fileset
>complains that it's 'base' directory doesn't exists. I think there's a
>BugZilla request to add an attribute to stop <fileset> from
>complaining when its dir. See
>http://issues.apache.org/bugzilla/show_bug.cgi?id=11270. --DD
>
>  
>

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087      (home)
919-319-1099 x117 (work)

Chief Architect JPlate  http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim


Re: Problem converting path to property when a fileset's dir does not exist

Posted by Dominique Devienne <dd...@gmail.com>.
On 10/19/05, Scot P. Floess <fl...@mindspring.com> wrote:
> I'm not sure why the source behind Path.java is coded to raise and
> exception if the directory is not there...or more to the point why I
> can't simply specify to <path> something like "ignore-non-existants"

<path> does ignore non-existent files, but the <fileset> within
*requires* it's dir attribute to be a valid directory. <path> is
basically asking <fileset> for the files it selects, and fileset
complains that it's 'base' directory doesn't exists. I think there's a
BugZilla request to add an attribute to stop <fileset> from
complaining when its dir. See
http://issues.apache.org/bugzilla/show_bug.cgi?id=11270. --DD

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


Re: Problem converting path to property when a fileset's dir does not exist

Posted by "Scot P. Floess" <fl...@mindspring.com>.
Matt:

Thanks for the quick and prompt reply :)

I considered using targets but was hoping that was not necessary (mostly 
because I dint want to see the extra target(s) listed and printed - just 
being anal).

I'm not sure why the source behind Path.java is coded to raise and 
exception if the directory is not there...or more to the point why I 
can't simply specify to <path> something like "ignore-non-existants"

Anyway, I can try the target solution...thanks :D

Matt Benson wrote:

>--- "Scot P. Floess" <fl...@mindspring.com> wrote:
>
>  
>
>>I was wondering if anyone can please help me?  I am
>>having trouble 
>>converting a path to a property when a fileset's dir
>>does not exist.  
>>    
>>
>[SNIP]
>
>You will have to check for the directory's existence
>before adding the offending fileset to the path.  I
>assume your expectation of pathconvert results for a
>fileset with no matching files (including when the
>directory does not exist) is "".
>
>Example:
>
><project default="foo">
>
>  <path id="base">
>    <fileset dir="a" />
>    <fileset dir="b" />
>    <fileset dir="c" />
>  </path>
>
>  <path id="p" refid="base" />
>
>  <target name="check">
>    <available file="z" type="dir" property="found" />
>  </target>
>
>  <target name="modify" if="found">
>    <path id="p">
>      <path refid="base" />
>      <fileset dir="z" />
>    </path>
>  </target>
>
>  <target name="foo" depends="check,modify">
>    <pathconvert property="result" refid="p"
>                 pathsep="${line.separator}" />
>    <echo>$${result}=${result}</echo>
>  </target>
>
></project>
>
>HTH,
>Matt
>
>
>	
>		
>__________________________________ 
>Yahoo! Mail - PC Magazine Editors' Choice 2005 
>http://mail.yahoo.com
>
>  
>

-- 
Scot P. Floess
27 Lake Royale
Louisburg, NC  27549

252-478-8087      (home)
919-319-1099 x117 (work)

Chief Architect JPlate  http://sourceforge.net/projects/jplate
Chief Architect JavaPIM http://sourceforge.net/projects/javapim


Re: Problem converting path to property when a fileset's dir does not exist

Posted by Matt Benson <gu...@yahoo.com>.
--- "Scot P. Floess" <fl...@mindspring.com> wrote:

> I was wondering if anyone can please help me?  I am
> having trouble 
> converting a path to a property when a fileset's dir
> does not exist.  
[SNIP]

You will have to check for the directory's existence
before adding the offending fileset to the path.  I
assume your expectation of pathconvert results for a
fileset with no matching files (including when the
directory does not exist) is "".

Example:

<project default="foo">

  <path id="base">
    <fileset dir="a" />
    <fileset dir="b" />
    <fileset dir="c" />
  </path>

  <path id="p" refid="base" />

  <target name="check">
    <available file="z" type="dir" property="found" />
  </target>

  <target name="modify" if="found">
    <path id="p">
      <path refid="base" />
      <fileset dir="z" />
    </path>
  </target>

  <target name="foo" depends="check,modify">
    <pathconvert property="result" refid="p"
                 pathsep="${line.separator}" />
    <echo>$${result}=${result}</echo>
  </target>

</project>

HTH,
Matt


	
		
__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

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