I am developing my custom maven plugin. One of the parameters this plugin shall receive is a fileset. Here's a snippet from the plugin itself:
@Parameter
private FileSet[] filesets;
It compiles well and performs some of the tasks it is intended to. I can also see that the filesets field gets populated when I place such stuff into the pom:
<configuration>
...
<filesets>
<fileset dir="/">
<include name="**/*.*"/>
</fileset>
</filesets>
</configuration>
But in the plugin I do not know how to iterate over the included files. The below code always gives me an empty list:
FileSetManager fileSetManager = new FileSetManager();
fileSetManager.getIncludedFiles(fileset);
Frustrated, I changed my pattern to include all files from the filesystem - but still no success. And the documentation on that topic is just about defining parameters and does not detail how to use them: https://maven.apache.org/guides/plugin/guide-java-plugin-development.html#Parameters
So how can I correctly iterate over the files in a fileset?
edit: If someone believes I gave vague information - it is as much as you can see in the Maven Plugin Development Guide. Seems there are people who can make sense of it.
I found some additional documentation specifically for handling filesets in Maven: https://maven.apache.org/shared/file-management/examples/mojo.html
While this confirms I am on the correct path however still no files are included in the fileset. I drilled this down to the configuration. It needs to look like this:
<configuration>
...
<filesets>
<fileset>
<directory>/</directory>
<include name="**/*.*"/>
</fileset>
</filesets>
</configuration>
Mind the directory
element!