• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3950
  • Last Modified:

ANT: Files from multiple directories in a single fileset?

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
stefarg
Asked:
stefarg
1 Solution
 
CEHJCommented:
Sounds like you need a PatternSet. You can reuse this, referring to it by id:

http://ant.apache.org/manual/CoreTypes/patternset.html
0
 
stefargAuthor Commented:
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
 
CEHJCommented:
I think that should possibly be more like:

<target name="tester">
      <copy todir="D:/temp">
            <fileset>
                  <patternset refid="testpattern"/>
            </fileset>
      </copy>
</target>
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
stefargAuthor Commented:
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
 
CEHJCommented:
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
 
stefargAuthor Commented:
Thanks again for reply but the when I use a directory I can't span multiple directories.

Any other ideas?
0
 
CEHJCommented:
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
 
aozarovCommented:
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
 
stefargAuthor Commented:
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
 
CEHJCommented:
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
 
stefargAuthor Commented:
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
 
stefargAuthor Commented:
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
 
stefargAuthor Commented:
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
 
CEHJCommented:
>>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
 
moduloCommented:
PAQed with points refunded (350)

modulo
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now