Hi all,

I regularly hit an issue with plugin definition: it is not possible to
define the plugin for children in a parent.
Let me detail a concrete case: i want a parent module to define the plugins
for children modules but I don't want the parent to have these plugins.
A common solution is to skip=true in the parent and skip=false in children
but it requires N (number of children) undesired flag (vs 1 for the parent).
An example is when I do an ui/ parent (pom packaging) i want to define "npm
install && npm run build" using frontend-maven-plugin for all children
(spa1, spa2 etc) but I don't want ui/ module itself to run npm since it
does not contain any module.

Side note: it is the same if you do an images/ subhierarchy or servers/
subhierarchy.

Indeed a trivial trick for the plugin would be to avoid pom packaging but
the author rejected the PR doing that saying it is a tool feature not a
plugin feature - a bit the same argument that skip should be handled by
mojo executor and not each plugin.

I did a quick extension workaround (
https://github.com/rmannibucau/hierarchy-extension) to enable to configure
the skip toggle the plugin luckily has from the parent and not redefine the
chain/toggle in all children but I think we would need to solve it more
cleanly at some point.

I see a few options (and even if a single one would solve my particular
issue, all can be nice feature IMHO):

1. support what I did in the extension in maven-core?
2. support implicit skip toggle for all mojo executions
3. add some virtual properties ${project.packaging.isPom},
${project.packaging.isNotPom} (potentially others with dynamic evaluations
is[Not]XXX)
4. support implicit skipPackagings (list<string>) property for all mojos

Overall it ends to either define a pseudo language in placeholders and
reuse what is in the plugins or add virutal properties in plugin about the
project structure (what maven itself handles).
Personally I think this last option is saner on the long run (so 2 and 4
short term) but happy to get some feedback or even existing workaround
which does not require to rewire some value in all child or write another
extension ;).

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>

Reply via email to