I'm adding some extra sources to my Maven project and until now all is working well. I just want to make the extra source selection a little more more generic, because today I have something like:
<source>client/plugins/plug1/classes</source>
<source>client/plugins/plug2/classes</source>
<source>client/plugins/plug3/classes</source>
<source>client/plugins/plug4/classes</source>
<source>client/plugins/plug5/classes</source>
...
And I want to do it in this way:
<source>client/plugins/**/classes</source>
That's because some developers do not have all the plugins under their working space, and I don't want to modify my pom.xml
in each dev environment.
Unfortunately that pattern doesn't work -at least in Eclipse- because the folders are not marked as source. I made a little research and I saw that Maven uses the Ant patterns but it is not working.
Could you please tell me if it is possible to use that convention in <sources>
definition?
No, this is not possible.
The
sources
attribute of thebuild-helper-maven-plugin:add-source
goal is aFile
array, which means that every source must be aFile
, hence you can't use an Ant path pattern. The plugin will literally add the fileclient/plugins/**/classes
as a source directory (and since it doesn't exist, nothing will happen). This is the logs that I had when I tested it:But there's the matter of why you would want such a thing. It isn't clear from your question where are those "plugins" coming from but you shouldn't be in that situation. Each plugin should probably be a separate module of a multi-module Maven project. This way, each plugin will handle its build and you can add a dependency on those modules.