You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by MikeO <mi...@cibc.ca> on 2007/11/02 17:52:23 UTC

Converting path to fileset issue.

What I am trying to do is have the user specify in an external properties
file any jar files needed in the compilation process. Since a folder may
contain several jar files, I thought it would be simpler to have the user
just specify the folder that jar file is in. The user can specify several
folders in the property in this format:

classpath.jar.include=lib;lib\ext;lib\config

However, if I just include that string in a path like:

<path id="user.jar.include" path="${classpath.jar.include}" />	

then the jar files are not found. So what I wanted to do was convert this
path into a fileset, which would include the jar files. However, I am unable
to get the pathtoconvert task to work properly for some reason. When I am
debugging the script, it seems that the fileset that is made from the
pathtoconvert task is empty.
If the classpath.jar.include property is set to
C:\a\b\c\d\lib;C:\a\b\c\d\lib\ext (for example), would the following
pathtofileset task be correct?

<path id="user.jar.include" path="${classpath.jar.include}" />	
<pathtofileset name="fileset.jar.include" pathrefid="user.jar.include"
dir="C:\a\b\c\d"/>

I am also assuming that the fileset.jar.include value set for the name
attribute is now the refid for that fileset. Would I use that handle in a
similar fashion to this?

<path id="project.class.path">
   <fileset refid="fileset.jar.include" />
</path>

What am I doing wrong? Am I even on the right track? Thanks in advance.
-- 
View this message in context: http://www.nabble.com/Converting-path-to-fileset-issue.-tf4738646.html#a13551372
Sent from the Ant - Dev mailing list archive at Nabble.com.


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


Re: Converting path to fileset issue.

Posted by MikeO <mi...@cibc.ca>.


Dominique Devienne-2 wrote:
> 
> My mistake. You must use comma indeed, instead of semi-colon.
> 
> The 'includes' attribute of <fileset> *does* accept of comma-separated
> list of patterns (make sure to use forward slashes, even on windows),
> which *must* be relative to the fileset's dir attribute. You are
> referring to the <include> nested-element of <fileset> (and
> <patternset>) which indeed accepts a single pattern only.
> 
> --DD
> 

Excellent. Thank you so much. I had no idea it could work like that. Problem
solved!

-- 
View this message in context: http://www.nabble.com/Converting-path-to-fileset-issue.-tf4738646.html#a13592797
Sent from the Ant - Dev mailing list archive at Nabble.com.


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


Re: Converting path to fileset issue.

Posted by Dominique Devienne <dd...@gmail.com>.
On 11/5/07, MikeO <mi...@cibc.ca> wrote:
> I tried something similar before, but from my experience, it seems that the
> fileset task doesn't like dealing with semi-colon separated lists, and only
> deals with single files/directories.

My mistake. You must use comma indeed, instead of semi-colon.

The 'includes' attribute of <fileset> *does* accept of comma-separated
list of patterns (make sure to use forward slashes, even on windows),
which *must* be relative to the fileset's dir attribute. You are
referring to the <include> nested-element of <fileset> (and
<patternset>) which indeed accepts a single pattern only.

--DD

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


Re: Converting path to fileset issue.

Posted by MikeO <mi...@cibc.ca>.
This doesn't seem to be working for me. I am printing out the classpath
(using ant-contrib) with this code after the path task:

<pathconvert targetos="windows" property="printPath"
refid="project.class.path" pathsep=";" />
<echo> Your classpath: ${printPath}</echo>

and it displays nothing.

I tried something similar before, but from my experience, it seems that the
fileset task doesn't like dealing with semi-colon separated lists, and only
deals with single files/directories. In other words, this would work if my
properties file said:

classpath.jar.include=lib/*.jar

but once you add in a ; it no longer works. I think this is because fileset
is trying to treat the string as a single filename, rather than a list.
Maybe this works in later versions of ant? Right now, I am using ant 1.7.0. 

Thanks again,

Mike.


Dominique Devienne-2 wrote:
> 
> You're better off leveraging the includes attribute of fileset in this
> case IMHO.
> 
> ---- env.properties ----
> classpath.jar.include = \
>   lib/*.jar;\
>   lib/ext/*.jar;\
>   lib/config/*.jar
> 
> ---- build.xml extract ---
> <properties file="env.properties" />
> <path id="project.class.path">
>   <fileset dir="." includes="${classpath.jar.include}" />
> </path>
> 
> Forces to "list" all jars (well, uses patterns, so not exactly list),
> but specifying it this way is better anyway I think. --DD
> 
> PS: Note the use of forward slashes in .properties. Always prefer
> forward slashes in Ant.
> 
> 

-- 
View this message in context: http://www.nabble.com/Converting-path-to-fileset-issue.-tf4738646.html#a13589882
Sent from the Ant - Dev mailing list archive at Nabble.com.


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


Re: Converting path to fileset issue.

Posted by Dominique Devienne <dd...@gmail.com>.
On 11/2/07, MikeO <mi...@cibc.ca> wrote:
> classpath.jar.include=lib;lib\ext;lib\config
> What am I doing wrong? Am I even on the right track? Thanks in advance.

You're better off leveraging the includes attribute of fileset in this
case IMHO.

---- env.properties ----
classpath.jar.include = \
  lib/*.jar;\
  lib/ext/*.jar;\
  lib/config/*.jar

---- build.xml extract ---
<properties file="env.properties" />
<path id="project.class.path">
  <fileset dir="." includes="${classpath.jar.include}" />
</path>

Forces to "list" all jars (well, uses patterns, so not exactly list),
but specifying it this way is better anyway I think. --DD

PS: Note the use of forward slashes in .properties. Always prefer
forward slashes in Ant.

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