Gilbert Rebhan wrote:
>Hi,
>
>Matt Benson wrote:
>
>
>>I can't remember the entire context of this
>>discussion... but includes/excludes are used by
>>DirectoryScanner. To include only child "files" of
>>basedir, the correct include pattern is "*". However,
>>this includes directories which are basedir's
>>immediate children. To further restrict the selection
>>to non-directory files, use the <type> selector as
>>well.
>>
>>-Matt
>>
>>
>
>my first post was =
>
>/*
>...
>
>i want to use the DirectoryScanner in an own task.
>
>i want to exclude subdirectories and only including
>the files in the root of basedir.
>
>DirectoryScanner ds = fs.getDirectoryScanner(getProject());
> String[] includes = {"*.*"};
> String[] excludes = {"**\\**"};
> ds.setIncludes(includes);
> ds.setExcludes(excludes);
>String[] names = ds.getIncludedFiles();
>
>
>What are the correct include / exclude patterns to
>include ownly the files in root of basedir but exclude
>all subdirectories and files in subdirectories ?
>
>...
>*/
>
>i want to use it in a selfwritten task not in an
>ant(xml)script
>
>
>
Hello Gilbert,
>Question =
>
>is it possible to use DirecoryScanner standalone or only combined
>with a type selector ?
>
>i believe it's easier to roll my own solution instead of using
>DirectoryScanner combined with a selector.
>
>
>
It is always a matter of taste. I like to use the Ant Apis, which are
well documented, maintained, and stay mostly compatible from version to
version.
<fileset dir="foo/bar">
<and>
<depth max="1"/>
<type type="file"/>
</and>
</fileset>
is what you are looking for. You just need to find out from the code of
AbstractFileSet how to do this programmatically (probably 4 lines of code).
Something like
// assuming variable myProject : current ant project
// myFs : the fileset you are defining
//
AndSelector mySelector = new AndSelector();
mySelector.setProject(myProject);
DepthSelector depthsel = new DepthSelector();
depthsel.setProject(myProject);
deptsel.setMax(1);
mySelector.appendSelector(depthsel);
TypeSelector ts = new TypeSelector();
ts.setType("file");
ts.setProject(myProject);
mySelector.appendSelector(ts);
myFs.addAnd(mySelector);
>Regards, Gilbert
>
>
>
>
Cheers,
Antoine
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]