On 9/13/06, Morgovsky, Alexander (US - Glen Mills) <[EMAIL PROTECTED]>
wrote:
>
>
>
>
> Thanks. What I am looking for is a way to iterate over the files in a
> directory. For example, if I have the structure:
>
> A
> -src
> -A.java
> -B.java
> -C.java
>
> I want to do something like:
> FileSet a = ${project.src.directory}
> Iterator b=a.getIterator();
> While(e=0; b has more elements){
> file d=.getAt(e)
> }
>
> Also, for FileSet, I want to be able to specify inclusions/exclusions.
> How
> can I achieve this using Java code? Thanks.
>
>
> This message (including any attachments) contains confidential
> information
> intended for a specific individual and purpose, and is protected by law.
> If
> you are not the intended recipient, you should delete this message.
>
>
> Any disclosure, copying, or distribution of this message, or the taking
> of
> any action based on it, is strictly prohibited. [v.E.1]
>
Good day to you, Alexander,
AFAIK, the common way maven apache plugins handles that, is by using
org.apache.maven.shared.model.fileset.FileSet, and
org.codehaus.plexus.util.DirectoryScanner. But you may also want to take a
look at plexus-utils for more functionalities that you may need :-)
Anyway, the FileSet i mentioned takes care of your inclusions/exclusions.
Thus, you can declare something like this
/**
* @parameter
*/
private List filesets;
within your Mojo so that you can configure your includes and excludes (see
[1] since the code snippet above was taken from CleanMojo) :-)
After getting those FileSets, you can now configure your DirectoryScanner
given the attributes of your FileSets, so that you can use that
DirecotryScanner to do a scan (to find the files that complies with your
includes and exludes). From then on, you can now retrieve the included files
for whatever process you may need them (you may want to take a look at
ResourcesMojo for an example on how it used FileSets and DirectoryScanner.
Note: Resources is a subclass of FileSet).
I hope I answered your question :-)
Cheers,
Franz
[1]
http://people.apache.org/~epunzalan/maven-clean-plugin/examples/delete_additional_files.html
--
View this message in context:
http://www.nabble.com/File-handling-in-Mojo%27s-tf2262210.html#a6298636
Sent from the Maven - Users forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]