You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Romain Manni-Bucau <rm...@gmail.com> on 2021/11/26 14:21:08 UTC

Different parent/child configuration without child located customization?

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>

Re: Different parent/child configuration without child located customization?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Le sam. 27 nov. 2021 à 21:58, Falko Modler <f....@gmx.net> a écrit :

> Am 27.11.2021 um 20:25 schrieb Romain Manni-Bucau:
> > 1. Profiles dont work by design since they must be activated and have the
> > same issue that plugin flag
>
> In what I proposed the activation happens automatically via
> <file>...</file> activation, so I don't get your point.


> Sure, if you don't have a suitable file or directory in each child
> module to use for the activation then this approach is not an option.
>

I see - didn't t think to <file> - but it is not always there  at mvn
command time (profile resolution) or files are ambiguous - first run can
generate the build descriptor - and I guess the best test is src/main/java
for other kind of modules (thinking to servers/ subtree) but it is not that
neat at the end - indeed marker files ".build" are a no-go here - and it is
easy to break so I prefer a more robust approach, either the hierarchy
extension or pluginMgt trick for now, but right <file> is a workaround too,
got it.


>
> Artificial flagfiles can be an option when you want to activate a
> profile only for a subset of child modules, but I wouldn't use this
> approach unless there is no other option.
>
> I can show you (working) examples for both in the Quarkus codebase.
>
> Cheers,
>
> Falko
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Different parent/child configuration without child located customization?

Posted by Falko Modler <f....@gmx.net>.
Am 27.11.2021 um 20:25 schrieb Romain Manni-Bucau:
> 1. Profiles dont work by design since they must be activated and have the
> same issue that plugin flag

In what I proposed the activation happens automatically via
<file>...</file> activation, so I don't get your point.

Sure, if you don't have a suitable file or directory in each child
module to use for the activation then this approach is not an option.

Artificial flagfiles can be an option when you want to activate a
profile only for a subset of child modules, but I wouldn't use this
approach unless there is no other option.

I can show you (working) examples for both in the Quarkus codebase.

Cheers,

Falko


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Different parent/child configuration without child located customization?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

Just to answer to the 2 proposals:

1. Profiles dont work by design since they must be activated and have the
same issue that plugin flag
2. Tiles plugin is not bad and relates to the issue i mentionned about
custom lifecycles in an old thread but it is not really related to this
particular issue which is aligned on default jar lifecycle even if it
builds frontend in the example I gave (it is more a structure issue, look
at server example which does not need any custom lifecycle - just jar).
Also something light not requiring way more than maven knowledge is always
10 times saner - when possible - than a very custom build for sharing in
teams. Corporate custom lifecycles or autoconfig always fail after a few
months from my XP (people moving, new coming etc) so I tend to only use it
when I can justify it by a multi outputs - fullstack - module or alike.

Hope it makes sense.

Le sam. 27 nov. 2021 à 19:52, Frederik Boster <fr...@boster.de.invalid>
a écrit :

> For frontend development with Maven I found it to be easiest to define a
> custom lifecycle for a custom artifact type / packaging, e.g.
> "angular-app", "angular-lib", "webpack-app" etc.
> This way it is possible to specify a build flow which is more appropriate
> for frontend development than the default lifecycle by specifying a
> sensible set of plugin executions such as the frontend-maven-plugin.
> The generated frontend artifact can then be used as dependency in other
> maven modules and be unpacked with the maven-dependency-plugin to the
> desired location.
>
> On a more general note: in my opinion maven-tiles [1] is more appropriate
> for this kind of scenarios by utilizing composition-over-inheritance.
>
> I usually combine both approaches to specify a generalized build flow for
> the frontend first with the custom lifecycle / artifact type and
> maven-tiles to make customizations to this build flow.
>
>
> [1] https://github.com/repaint-io/maven-tiles
>
>
> On Sat, Nov 27, 2021, 18:08 Falko Modler <f....@gmx.net> wrote:
>
> > Hi,
> >
> > what also works in many cases is a profile with file activation, e.g. if
> > there is src/main/kotlin add the kotlin plugin.
> > You can even use flagfiles to control this, which isn't pretty but
> > sometimes it makes sense
> >
> > Cheers,
> >
> > Falko
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
>

Re: Different parent/child configuration without child located customization?

Posted by Frederik Boster <fr...@boster.de.INVALID>.
For frontend development with Maven I found it to be easiest to define a
custom lifecycle for a custom artifact type / packaging, e.g.
"angular-app", "angular-lib", "webpack-app" etc.
This way it is possible to specify a build flow which is more appropriate
for frontend development than the default lifecycle by specifying a
sensible set of plugin executions such as the frontend-maven-plugin.
The generated frontend artifact can then be used as dependency in other
maven modules and be unpacked with the maven-dependency-plugin to the
desired location.

On a more general note: in my opinion maven-tiles [1] is more appropriate
for this kind of scenarios by utilizing composition-over-inheritance.

