[ 
https://issues.apache.org/jira/browse/IO-172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17800503#comment-17800503
 ] 

Elliotte Rusty Harold commented on IO-172:
------------------------------------------

Maven needs this too and has probably two or three implementations of it 
already, mostly forked from ant into different projects at different times with 
subtly different behavior. I'm skeptical that at this point another one could 
be adopted and actually replace what Maven already uses though. 
https://xkcd.com/927/ applies. 

If this is attempted, it needs to start with a serious analysis of existing use 
cases in maven, ant, and elsewhere, and a detailed specification that covers 
the edge cases. A PR without a reasonably formal and normative spec should not 
be accepted. 

> Support directory scanning based on Ant-like include/exclude patterns
> ---------------------------------------------------------------------
>
>                 Key: IO-172
>                 URL: https://issues.apache.org/jira/browse/IO-172
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Utilities
>    Affects Versions: 1.4
>            Reporter: Benjamin Bentmann
>            Priority: Major
>             Fix For: 3.x
>
>
> While IO offers a rich set of {{IOFileFilters}} for finding files in 
> directories, I feel it's missing a concept similar to Ant's file sets. For 
> example, how would one search for files that match "**/*.xml" but that don't 
> match "bad/**"? The sketched example would require to exclude the directory 
> "bad" but only if it is the first component of the path, something like 
> "foo/bad/bar.xml" still needs to be included.
> Given the increased flexibility of [Ant-like 
> patterns|http://ant.apache.org/manual/dirtasks.html#patterns], it would be 
> cool to have something similar to Ant's 
> [{{DirectoryScanner}}|http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/DirectoryScanner.java?view=markup]
>  available in Commons IO.
> Personally, I wouldn't need a full copy of the mentioned class, I believe 
> some method like
> {code:java}
> Collection<String> scanDirectory(File dir, Collection<String> includes, 
> Collection<String> excludes)
> {code}
> in {{FileUtils}} would just suffice. Some default excludes like SCM metadata 
> files could be provided as a public static final and unmodifiable string 
> collection. The return value should include path names relative to the base 
> directory instead of absolute paths (it's easy for the caller to resolve the 
> files against the base directory but it's error-prone to relativize absolute 
> paths).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to