?
Solved

ANT: Files from multiple directories in a single fileset?

Posted on 2005-04-15
16
Medium Priority
?
3,596 Views
Last Modified: 2012-08-13
Hi All,

I'm using ant 1.6.2 and I want to create a single <fileset> or something similar for a collection of files in multiple directories without a common base directory.  

I deally what I would like is a structure that acts like a path and fileset hybrid i.e. it can span multiple directories and be used by tasks like <copy>.

This is quite important for what I need to do so please help if you can,
Thanks in advance,
Stef
0
Comment
Question by:stefarg
15 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 13791375
Sounds like you need a PatternSet. You can reuse this, referring to it by id:

http://ant.apache.org/manual/CoreTypes/patternset.html
0
 
LVL 1

Author Comment

by:stefarg
ID: 13791908
Hi CEHJ,

That seems very close to what I want but how do I copy files in this element or add it to a classpath (these are probably very stupid questions but it's not obvious to me).

I tried:

<patternset id="testpattern">
      <includesfile name="D:/test-1.0.jar"/>
</patternset>
<target name="tester">
      <path name="test2">
            <patternset refid="testpattern"/>
      </path>
</target>

and

<patternset id="testpattern">
      <includesfile name="D:/test-1.0.jar"/>
</patternset>
<target name="tester">
      <copy todir="D:/temp">
      <patternset refid="testpattern"/>
</copy>
</target>

but both <copy> and <path> complained that they did not support the patternset.

Nearly there I think... Maybe you could help me with this last but :)

Stef
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13791982
I think that should possibly be more like:

<target name="tester">
      <copy todir="D:/temp">
            <fileset>
                  <patternset refid="testpattern"/>
            </fileset>
      </copy>
</target>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:stefarg
ID: 13792000
Unfortunatley now I'm back to a problem I have before:
"No directory speified for fileset"

Any ideas how to get around this?

Thanks again
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13792068
I can't test that at the moment, but the first kludge i'd try is to put a dir in, duplicating one in the PatternSet
0
 
LVL 1

Author Comment

by:stefarg
ID: 13792157
Thanks again for reply but the when I use a directory I can't span multiple directories.

Any other ideas?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13792305
I might have to play around with this later. One thing to try for the moment:

1. Use a FileSet and define it, giving it an id
2. In copy, try using ref-id to refer to it
0
 
LVL 15

Expert Comment

by:aozarov
ID: 13796285
Why not to have the FileSet set to the root of your directories and then filter only
the directories you need by using the FileSet include/exclude or nested patternsets.
0
 
LVL 1

Author Comment

by:stefarg
ID: 13804308
Hi CEHJ ,

I tried using the fileset and using the refid but it still complained about the lack of a directory in the fileset declaration.
Thanks for replying again.

Hi aozarov,

Thanks for the suggestion but the problem is that the files do not have a common base directory.   The files reside on different drives e.g. some on C:, some on D: and more on a remote drive G:.

I'm very interested in finding a solution for this so please keep the suggestions coming.

Stef
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13804676
This would appear to be a weakness in the relation of these entities and their attributes. There may be a way of doing it - there should be, but i can't see it for the moment. One way of solving this would be to post a message in an Ant group or even find the authors of those tasks and ask them.

The site policy here is to encourage outsiders to answer questions here, so you should really try to get them to do that. Failing that, please post the solution here if you find one.
0
 
LVL 1

Author Comment

by:stefarg
ID: 13804795
Ok, thanks for the help, I'll get on to Ant group and see if they can help.  As you suggested I'll post up any responses I get.  
Stef
0
 
LVL 1

Author Comment

by:stefarg
ID: 13822025
Ok, I contacted the apache group via their bugzilla website and they suggested a few alternatives but none of these solved the problem.

The most recent post from them is:
"giving this back to the public, will hopefully be fixed via FileCollections planned
for Ant 1.7."

So  guess I can't really do what I want until version 1.7.

Btw, what's the story with questions like this that can't be resolved?  I'm happy enough to award points for the comments I got, but is there a standard procedure to park questions that cannot be resolved?
0
 
LVL 1

Author Comment

by:stefarg
ID: 13822028
Oops, I forgot the links to bugzilla:

My posting:

http://issues.apache.org/bugzilla/show_bug.cgi?id=34500

which was marked as duplicate of:

http://issues.apache.org/bugzilla/show_bug.cgi?id=18128

Thanks,
Stef
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13822139
>>Btw, what's the story with questions like this that can't be resolved?  

I've tended, in the past, to award *some* marks for effort by getting CS to lower the points if they're too high to all be awarded and retaining the balance myself. It would seem though that my comment:

>> This would appear to be a weakness in the relation of these entities and their attributes.

is pretty near the mark ;-)
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 14617263
PAQed with points refunded (350)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question