I usually combine both approaches to specify a generalized build flow for
the frontend first with the custom lifecycle / artifact type and
maven-tiles to make customizations to this build flow.


[1] https://github.com/repaint-io/maven-tiles


On Sat, Nov 27, 2021, 18:08 Falko Modler <f....@gmx.net> wrote:

> Hi,
>
> what also works in many cases is a profile with file activation, e.g. if
> there is src/main/kotlin add the kotlin plugin.
> You can even use flagfiles to control this, which isn't pretty but
> sometimes it makes sense
>
> Cheers,
>
> Falko
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Different parent/child configuration without child located customization?

Posted by Falko Modler <f....@gmx.net>.
Hi,

what also works in many cases is a profile with file activation, e.g. if there is src/main/kotlin add the kotlin plugin.
You can even use flagfiles to control this, which isn't pretty but sometimes it makes sense

Cheers,

Falko

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Different parent/child configuration without child located customization?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Sławomir,

Ok, finally got the trick, it is a good one actually and even if a bit more
verbose than mine it is more "buit-in", thanks a lot and probleme solved!

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>


Le ven. 26 nov. 2021 à 18:27, Slawomir Jaranowski <s....@gmail.com>
a écrit :

> Hi
> It can be for both cases.
>
> You want to configure everything in parent pom - right?
> Some executions for all child only and some for parent only.
>
> So everything can be done in one place, like:
>
> <build>
>     <pluginManagment>
>         <plugin>
>             <artifactId>frontend-maven-plugin</artifactId>
>             <execution>
>                 <!-- for all child -->
>                 <id>npm-build</id>
>                 <goals>
>                     <goal>npm</goal>
>                 </goals>
>             </execution>
>         </plugin>
>     </pluginManagment>
>
>     <plugin>
>         <artifactId>frontend-maven-plugin</artifactId>
>         <executions>
>             <execution>
>                 <!-- only skipped in parent pom -->
>                 <inherited>false</inherited>
>                 <!-- the same id as in pluginManagment -->
>                 <id>npm-build</id>
>                 <phase>none</phase>
>             </execution>
>             <execution>
>                 <!-- only in parent pom -->
>                 <inherited>false</inherited>
>                 <id>install-node-npm</id>
>                 <goals>
>                     <goal>install-node-and-npm</goal>
>                 </goals>
>             </execution>
>         </executions>
>     </plugin>
> </build>
>
>
>
> pt., 26 lis 2021 o 17:38 Romain Manni-Bucau <rm...@gmail.com>
> napisał(a):
>
> > Hi Sławomir,
> >
> > It solves the parent case but not the child one (the exact opposite). So
> i
> > can install node only in parent but i can't run npm install && npm run in
> > all children. Do I miss anything?
> >
> > 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
> > >
> >
> >
> > Le ven. 26 nov. 2021 à 16:20, Slawomir Jaranowski <
> s.jaranowski@gmail.com>
> > a écrit :
> >
> > > Hi,
> > >
> > > Try something like in parent pom
> > >
> > >     <build>
> > >         <pluginManagement>
> > >             <plugins>
> > >                 <plugin>
> > >                     <artifactId>maven-failsafe-plugin</artifactId>
> > >                     <version>3.0.0-M5</version>
> > >                     <executions>
> > >                         <execution>
> > >                             <id>test-id</id>
> > >                             <goals>
> > >                                 <goal>integration-test</goal>
> > >                                 <goal>verify</goal>
> > >                             </goals>
> > >                         </execution>
> > >                     </executions>
> > >                 </plugin>
> > >             </plugins>
> > >         </pluginManagement>
> > >
> > >         <plugins>
> > >             <plugin>
> > >                 <artifactId>maven-failsafe-plugin</artifactId>
> > >                 <executions>
> > >                     <execution>
> > >                         <inherited>false</inherited>
> > >                         <id>test-id</id>
> > >                         <phase>none</phase>
> > >                     </execution>
> > >                 </executions>
> > >             </plugin>
> > >         </plugins>
> > >     </build>
> > >
> > > In build/pluginManagement I have executions and also can have
> > > configuration.
> > >
> > > In build/plugins I bind execution to magic phase none with inherited
> set
> > to
> > > false, so plugin will not execute in parent pom only.
> > >
> > >
> > > pt., 26 lis 2021 o 15:21 Romain Manni-Bucau <rm...@gmail.com>
> > > napisał(a):
> > >
> > > > 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
> > > > >
> > > >
> > >
> > >
> > > --
> > > Sławomir Jaranowski
> > >
> >
>
>
> --
> Sławomir Jaranowski
>

Re: Different parent/child configuration without child located customization?

Posted by Slawomir Jaranowski <s....@gmail.com>.
Hi
It can be for both cases.

You want to configure everything in parent pom - right?
Some executions for all child only and some for parent only.

So everything can be done in one place, like:

<build>
    <pluginManagment>
        <plugin>
            <artifactId>frontend-maven-plugin</artifactId>
            <execution>
                <!-- for all child -->
                <id>npm-build</id>
                <goals>
                    <goal>npm</goal>
                </goals>
            </execution>
        </plugin>
    </pluginManagment>

    <plugin>
        <artifactId>frontend-maven-plugin</artifactId>
        <executions>
            <execution>
                <!-- only skipped in parent pom -->
                <inherited>false</inherited>
                <!-- the same id as in pluginManagment -->
                <id>npm-build</id>
                <phase>none</phase>
            </execution>
            <execution>
                <!-- only in parent pom -->
                <inherited>false</inherited>
                <id>install-node-npm</id>
                <goals>
                    <goal>install-node-and-npm</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
</build>



pt., 26 lis 2021 o 17:38 Romain Manni-Bucau <rm...@gmail.com>
napisał(a):

> Hi Sławomir,
>
> It solves the parent case but not the child one (the exact opposite). So i
> can install node only in parent but i can't run npm install && npm run in
> all children. Do I miss anything?
>
> 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
> >
>
>
> Le ven. 26 nov. 2021 à 16:20, Slawomir Jaranowski <s....@gmail.com>
> a écrit :
>
> > Hi,
> >
> > Try something like in parent pom
> >
> >     <build>
> >         <pluginManagement>
> >             <plugins>
> >                 <plugin>
> >                     <artifactId>maven-failsafe-plugin</artifactId>
> >                     <version>3.0.0-M5</version>
> >                     <executions>
> >                         <execution>
> >                             <id>test-id</id>
> >                             <goals>
> >                                 <goal>integration-test</goal>
> >                                 <goal>verify</goal>
> >                             </goals>
> >                         </execution>
> >                     </executions>
> >                 </plugin>
> >             </plugins>
> >         </pluginManagement>
> >
> >         <plugins>
> >             <plugin>
> >                 <artifactId>maven-failsafe-plugin</artifactId>
> >                 <executions>
> >                     <execution>
> >                         <inherited>false</inherited>
> >                         <id>test-id</id>
> >                         <phase>none</phase>
> >                     </execution>
> >                 </executions>
> >             </plugin>
> >         </plugins>
> >     </build>
> >
> > In build/pluginManagement I have executions and also can have
> > configuration.
> >
> > In build/plugins I bind execution to magic phase none with inherited set
> to
> > false, so plugin will not execute in parent pom only.
> >
> >
> > pt., 26 lis 2021 o 15:21 Romain Manni-Bucau <rm...@gmail.com>
> > napisał(a):
> >
> > > 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
> > > >
> > >
> >
> >
> > --
> > Sławomir Jaranowski
> >
>


-- 
Sławomir Jaranowski

Re: Different parent/child configuration without child located customization?

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Sławomir,

It solves the parent case but not the child one (the exact opposite). So i
can install node only in parent but i can't run npm install && npm run in
all children. Do I miss anything?

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>


Le ven. 26 nov. 2021 à 16:20, Slawomir Jaranowski <s....@gmail.com>
a écrit :

> Hi,
>
> Try something like in parent pom
>
>     <build>
>         <pluginManagement>
>             <plugins>
>                 <plugin>
>                     <artifactId>maven-failsafe-plugin</artifactId>
>                     <version>3.0.0-M5</version>
>                     <executions>
>                         <execution>
>                             <id>test-id</id>
>                             <goals>
>                                 <goal>integration-test</goal>
>                                 <goal>verify</goal>
>                             </goals>
>                         </execution>
>                     </executions>
>                 </plugin>
>             </plugins>
>         </pluginManagement>
>
>         <plugins>
>             <plugin>
>                 <artifactId>maven-failsafe-plugin</artifactId>
>                 <executions>
>                     <execution>
>                         <inherited>false</inherited>
>                         <id>test-id</id>
>                         <phase>none</phase>
>                     </execution>
>                 </executions>
>             </plugin>
>         </plugins>
>     </build>
>
> In build/pluginManagement I have executions and also can have
> configuration.
>
> In build/plugins I bind execution to magic phase none with inherited set to
> false, so plugin will not execute in parent pom only.
>
>
> pt., 26 lis 2021 o 15:21 Romain Manni-Bucau <rm...@gmail.com>
> napisał(a):
>
> > 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
> > >
> >
>
>
> --
> Sławomir Jaranowski
>

Re: Different parent/child configuration without child located customization?

Posted by Slawomir Jaranowski <s....@gmail.com>.
Hi,

Try something like in parent pom

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>3.0.0-M5</version>
                    <executions>
                        <execution>
                            <id>test-id</id>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <inherited>false</inherited>
                        <id>test-id</id>
                        <phase>none</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

In build/pluginManagement I have executions and also can have configuration.

In build/plugins I bind execution to magic phase none with inherited set to
false, so plugin will not execute in parent pom only.


pt., 26 lis 2021 o 15:21 Romain Manni-Bucau <rm...@gmail.com>
napisał(a):

> 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
> >
>


-- 
Sławomir Jaranowski