maven configuration with multiple parents

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

maven configuration with multiple parents

Clément Guillaume
Hello,

I have a setup with 2 parent poms, one being the parent of the other.
I'm not able to run a plugin configuration (the configuration is not found)
from command line if it's defined in the (first level) parent pom.
But it does work if the configuration is defined in the "grandparent" pom.

Is it a bug, or designed to be like that?
If it's designed to be like that, am I missing something to get the
configuration defined in my parent pom to be recognized?

Here is a sample project to reproduce
https://github.com/guillaumecle/maven-configuration-test (test-cli-parent
has the configuration for exec:exec but it's not found)

mvn exec:exec

> [INFO] Scanning for projects...
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Reactor Build Order:
> [INFO]
> [INFO] test-cli-grand-parent
>  [pom]
> [INFO] test-cli-parent
>  [pom]
> [INFO] test-cli-module1
> [jar]
> [INFO]
> [INFO] ----------------< bzh.guillaume:test-cli-grand-parent
> >-----------------
> [INFO] Building test-cli-grand-parent 0.0.1-SNAPSHOT
>  [1/3]
> [INFO] --------------------------------[ pom
> ]---------------------------------
> [INFO]
> [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
> test-cli-grand-parent ---
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Reactor Summary for test-cli-parent 0.0.1-SNAPSHOT:
> [INFO]
> [INFO] test-cli-grand-parent .............................. FAILURE [
>  0.586 s]
> [INFO] test-cli-parent .................................... SKIPPED
> [INFO] test-cli-module1 ................................... SKIPPED
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time:  1.034 s
> [INFO] Finished at: 2020-07-15T18:09:15-07:00
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] Failed to execute goal
> org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project
> test-cli-grand-parent: The parameter 'executable' is missing or invalid ->
> [Help 1]
> [ERROR]
> [ERROR] To see the full stack trace of the errors, re-run Maven with the
> -e switch.
> [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> [ERROR]
> [ERROR] For more information about the errors and possible solutions,
> please read the following articles:
> [ERROR] [Help 1]
> http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException


Thank you,
Reply | Threaded
Open this post in threaded view
|

Re: maven configuration with multiple parents

Anders Hammar
If you want to be able to execute the plugin from commandline (like "mvn
exec:exec) and use the plugin config from the pom, the configuration needs
to be in the pluginManagement section. Change that and it should work
regardless if it's in the parent or the "grand-parent".

/Anders

On Thu, Jul 16, 2020 at 3:22 AM Clément Guillaume <[hidden email]>
wrote:

> Hello,
>
> I have a setup with 2 parent poms, one being the parent of the other.
> I'm not able to run a plugin configuration (the configuration is not found)
> from command line if it's defined in the (first level) parent pom.
> But it does work if the configuration is defined in the "grandparent" pom.
>
> Is it a bug, or designed to be like that?
> If it's designed to be like that, am I missing something to get the
> configuration defined in my parent pom to be recognized?
>
> Here is a sample project to reproduce
> https://github.com/guillaumecle/maven-configuration-test (test-cli-parent
> has the configuration for exec:exec but it's not found)
>
> mvn exec:exec
> > [INFO] Scanning for projects...
> > [INFO]
> > ------------------------------------------------------------------------
> > [INFO] Reactor Build Order:
> > [INFO]
> > [INFO] test-cli-grand-parent
> >  [pom]
> > [INFO] test-cli-parent
> >  [pom]
> > [INFO] test-cli-module1
> > [jar]
> > [INFO]
> > [INFO] ----------------< bzh.guillaume:test-cli-grand-parent
> > >-----------------
> > [INFO] Building test-cli-grand-parent 0.0.1-SNAPSHOT
> >  [1/3]
> > [INFO] --------------------------------[ pom
> > ]---------------------------------
> > [INFO]
> > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
> > test-cli-grand-parent ---
> > [INFO]
> > ------------------------------------------------------------------------
> > [INFO] Reactor Summary for test-cli-parent 0.0.1-SNAPSHOT:
> > [INFO]
> > [INFO] test-cli-grand-parent .............................. FAILURE [
> >  0.586 s]
> > [INFO] test-cli-parent .................................... SKIPPED
> > [INFO] test-cli-module1 ................................... SKIPPED
> > [INFO]
> > ------------------------------------------------------------------------
> > [INFO] BUILD FAILURE
> > [INFO]
> > ------------------------------------------------------------------------
> > [INFO] Total time:  1.034 s
> > [INFO] Finished at: 2020-07-15T18:09:15-07:00
> > [INFO]
> > ------------------------------------------------------------------------
> > [ERROR] Failed to execute goal
> > org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project
> > test-cli-grand-parent: The parameter 'executable' is missing or invalid
> ->
> > [Help 1]
> > [ERROR]
> > [ERROR] To see the full stack trace of the errors, re-run Maven with the
> > -e switch.
> > [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> > [ERROR]
> > [ERROR] For more information about the errors and possible solutions,
> > please read the following articles:
> > [ERROR] [Help 1]
> > http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
>
>
> Thank you,
>
Reply | Threaded
Open this post in threaded view
|

Re: maven configuration with multiple parents

Clément Guillaume
Hum, I tried that
<https://github.com/guillaumecle/maven-configuration-test/commit/8b8caabd93a799dd5d68346338b5fa02c899cc8d>
and it still not working

On Thu, Jul 16, 2020 at 12:16 AM Anders Hammar <[hidden email]> wrote:

> If you want to be able to execute the plugin from commandline (like "mvn
> exec:exec) and use the plugin config from the pom, the configuration needs
> to be in the pluginManagement section. Change that and it should work
> regardless if it's in the parent or the "grand-parent".
>
> /Anders
>
> On Thu, Jul 16, 2020 at 3:22 AM Clément Guillaume <[hidden email]>
> wrote:
>
> > Hello,
> >
> > I have a setup with 2 parent poms, one being the parent of the other.
> > I'm not able to run a plugin configuration (the configuration is not
> found)
> > from command line if it's defined in the (first level) parent pom.
> > But it does work if the configuration is defined in the "grandparent"
> pom..
> >
> > Is it a bug, or designed to be like that?
> > If it's designed to be like that, am I missing something to get the
> > configuration defined in my parent pom to be recognized?
> >
> > Here is a sample project to reproduce
> > https://github.com/guillaumecle/maven-configuration-test
> (test-cli-parent
> > has the configuration for exec:exec but it's not found)
> >
> > mvn exec:exec
> > > [INFO] Scanning for projects...
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [INFO] Reactor Build Order:
> > > [INFO]
> > > [INFO] test-cli-grand-parent
> > >  [pom]
> > > [INFO] test-cli-parent
> > >  [pom]
> > > [INFO] test-cli-module1
> > > [jar]
> > > [INFO]
> > > [INFO] ----------------< bzh.guillaume:test-cli-grand-parent
> > > >-----------------
> > > [INFO] Building test-cli-grand-parent 0.0.1-SNAPSHOT
> > >  [1/3]
> > > [INFO] --------------------------------[ pom
> > > ]---------------------------------
> > > [INFO]
> > > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
> > > test-cli-grand-parent ---
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [INFO] Reactor Summary for test-cli-parent 0.0.1-SNAPSHOT:
> > > [INFO]
> > > [INFO] test-cli-grand-parent .............................. FAILURE [
> > >  0.586 s]
> > > [INFO] test-cli-parent .................................... SKIPPED
> > > [INFO] test-cli-module1 ................................... SKIPPED
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [INFO] BUILD FAILURE
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [INFO] Total time:  1.034 s
> > > [INFO] Finished at: 2020-07-15T18:09:15-07:00
> > > [INFO]
> > >
> ------------------------------------------------------------------------
> > > [ERROR] Failed to execute goal
> > > org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on project
> > > test-cli-grand-parent: The parameter 'executable' is missing or invalid
> > ->
> > > [Help 1]
> > > [ERROR]
> > > [ERROR] To see the full stack trace of the errors, re-run Maven with
> the
> > > -e switch.
> > > [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> > > [ERROR]
> > > [ERROR] For more information about the errors and possible solutions,
> > > please read the following articles:
> > > [ERROR] [Help 1]
> > >
> http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
> >
> >
> > Thank you,
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: maven configuration with multiple parents

Martin Kanters
Hi Clément,

The <pluginManagement> section, much like the <dependencyManagement>
section, is a place where you can define "blueprints". The child POMs can
then activate this plugin by adding the plugin normally, with limited
configuration.
In your example your parent pom (/pom.xml) is great. To activate it you
would have to add this in /module1/pom.xml:

<build>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
    </plugin>
  </plugins>
</build>

Then, when executing the command mvn exec:exec in the /module1/ directory,
you will see:
[INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @ test-cli-module1 ---
hello world jar

It would also work if you put this pluginManagement section in your
"grand-parent" pom.

Hope that helps,
Martin

Op vr 17 jul. 2020 om 00:49 schreef Clément Guillaume <[hidden email]
>:

> Hum, I tried that
> <
> https://github.com/guillaumecle/maven-configuration-test/commit/8b8caabd93a799dd5d68346338b5fa02c899cc8d
> >
> and it still not working
>
> On Thu, Jul 16, 2020 at 12:16 AM Anders Hammar <[hidden email]> wrote:
>
> > If you want to be able to execute the plugin from commandline (like "mvn
> > exec:exec) and use the plugin config from the pom, the configuration
> needs
> > to be in the pluginManagement section. Change that and it should work
> > regardless if it's in the parent or the "grand-parent".
> >
> > /Anders
> >
> > On Thu, Jul 16, 2020 at 3:22 AM Clément Guillaume <[hidden email]
> >
> > wrote:
> >
> > > Hello,
> > >
> > > I have a setup with 2 parent poms, one being the parent of the other.
> > > I'm not able to run a plugin configuration (the configuration is not
> > found)
> > > from command line if it's defined in the (first level) parent pom.
> > > But it does work if the configuration is defined in the "grandparent"
> > pom..
> > >
> > > Is it a bug, or designed to be like that?
> > > If it's designed to be like that, am I missing something to get the
> > > configuration defined in my parent pom to be recognized?
> > >
> > > Here is a sample project to reproduce
> > > https://github.com/guillaumecle/maven-configuration-test
> > (test-cli-parent
> > > has the configuration for exec:exec but it's not found)
> > >
> > > mvn exec:exec
> > > > [INFO] Scanning for projects...
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [INFO] Reactor Build Order:
> > > > [INFO]
> > > > [INFO] test-cli-grand-parent
> > > >  [pom]
> > > > [INFO] test-cli-parent
> > > >  [pom]
> > > > [INFO] test-cli-module1
> > > > [jar]
> > > > [INFO]
> > > > [INFO] ----------------< bzh.guillaume:test-cli-grand-parent
> > > > >-----------------
> > > > [INFO] Building test-cli-grand-parent 0.0.1-SNAPSHOT
> > > >  [1/3]
> > > > [INFO] --------------------------------[ pom
> > > > ]---------------------------------
> > > > [INFO]
> > > > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
> > > > test-cli-grand-parent ---
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [INFO] Reactor Summary for test-cli-parent 0.0.1-SNAPSHOT:
> > > > [INFO]
> > > > [INFO] test-cli-grand-parent .............................. FAILURE [
> > > >  0.586 s]
> > > > [INFO] test-cli-parent .................................... SKIPPED
> > > > [INFO] test-cli-module1 ................................... SKIPPED
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [INFO] BUILD FAILURE
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [INFO] Total time:  1.034 s
> > > > [INFO] Finished at: 2020-07-15T18:09:15-07:00
> > > > [INFO]
> > > >
> > ------------------------------------------------------------------------
> > > > [ERROR] Failed to execute goal
> > > > org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on
> project
> > > > test-cli-grand-parent: The parameter 'executable' is missing or
> invalid
> > > ->
> > > > [Help 1]
> > > > [ERROR]
> > > > [ERROR] To see the full stack trace of the errors, re-run Maven with
> > the
> > > > -e switch.
> > > > [ERROR] Re-run Maven using the -X switch to enable full debug
> logging.
> > > > [ERROR]
> > > > [ERROR] For more information about the errors and possible solutions,
> > > > please read the following articles:
> > > > [ERROR] [Help 1]
> > > >
> > http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
> > >
> > >
> > > Thank you,
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: maven configuration with multiple parents

Anders Hammar
On Fri, Jul 17, 2020 at 7:58 AM Martin Kanters <[hidden email]>
wrote:

> The <pluginManagement> section, much like the <dependencyManagement>
> section, is a place where you can define "blueprints". The child POMs can
> then activate this plugin by adding the plugin normally, with limited
> configuration.
> In your example your parent pom (/pom.xml) is great. To activate it you
> would have to add this in /module1/pom.xml:
>
> <build>
>   <plugins>
>     <plugin>
>       <groupId>org.codehaus.mojo</groupId>
>       <artifactId>exec-maven-plugin</artifactId>
>     </plugin>
>   </plugins>
> </build>
>

I'm fairly sure this is not required. The build/plugins section is for
binding to the build lifecycle, but when you execute a mojo directly (like
maven exec:exec) the build lifecycle is not executed. I like to view this
as there are actually two ways of using Maven:
1) As a build tool. You execute the build lifecycle, like "mvn verify".
2) As a utility tool. You then execute a specific mojo, that could do
pretty much anything. Like "mvn exec:exec".

Thinking harder about this specific scenario (which I don't really
understand though, why two parents in the same build?), I believe that the
problem could be that the build lifecycle is not executed. Thus, there is
no reactor and then the grand-parent might be retrieved from the local repo
instead of from the subfolder (if you execute from the root folder). I.e.
the relative path specified doesn't work. Just guessing here...

What you could do is inspect the effective pom ("mvn help:effective-pom")
and verify that the maven-exec-plugin configuration exists (in the
pluginManagement section).

/Anders


>
> Then, when executing the command mvn exec:exec in the /module1/ directory,
> you will see:
> [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @ test-cli-module1
> ---
> hello world jar
>
> It would also work if you put this pluginManagement section in your
> "grand-parent" pom.
>
> Hope that helps,
> Martin
>
> Op vr 17 jul. 2020 om 00:49 schreef Clément Guillaume
> <[hidden email]
> >:
>
> > Hum, I tried that
> > <
> >
> https://github.com/guillaumecle/maven-configuration-test/commit/8b8caabd93a799dd5d68346338b5fa02c899cc8d
> > >
> > and it still not working
> >
> > On Thu, Jul 16, 2020 at 12:16 AM Anders Hammar <[hidden email]>
> wrote:
> >
> > > If you want to be able to execute the plugin from commandline (like
> "mvn
> > > exec:exec) and use the plugin config from the pom, the configuration
> > needs
> > > to be in the pluginManagement section. Change that and it should work
> > > regardless if it's in the parent or the "grand-parent".
> > >
> > > /Anders
> > >
> > > On Thu, Jul 16, 2020 at 3:22 AM Clément Guillaume
> <[hidden email]
> > >
> > > wrote:
> > >
> > > > Hello,
> > > >
> > > > I have a setup with 2 parent poms, one being the parent of the other.
> > > > I'm not able to run a plugin configuration (the configuration is not
> > > found)
> > > > from command line if it's defined in the (first level) parent pom.
> > > > But it does work if the configuration is defined in the "grandparent"
> > > pom..
> > > >
> > > > Is it a bug, or designed to be like that?
> > > > If it's designed to be like that, am I missing something to get the
> > > > configuration defined in my parent pom to be recognized?
> > > >
> > > > Here is a sample project to reproduce
> > > > https://github.com/guillaumecle/maven-configuration-test
> > > (test-cli-parent
> > > > has the configuration for exec:exec but it's not found)
> > > >
> > > > mvn exec:exec
> > > > > [INFO] Scanning for projects...
> > > > > [INFO]
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > [INFO] Reactor Build Order:
> > > > > [INFO]
> > > > > [INFO] test-cli-grand-parent
> > > > >  [pom]
> > > > > [INFO] test-cli-parent
> > > > >  [pom]
> > > > > [INFO] test-cli-module1
> > > > > [jar]
> > > > > [INFO]
> > > > > [INFO] ----------------< bzh.guillaume:test-cli-grand-parent
> > > > > >-----------------
> > > > > [INFO] Building test-cli-grand-parent 0.0.1-SNAPSHOT
> > > > >  [1/3]
> > > > > [INFO] --------------------------------[ pom
> > > > > ]---------------------------------
> > > > > [INFO]
> > > > > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
> > > > > test-cli-grand-parent ---
> > > > > [INFO]
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > [INFO] Reactor Summary for test-cli-parent 0.0.1-SNAPSHOT:
> > > > > [INFO]
> > > > > [INFO] test-cli-grand-parent ..............................
> FAILURE [
> > > > >  0.586 s]
> > > > > [INFO] test-cli-parent .................................... SKIPPED
> > > > > [INFO] test-cli-module1 ................................... SKIPPED
> > > > > [INFO]
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > [INFO] BUILD FAILURE
> > > > > [INFO]
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > [INFO] Total time:  1.034 s
> > > > > [INFO] Finished at: 2020-07-15T18:09:15-07:00
> > > > > [INFO]
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > [ERROR] Failed to execute goal
> > > > > org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on
> > project
> > > > > test-cli-grand-parent: The parameter 'executable' is missing or
> > invalid
> > > > ->
> > > > > [Help 1]
> > > > > [ERROR]
> > > > > [ERROR] To see the full stack trace of the errors, re-run Maven
> with
> > > the
> > > > > -e switch.
> > > > > [ERROR] Re-run Maven using the -X switch to enable full debug
> > logging.
> > > > > [ERROR]
> > > > > [ERROR] For more information about the errors and possible
> solutions,
> > > > > please read the following articles:
> > > > > [ERROR] [Help 1]
> > > > >
> > >
> http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
> > > >
> > > >
> > > > Thank you,
> > > >
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: maven configuration with multiple parents

Martin Kanters
You are right! My bad, I haven't used pluginManagement that much.
I verified that `mvn exec:exec` in the module1 child project works with the
example project that Clément gave (including the pluginManagement change).

I also verified that if you put the pluginManagement part in the
"grandparent", it still works.
It is quite an unusual setup I think to include "grandparent" pom as a
submodule to the root pom (or "parent" pom in this case), but somehow it's
valid.

Clément, as you are saying that your test project didn't work for you, are
you executing `mvn exec:exec` or something different?

Martin


Op vr 17 jul. 2020 om 09:01 schreef Anders Hammar <[hidden email]>:

> On Fri, Jul 17, 2020 at 7:58 AM Martin Kanters <[hidden email]>
> wrote:
>
> > The <pluginManagement> section, much like the <dependencyManagement>
> > section, is a place where you can define "blueprints". The child POMs can
> > then activate this plugin by adding the plugin normally, with limited
> > configuration.
> > In your example your parent pom (/pom.xml) is great. To activate it you
> > would have to add this in /module1/pom.xml:
> >
> > <build>
> >   <plugins>
> >     <plugin>
> >       <groupId>org.codehaus.mojo</groupId>
> >       <artifactId>exec-maven-plugin</artifactId>
> >     </plugin>
> >   </plugins>
> > </build>
> >
>
> I'm fairly sure this is not required. The build/plugins section is for
> binding to the build lifecycle, but when you execute a mojo directly (like
> maven exec:exec) the build lifecycle is not executed. I like to view this
> as there are actually two ways of using Maven:
> 1) As a build tool. You execute the build lifecycle, like "mvn verify".
> 2) As a utility tool. You then execute a specific mojo, that could do
> pretty much anything. Like "mvn exec:exec".
>
> Thinking harder about this specific scenario (which I don't really
> understand though, why two parents in the same build?), I believe that the
> problem could be that the build lifecycle is not executed. Thus, there is
> no reactor and then the grand-parent might be retrieved from the local repo
> instead of from the subfolder (if you execute from the root folder). I.e.
> the relative path specified doesn't work. Just guessing here...
>
> What you could do is inspect the effective pom ("mvn help:effective-pom")
> and verify that the maven-exec-plugin configuration exists (in the
> pluginManagement section).
>
> /Anders
>
>
> >
> > Then, when executing the command mvn exec:exec in the /module1/
> directory,
> > you will see:
> > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @ test-cli-module1
> > ---
> > hello world jar
> >
> > It would also work if you put this pluginManagement section in your
> > "grand-parent" pom.
> >
> > Hope that helps,
> > Martin
> >
> > Op vr 17 jul. 2020 om 00:49 schreef Clément Guillaume
> > <[hidden email]
> > >:
> >
> > > Hum, I tried that
> > > <
> > >
> >
> https://github.com/guillaumecle/maven-configuration-test/commit/8b8caabd93a799dd5d68346338b5fa02c899cc8d
> > > >
> > > and it still not working
> > >
> > > On Thu, Jul 16, 2020 at 12:16 AM Anders Hammar <[hidden email]>
> > wrote:
> > >
> > > > If you want to be able to execute the plugin from commandline (like
> > "mvn
> > > > exec:exec) and use the plugin config from the pom, the configuration
> > > needs
> > > > to be in the pluginManagement section. Change that and it should work
> > > > regardless if it's in the parent or the "grand-parent".
> > > >
> > > > /Anders
> > > >
> > > > On Thu, Jul 16, 2020 at 3:22 AM Clément Guillaume
> > <[hidden email]
> > > >
> > > > wrote:
> > > >
> > > > > Hello,
> > > > >
> > > > > I have a setup with 2 parent poms, one being the parent of the
> other.
> > > > > I'm not able to run a plugin configuration (the configuration is
> not
> > > > found)
> > > > > from command line if it's defined in the (first level) parent pom.
> > > > > But it does work if the configuration is defined in the
> "grandparent"
> > > > pom..
> > > > >
> > > > > Is it a bug, or designed to be like that?
> > > > > If it's designed to be like that, am I missing something to get the
> > > > > configuration defined in my parent pom to be recognized?
> > > > >
> > > > > Here is a sample project to reproduce
> > > > > https://github.com/guillaumecle/maven-configuration-test
> > > > (test-cli-parent
> > > > > has the configuration for exec:exec but it's not found)
> > > > >
> > > > > mvn exec:exec
> > > > > > [INFO] Scanning for projects...
> > > > > > [INFO]
> > > > > >
> > > >
> > ------------------------------------------------------------------------
> > > > > > [INFO] Reactor Build Order:
> > > > > > [INFO]
> > > > > > [INFO] test-cli-grand-parent
> > > > > >  [pom]
> > > > > > [INFO] test-cli-parent
> > > > > >  [pom]
> > > > > > [INFO] test-cli-module1
> > > > > > [jar]
> > > > > > [INFO]
> > > > > > [INFO] ----------------< bzh.guillaume:test-cli-grand-parent
> > > > > > >-----------------
> > > > > > [INFO] Building test-cli-grand-parent 0.0.1-SNAPSHOT
> > > > > >  [1/3]
> > > > > > [INFO] --------------------------------[ pom
> > > > > > ]---------------------------------
> > > > > > [INFO]
> > > > > > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
> > > > > > test-cli-grand-parent ---
> > > > > > [INFO]
> > > > > >
> > > >
> > ------------------------------------------------------------------------
> > > > > > [INFO] Reactor Summary for test-cli-parent 0.0.1-SNAPSHOT:
> > > > > > [INFO]
> > > > > > [INFO] test-cli-grand-parent ..............................
> > FAILURE [
> > > > > >  0.586 s]
> > > > > > [INFO] test-cli-parent ....................................
> SKIPPED
> > > > > > [INFO] test-cli-module1 ...................................
> SKIPPED
> > > > > > [INFO]
> > > > > >
> > > >
> > ------------------------------------------------------------------------
> > > > > > [INFO] BUILD FAILURE
> > > > > > [INFO]
> > > > > >
> > > >
> > ------------------------------------------------------------------------
> > > > > > [INFO] Total time:  1.034 s
> > > > > > [INFO] Finished at: 2020-07-15T18:09:15-07:00
> > > > > > [INFO]
> > > > > >
> > > >
> > ------------------------------------------------------------------------
> > > > > > [ERROR] Failed to execute goal
> > > > > > org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on
> > > project
> > > > > > test-cli-grand-parent: The parameter 'executable' is missing or
> > > invalid
> > > > > ->
> > > > > > [Help 1]
> > > > > > [ERROR]
> > > > > > [ERROR] To see the full stack trace of the errors, re-run Maven
> > with
> > > > the
> > > > > > -e switch.
> > > > > > [ERROR] Re-run Maven using the -X switch to enable full debug
> > > logging.
> > > > > > [ERROR]
> > > > > > [ERROR] For more information about the errors and possible
> > solutions,
> > > > > > please read the following articles:
> > > > > > [ERROR] [Help 1]
> > > > > >
> > > >
> > http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
> > > > >
> > > > >
> > > > > Thank you,
> > > > >
> > > >
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: maven configuration with multiple parents

Anders Hammar
Also, what version of Maven is used? I think there was something related to
relative path for parent fixed in some version.

/Anders

On Fri, Jul 17, 2020 at 9:18 AM Martin Kanters <[hidden email]>
wrote:

> You are right! My bad, I haven't used pluginManagement that much.
> I verified that `mvn exec:exec` in the module1 child project works with the
> example project that Clément gave (including the pluginManagement change).
>
> I also verified that if you put the pluginManagement part in the
> "grandparent", it still works.
> It is quite an unusual setup I think to include "grandparent" pom as a
> submodule to the root pom (or "parent" pom in this case), but somehow it's
> valid.
>
> Clément, as you are saying that your test project didn't work for you, are
> you executing `mvn exec:exec` or something different?
>
> Martin
>
>
> Op vr 17 jul. 2020 om 09:01 schreef Anders Hammar <[hidden email]>:
>
> > On Fri, Jul 17, 2020 at 7:58 AM Martin Kanters <[hidden email]
> >
> > wrote:
> >
> > > The <pluginManagement> section, much like the <dependencyManagement>
> > > section, is a place where you can define "blueprints". The child POMs
> can
> > > then activate this plugin by adding the plugin normally, with limited
> > > configuration.
> > > In your example your parent pom (/pom.xml) is great. To activate it you
> > > would have to add this in /module1/pom.xml:
> > >
> > > <build>
> > >   <plugins>
> > >     <plugin>
> > >       <groupId>org.codehaus.mojo</groupId>
> > >       <artifactId>exec-maven-plugin</artifactId>
> > >     </plugin>
> > >   </plugins>
> > > </build>
> > >
> >
> > I'm fairly sure this is not required. The build/plugins section is for
> > binding to the build lifecycle, but when you execute a mojo directly
> (like
> > maven exec:exec) the build lifecycle is not executed. I like to view this
> > as there are actually two ways of using Maven:
> > 1) As a build tool. You execute the build lifecycle, like "mvn verify".
> > 2) As a utility tool. You then execute a specific mojo, that could do
> > pretty much anything. Like "mvn exec:exec".
> >
> > Thinking harder about this specific scenario (which I don't really
> > understand though, why two parents in the same build?), I believe that
> the
> > problem could be that the build lifecycle is not executed. Thus, there is
> > no reactor and then the grand-parent might be retrieved from the local
> repo
> > instead of from the subfolder (if you execute from the root folder). I.e.
> > the relative path specified doesn't work. Just guessing here...
> >
> > What you could do is inspect the effective pom ("mvn help:effective-pom")
> > and verify that the maven-exec-plugin configuration exists (in the
> > pluginManagement section).
> >
> > /Anders
> >
> >
> > >
> > > Then, when executing the command mvn exec:exec in the /module1/
> > directory,
> > > you will see:
> > > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
> test-cli-module1
> > > ---
> > > hello world jar
> > >
> > > It would also work if you put this pluginManagement section in your
> > > "grand-parent" pom.
> > >
> > > Hope that helps,
> > > Martin
> > >
> > > Op vr 17 jul. 2020 om 00:49 schreef Clément Guillaume
> > > <[hidden email]
> > > >:
> > >
> > > > Hum, I tried that
> > > > <
> > > >
> > >
> >
> https://github.com/guillaumecle/maven-configuration-test/commit/8b8caabd93a799dd5d68346338b5fa02c899cc8d
> > > > >
> > > > and it still not working
> > > >
> > > > On Thu, Jul 16, 2020 at 12:16 AM Anders Hammar <[hidden email]>
> > > wrote:
> > > >
> > > > > If you want to be able to execute the plugin from commandline (like
> > > "mvn
> > > > > exec:exec) and use the plugin config from the pom, the
> configuration
> > > > needs
> > > > > to be in the pluginManagement section. Change that and it should
> work
> > > > > regardless if it's in the parent or the "grand-parent".
> > > > >
> > > > > /Anders
> > > > >
> > > > > On Thu, Jul 16, 2020 at 3:22 AM Clément Guillaume
> > > <[hidden email]
> > > > >
> > > > > wrote:
> > > > >
> > > > > > Hello,
> > > > > >
> > > > > > I have a setup with 2 parent poms, one being the parent of the
> > other.
> > > > > > I'm not able to run a plugin configuration (the configuration is
> > not
> > > > > found)
> > > > > > from command line if it's defined in the (first level) parent
> pom.
> > > > > > But it does work if the configuration is defined in the
> > "grandparent"
> > > > > pom..
> > > > > >
> > > > > > Is it a bug, or designed to be like that?
> > > > > > If it's designed to be like that, am I missing something to get
> the
> > > > > > configuration defined in my parent pom to be recognized?
> > > > > >
> > > > > > Here is a sample project to reproduce
> > > > > > https://github.com/guillaumecle/maven-configuration-test
> > > > > (test-cli-parent
> > > > > > has the configuration for exec:exec but it's not found)
> > > > > >
> > > > > > mvn exec:exec
> > > > > > > [INFO] Scanning for projects...
> > > > > > > [INFO]
> > > > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > > > [INFO] Reactor Build Order:
> > > > > > > [INFO]
> > > > > > > [INFO] test-cli-grand-parent
> > > > > > >  [pom]
> > > > > > > [INFO] test-cli-parent
> > > > > > >  [pom]
> > > > > > > [INFO] test-cli-module1
> > > > > > > [jar]
> > > > > > > [INFO]
> > > > > > > [INFO] ----------------< bzh.guillaume:test-cli-grand-parent
> > > > > > > >-----------------
> > > > > > > [INFO] Building test-cli-grand-parent 0.0.1-SNAPSHOT
> > > > > > >  [1/3]
> > > > > > > [INFO] --------------------------------[ pom
> > > > > > > ]---------------------------------
> > > > > > > [INFO]
> > > > > > > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
> > > > > > > test-cli-grand-parent ---
> > > > > > > [INFO]
> > > > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > > > [INFO] Reactor Summary for test-cli-parent 0.0.1-SNAPSHOT:
> > > > > > > [INFO]
> > > > > > > [INFO] test-cli-grand-parent ..............................
> > > FAILURE [
> > > > > > >  0.586 s]
> > > > > > > [INFO] test-cli-parent ....................................
> > SKIPPED
> > > > > > > [INFO] test-cli-module1 ...................................
> > SKIPPED
> > > > > > > [INFO]
> > > > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > > > [INFO] BUILD FAILURE
> > > > > > > [INFO]
> > > > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > > > [INFO] Total time:  1.034 s
> > > > > > > [INFO] Finished at: 2020-07-15T18:09:15-07:00
> > > > > > > [INFO]
> > > > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > > > [ERROR] Failed to execute goal
> > > > > > > org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli) on
> > > > project
> > > > > > > test-cli-grand-parent: The parameter 'executable' is missing or
> > > > invalid
> > > > > > ->
> > > > > > > [Help 1]
> > > > > > > [ERROR]
> > > > > > > [ERROR] To see the full stack trace of the errors, re-run Maven
> > > with
> > > > > the
> > > > > > > -e switch.
> > > > > > > [ERROR] Re-run Maven using the -X switch to enable full debug
> > > > logging.
> > > > > > > [ERROR]
> > > > > > > [ERROR] For more information about the errors and possible
> > > solutions,
> > > > > > > please read the following articles:
> > > > > > > [ERROR] [Help 1]
> > > > > > >
> > > > >
> > >
> http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
> > > > > >
> > > > > >
> > > > > > Thank you,
> > > > > >
> > > > >
> > > >
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: maven configuration with multiple parents

Clément Guillaume
Hi again,

Thank you for the responses. I think I figured my problem.
Running the plugin on a specific module (changing work directory or using
-pl) was always working fine.
What I was trying to do was to run it for every module at once from the
parent directory.
And when defining the configuration in the parent, module1 and parent were
fine but obviously grandparent didn't know about it and exec:exec would
fail. In addition grandparent is the first to run and its failure hides the
potential success of parent and module1.

Now I'll try to find a way around this.
- Maybe defining a no-op exec:exec configuration in the grandparent.
- Could I do something like running a specific execution id and
skipping projects that don't have this execution id defined?

On Fri, Jul 17, 2020 at 12:21 AM Anders Hammar <[hidden email]> wrote:

> Also, what version of Maven is used? I think there was something related to
> relative path for parent fixed in some version.
>
> /Anders
>
> On Fri, Jul 17, 2020 at 9:18 AM Martin Kanters <[hidden email]>
> wrote:
>
> > You are right! My bad, I haven't used pluginManagement that much.
> > I verified that `mvn exec:exec` in the module1 child project works with
> the
> > example project that Clément gave (including the pluginManagement
> change).
> >
> > I also verified that if you put the pluginManagement part in the
> > "grandparent", it still works.
> > It is quite an unusual setup I think to include "grandparent" pom as a
> > submodule to the root pom (or "parent" pom in this case), but somehow
> it's
> > valid.
> >
> > Clément, as you are saying that your test project didn't work for you,
> are
> > you executing `mvn exec:exec` or something different?
> >
> > Martin
> >
> >
> > Op vr 17 jul. 2020 om 09:01 schreef Anders Hammar <[hidden email]>:
> >
> > > On Fri, Jul 17, 2020 at 7:58 AM Martin Kanters <
> [hidden email]
> > >
> > > wrote:
> > >
> > > > The <pluginManagement> section, much like the <dependencyManagement>
> > > > section, is a place where you can define "blueprints". The child POMs
> > can
> > > > then activate this plugin by adding the plugin normally, with limited
> > > > configuration.
> > > > In your example your parent pom (/pom.xml) is great. To activate it
> you
> > > > would have to add this in /module1/pom.xml:
> > > >
> > > > <build>
> > > >   <plugins>
> > > >     <plugin>
> > > >       <groupId>org.codehaus.mojo</groupId>
> > > >       <artifactId>exec-maven-plugin</artifactId>
> > > >     </plugin>
> > > >   </plugins>
> > > > </build>
> > > >
> > >
> > > I'm fairly sure this is not required. The build/plugins section is for
> > > binding to the build lifecycle, but when you execute a mojo directly
> > (like
> > > maven exec:exec) the build lifecycle is not executed. I like to view
> this
> > > as there are actually two ways of using Maven:
> > > 1) As a build tool. You execute the build lifecycle, like "mvn verify".
> > > 2) As a utility tool. You then execute a specific mojo, that could do
> > > pretty much anything. Like "mvn exec:exec".
> > >
> > > Thinking harder about this specific scenario (which I don't really
> > > understand though, why two parents in the same build?), I believe that
> > the
> > > problem could be that the build lifecycle is not executed. Thus, there
> is
> > > no reactor and then the grand-parent might be retrieved from the local
> > repo
> > > instead of from the subfolder (if you execute from the root folder).
> I.e.
> > > the relative path specified doesn't work. Just guessing here...
> > >
> > > What you could do is inspect the effective pom ("mvn
> help:effective-pom")
> > > and verify that the maven-exec-plugin configuration exists (in the
> > > pluginManagement section).
> > >
> > > /Anders
> > >
> > >
> > > >
> > > > Then, when executing the command mvn exec:exec in the /module1/
> > > directory,
> > > > you will see:
> > > > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
> > test-cli-module1
> > > > ---
> > > > hello world jar
> > > >
> > > > It would also work if you put this pluginManagement section in your
> > > > "grand-parent" pom.
> > > >
> > > > Hope that helps,
> > > > Martin
> > > >
> > > > Op vr 17 jul. 2020 om 00:49 schreef Clément Guillaume
> > > > <[hidden email]
> > > > >:
> > > >
> > > > > Hum, I tried that
> > > > > <
> > > > >
> > > >
> > >
> >
> https://github.com/guillaumecle/maven-configuration-test/commit/8b8caabd93a799dd5d68346338b5fa02c899cc8d
> > > > > >
> > > > > and it still not working
> > > > >
> > > > > On Thu, Jul 16, 2020 at 12:16 AM Anders Hammar <[hidden email]>
> > > > wrote:
> > > > >
> > > > > > If you want to be able to execute the plugin from commandline
> (like
> > > > "mvn
> > > > > > exec:exec) and use the plugin config from the pom, the
> > configuration
> > > > > needs
> > > > > > to be in the pluginManagement section. Change that and it should
> > work
> > > > > > regardless if it's in the parent or the "grand-parent".
> > > > > >
> > > > > > /Anders
> > > > > >
> > > > > > On Thu, Jul 16, 2020 at 3:22 AM Clément Guillaume
> > > > <[hidden email]
> > > > > >
> > > > > > wrote:
> > > > > >
> > > > > > > Hello,
> > > > > > >
> > > > > > > I have a setup with 2 parent poms, one being the parent of the
> > > other.
> > > > > > > I'm not able to run a plugin configuration (the configuration
> is
> > > not
> > > > > > found)
> > > > > > > from command line if it's defined in the (first level) parent
> > pom.
> > > > > > > But it does work if the configuration is defined in the
> > > "grandparent"
> > > > > > pom..
> > > > > > >
> > > > > > > Is it a bug, or designed to be like that?
> > > > > > > If it's designed to be like that, am I missing something to get
> > the
> > > > > > > configuration defined in my parent pom to be recognized?
> > > > > > >
> > > > > > > Here is a sample project to reproduce
> > > > > > > https://github.com/guillaumecle/maven-configuration-test
> > > > > > (test-cli-parent
> > > > > > > has the configuration for exec:exec but it's not found)
> > > > > > >
> > > > > > > mvn exec:exec
> > > > > > > > [INFO] Scanning for projects...
> > > > > > > > [INFO]
> > > > > > > >
> > > > > >
> > > >
> > ------------------------------------------------------------------------
> > > > > > > > [INFO] Reactor Build Order:
> > > > > > > > [INFO]
> > > > > > > > [INFO] test-cli-grand-parent
> > > > > > > >  [pom]
> > > > > > > > [INFO] test-cli-parent
> > > > > > > >  [pom]
> > > > > > > > [INFO] test-cli-module1
> > > > > > > > [jar]
> > > > > > > > [INFO]
> > > > > > > > [INFO] ----------------< bzh.guillaume:test-cli-grand-parent
> > > > > > > > >-----------------
> > > > > > > > [INFO] Building test-cli-grand-parent 0.0.1-SNAPSHOT
> > > > > > > >  [1/3]
> > > > > > > > [INFO] --------------------------------[ pom
> > > > > > > > ]---------------------------------
> > > > > > > > [INFO]
> > > > > > > > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
> > > > > > > > test-cli-grand-parent ---
> > > > > > > > [INFO]
> > > > > > > >
> > > > > >
> > > >
> > ------------------------------------------------------------------------
> > > > > > > > [INFO] Reactor Summary for test-cli-parent 0.0.1-SNAPSHOT:
> > > > > > > > [INFO]
> > > > > > > > [INFO] test-cli-grand-parent ..............................
> > > > FAILURE [
> > > > > > > >  0.586 s]
> > > > > > > > [INFO] test-cli-parent ....................................
> > > SKIPPED
> > > > > > > > [INFO] test-cli-module1 ...................................
> > > SKIPPED
> > > > > > > > [INFO]
> > > > > > > >
> > > > > >
> > > >
> > ------------------------------------------------------------------------
> > > > > > > > [INFO] BUILD FAILURE
> > > > > > > > [INFO]
> > > > > > > >
> > > > > >
> > > >
> > ------------------------------------------------------------------------
> > > > > > > > [INFO] Total time:  1.034 s
> > > > > > > > [INFO] Finished at: 2020-07-15T18:09:15-07:00
> > > > > > > > [INFO]
> > > > > > > >
> > > > > >
> > > >
> > ------------------------------------------------------------------------
> > > > > > > > [ERROR] Failed to execute goal
> > > > > > > > org.codehaus.mojo:exec-maven-plugin:3.0.0:exec (default-cli)
> on
> > > > > project
> > > > > > > > test-cli-grand-parent: The parameter 'executable' is missing
> or
> > > > > invalid
> > > > > > > ->
> > > > > > > > [Help 1]
> > > > > > > > [ERROR]
> > > > > > > > [ERROR] To see the full stack trace of the errors, re-run
> Maven
> > > > with
> > > > > > the
> > > > > > > > -e switch.
> > > > > > > > [ERROR] Re-run Maven using the -X switch to enable full debug
> > > > > logging.
> > > > > > > > [ERROR]
> > > > > > > > [ERROR] For more information about the errors and possible
> > > > solutions,
> > > > > > > > please read the following articles:
> > > > > > > > [ERROR] [Help 1]
> > > > > > > >
> > > > > >
> > > >
> > http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
> > > > > > >
> > > > > > >
> > > > > > > Thank you,
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: maven configuration with multiple parents

Martin Kanters
Hey Clément,

This is a problem, and a limitation, in Maven currently. A related JIRA
issue is MNG-6118 [1].
Here the scenario is using a different plugin invocation (jetty:run), which
also only makes sense for usually one module in a multi-module project.

The current solution indeed is to navigate into the submodule and run
maven there, but then it will only build that specific module.

We are planning to implement a solution which would make the following
possible from root:
`mvn -pl :module1 -am exec:exec`. This would enable a maven invocation from
root, run exec:exec only for module1 and build all the needed submodules
(parent and grandparent).
I think it would be nice to also include your scenario: mvn -pl
:module1,:parent -am exec:exec. This would run exec:exec in all modules,
except for the grandparent module.

That said, your first bullet point would work currently, and would give you
the cleanest cli invocation (no need for -pl and -am).
I don't think your last bullet point is possible, at least I have not seen
this yet.

Regards,
Martin

[1] https://issues.apache.org/jira/browse/MNG-6118

Op vr 17 jul. 2020 om 18:55 schreef Clément Guillaume <[hidden email]
>:

> Hi again,
>
> Thank you for the responses. I think I figured my problem.
> Running the plugin on a specific module (changing work directory or using
> -pl) was always working fine.
> What I was trying to do was to run it for every module at once from the
> parent directory.
> And when defining the configuration in the parent, module1 and parent were
> fine but obviously grandparent didn't know about it and exec:exec would
> fail. In addition grandparent is the first to run and its failure hides the
> potential success of parent and module1.
>
> Now I'll try to find a way around this.
> - Maybe defining a no-op exec:exec configuration in the grandparent.
> - Could I do something like running a specific execution id and
> skipping projects that don't have this execution id defined?
>
> On Fri, Jul 17, 2020 at 12:21 AM Anders Hammar <[hidden email]> wrote:
>
> > Also, what version of Maven is used? I think there was something related
> to
> > relative path for parent fixed in some version.
> >
> > /Anders
> >
> > On Fri, Jul 17, 2020 at 9:18 AM Martin Kanters <[hidden email]
> >
> > wrote:
> >
> > > You are right! My bad, I haven't used pluginManagement that much.
> > > I verified that `mvn exec:exec` in the module1 child project works with
> > the
> > > example project that Clément gave (including the pluginManagement
> > change).
> > >
> > > I also verified that if you put the pluginManagement part in the
> > > "grandparent", it still works.
> > > It is quite an unusual setup I think to include "grandparent" pom as a
> > > submodule to the root pom (or "parent" pom in this case), but somehow
> > it's
> > > valid.
> > >
> > > Clément, as you are saying that your test project didn't work for you,
> > are
> > > you executing `mvn exec:exec` or something different?
> > >
> > > Martin
> > >
> > >
> > > Op vr 17 jul. 2020 om 09:01 schreef Anders Hammar <[hidden email]>:
> > >
> > > > On Fri, Jul 17, 2020 at 7:58 AM Martin Kanters <
> > [hidden email]
> > > >
> > > > wrote:
> > > >
> > > > > The <pluginManagement> section, much like the
> <dependencyManagement>
> > > > > section, is a place where you can define "blueprints". The child
> POMs
> > > can
> > > > > then activate this plugin by adding the plugin normally, with
> limited
> > > > > configuration.
> > > > > In your example your parent pom (/pom.xml) is great. To activate it
> > you
> > > > > would have to add this in /module1/pom.xml:
> > > > >
> > > > > <build>
> > > > >   <plugins>
> > > > >     <plugin>
> > > > >       <groupId>org.codehaus.mojo</groupId>
> > > > >       <artifactId>exec-maven-plugin</artifactId>
> > > > >     </plugin>
> > > > >   </plugins>
> > > > > </build>
> > > > >
> > > >
> > > > I'm fairly sure this is not required. The build/plugins section is
> for
> > > > binding to the build lifecycle, but when you execute a mojo directly
> > > (like
> > > > maven exec:exec) the build lifecycle is not executed. I like to view
> > this
> > > > as there are actually two ways of using Maven:
> > > > 1) As a build tool. You execute the build lifecycle, like "mvn
> verify".
> > > > 2) As a utility tool. You then execute a specific mojo, that could do
> > > > pretty much anything. Like "mvn exec:exec".
> > > >
> > > > Thinking harder about this specific scenario (which I don't really
> > > > understand though, why two parents in the same build?), I believe
> that
> > > the
> > > > problem could be that the build lifecycle is not executed. Thus,
> there
> > is
> > > > no reactor and then the grand-parent might be retrieved from the
> local
> > > repo
> > > > instead of from the subfolder (if you execute from the root folder).
> > I.e.
> > > > the relative path specified doesn't work. Just guessing here...
> > > >
> > > > What you could do is inspect the effective pom ("mvn
> > help:effective-pom")
> > > > and verify that the maven-exec-plugin configuration exists (in the
> > > > pluginManagement section).
> > > >
> > > > /Anders
> > > >
> > > >
> > > > >
> > > > > Then, when executing the command mvn exec:exec in the /module1/
> > > > directory,
> > > > > you will see:
> > > > > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
> > > test-cli-module1
> > > > > ---
> > > > > hello world jar
> > > > >
> > > > > It would also work if you put this pluginManagement section in your
> > > > > "grand-parent" pom.
> > > > >
> > > > > Hope that helps,
> > > > > Martin
> > > > >
> > > > > Op vr 17 jul. 2020 om 00:49 schreef Clément Guillaume
> > > > > <[hidden email]
> > > > > >:
> > > > >
> > > > > > Hum, I tried that
> > > > > > <
> > > > > >
> > > > >
> > > >
> > >
> >
> https://github.com/guillaumecle/maven-configuration-test/commit/8b8caabd93a799dd5d68346338b5fa02c899cc8d
> > > > > > >
> > > > > > and it still not working
> > > > > >
> > > > > > On Thu, Jul 16, 2020 at 12:16 AM Anders Hammar <
> [hidden email]>
> > > > > wrote:
> > > > > >
> > > > > > > If you want to be able to execute the plugin from commandline
> > (like
> > > > > "mvn
> > > > > > > exec:exec) and use the plugin config from the pom, the
> > > configuration
> > > > > > needs
> > > > > > > to be in the pluginManagement section. Change that and it
> should
> > > work
> > > > > > > regardless if it's in the parent or the "grand-parent".
> > > > > > >
> > > > > > > /Anders
> > > > > > >
> > > > > > > On Thu, Jul 16, 2020 at 3:22 AM Clément Guillaume
> > > > > <[hidden email]
> > > > > > >
> > > > > > > wrote:
> > > > > > >
> > > > > > > > Hello,
> > > > > > > >
> > > > > > > > I have a setup with 2 parent poms, one being the parent of
> the
> > > > other.
> > > > > > > > I'm not able to run a plugin configuration (the configuration
> > is
> > > > not
> > > > > > > found)
> > > > > > > > from command line if it's defined in the (first level) parent
> > > pom.
> > > > > > > > But it does work if the configuration is defined in the
> > > > "grandparent"
> > > > > > > pom..
> > > > > > > >
> > > > > > > > Is it a bug, or designed to be like that?
> > > > > > > > If it's designed to be like that, am I missing something to
> get
> > > the
> > > > > > > > configuration defined in my parent pom to be recognized?
> > > > > > > >
> > > > > > > > Here is a sample project to reproduce
> > > > > > > > https://github.com/guillaumecle/maven-configuration-test
> > > > > > > (test-cli-parent
> > > > > > > > has the configuration for exec:exec but it's not found)
> > > > > > > >
> > > > > > > > mvn exec:exec
> > > > > > > > > [INFO] Scanning for projects...
> > > > > > > > > [INFO]
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > > > > > [INFO] Reactor Build Order:
> > > > > > > > > [INFO]
> > > > > > > > > [INFO] test-cli-grand-parent
> > > > > > > > >  [pom]
> > > > > > > > > [INFO] test-cli-parent
> > > > > > > > >  [pom]
> > > > > > > > > [INFO] test-cli-module1
> > > > > > > > > [jar]
> > > > > > > > > [INFO]
> > > > > > > > > [INFO] ----------------<
> bzh.guillaume:test-cli-grand-parent
> > > > > > > > > >-----------------
> > > > > > > > > [INFO] Building test-cli-grand-parent 0.0.1-SNAPSHOT
> > > > > > > > >  [1/3]
> > > > > > > > > [INFO] --------------------------------[ pom
> > > > > > > > > ]---------------------------------
> > > > > > > > > [INFO]
> > > > > > > > > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
> > > > > > > > > test-cli-grand-parent ---
> > > > > > > > > [INFO]
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > > > > > [INFO] Reactor Summary for test-cli-parent 0.0.1-SNAPSHOT:
> > > > > > > > > [INFO]
> > > > > > > > > [INFO] test-cli-grand-parent ..............................
> > > > > FAILURE [
> > > > > > > > >  0.586 s]
> > > > > > > > > [INFO] test-cli-parent ....................................
> > > > SKIPPED
> > > > > > > > > [INFO] test-cli-module1 ...................................
> > > > SKIPPED
> > > > > > > > > [INFO]
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > > > > > [INFO] BUILD FAILURE
> > > > > > > > > [INFO]
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > > > > > [INFO] Total time:  1.034 s
> > > > > > > > > [INFO] Finished at: 2020-07-15T18:09:15-07:00
> > > > > > > > > [INFO]
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> ------------------------------------------------------------------------
> > > > > > > > > [ERROR] Failed to execute goal
> > > > > > > > > org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
> (default-cli)
> > on
> > > > > > project
> > > > > > > > > test-cli-grand-parent: The parameter 'executable' is
> missing
> > or
> > > > > > invalid
> > > > > > > > ->
> > > > > > > > > [Help 1]
> > > > > > > > > [ERROR]
> > > > > > > > > [ERROR] To see the full stack trace of the errors, re-run
> > Maven
> > > > > with
> > > > > > > the
> > > > > > > > > -e switch.
> > > > > > > > > [ERROR] Re-run Maven using the -X switch to enable full
> debug
> > > > > > logging.
> > > > > > > > > [ERROR]
> > > > > > > > > [ERROR] For more information about the errors and possible
> > > > > solutions,
> > > > > > > > > please read the following articles:
> > > > > > > > > [ERROR] [Help 1]
> > > > > > > > >
> > > > > > >
> > > > >
> > >
> http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
> > > > > > > >
> > > > > > > >
> > > > > > > > Thank you,
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: maven configuration with multiple parents

Martin Kanters
I'll have to correct myself on the following:

--> We are planning to implement a solution which would make the following
possible from root:
--> `mvn -pl :module1 -am exec:exec`. This would enable a maven invocation
from root, run exec:exec only for module1 and build all the needed
submodules (parent and grandparent).
--> I think it would be nice to also include your scenario: mvn -pl
:module1,:parent -am exec:exec. This would run exec:exec in all modules,
except for the grandparent module.

`-am` currently invokes the same build (phase/goal/plugin) as is invoked on
the cli (so exec:exec in your case). This will not change with the planned
implementation.
We did discuss this use-case, but it turns out more work needs to be done
to achieve this.

One other thing that might come of help to you is (from root): `mvn -pl
!:grandparent exec:exec`. It is a bit easier than having to select two
modules.
Of course this only holds if only one module would have to be skipped...
otherwise the noop sounds better.

Regards,
Martin


Op zo 19 jul. 2020 om 17:17 schreef Martin Kanters <[hidden email]
>:

> Hey Clément,
>
> This is a problem, and a limitation, in Maven currently. A related JIRA
> issue is MNG-6118 [1].
> Here the scenario is using a different plugin invocation (jetty:run),
> which also only makes sense for usually one module in a multi-module
> project.
>
> The current solution indeed is to navigate into the submodule and run
> maven there, but then it will only build that specific module.
>
> We are planning to implement a solution which would make the following
> possible from root:
> `mvn -pl :module1 -am exec:exec`. This would enable a maven invocation
> from root, run exec:exec only for module1 and build all the needed
> submodules (parent and grandparent).
> I think it would be nice to also include your scenario: mvn -pl
> :module1,:parent -am exec:exec. This would run exec:exec in all modules,
> except for the grandparent module.
>
> That said, your first bullet point would work currently, and
> would give you the cleanest cli invocation (no need for -pl and -am).
> I don't think your last bullet point is possible, at least I have not seen
> this yet.
>
> Regards,
> Martin
>
> [1] https://issues.apache.org/jira/browse/MNG-6118
>
> Op vr 17 jul. 2020 om 18:55 schreef Clément Guillaume
> <[hidden email]>:
>
>> Hi again,
>>
>> Thank you for the responses. I think I figured my problem.
>> Running the plugin on a specific module (changing work directory or using
>> -pl) was always working fine.
>> What I was trying to do was to run it for every module at once from the
>> parent directory.
>> And when defining the configuration in the parent, module1 and parent were
>> fine but obviously grandparent didn't know about it and exec:exec would
>> fail. In addition grandparent is the first to run and its failure hides
>> the
>> potential success of parent and module1.
>>
>> Now I'll try to find a way around this.
>> - Maybe defining a no-op exec:exec configuration in the grandparent.
>> - Could I do something like running a specific execution id and
>> skipping projects that don't have this execution id defined?
>>
>> On Fri, Jul 17, 2020 at 12:21 AM Anders Hammar <[hidden email]> wrote:
>>
>> > Also, what version of Maven is used? I think there was something
>> related to
>> > relative path for parent fixed in some version.
>> >
>> > /Anders
>> >
>> > On Fri, Jul 17, 2020 at 9:18 AM Martin Kanters <
>> [hidden email]>
>> > wrote:
>> >
>> > > You are right! My bad, I haven't used pluginManagement that much.
>> > > I verified that `mvn exec:exec` in the module1 child project works
>> with
>> > the
>> > > example project that Clément gave (including the pluginManagement
>> > change).
>> > >
>> > > I also verified that if you put the pluginManagement part in the
>> > > "grandparent", it still works.
>> > > It is quite an unusual setup I think to include "grandparent" pom as a
>> > > submodule to the root pom (or "parent" pom in this case), but somehow
>> > it's
>> > > valid.
>> > >
>> > > Clément, as you are saying that your test project didn't work for you,
>> > are
>> > > you executing `mvn exec:exec` or something different?
>> > >
>> > > Martin
>> > >
>> > >
>> > > Op vr 17 jul. 2020 om 09:01 schreef Anders Hammar <[hidden email]
>> >:
>> > >
>> > > > On Fri, Jul 17, 2020 at 7:58 AM Martin Kanters <
>> > [hidden email]
>> > > >
>> > > > wrote:
>> > > >
>> > > > > The <pluginManagement> section, much like the
>> <dependencyManagement>
>> > > > > section, is a place where you can define "blueprints". The child
>> POMs
>> > > can
>> > > > > then activate this plugin by adding the plugin normally, with
>> limited
>> > > > > configuration.
>> > > > > In your example your parent pom (/pom.xml) is great. To activate
>> it
>> > you
>> > > > > would have to add this in /module1/pom.xml:
>> > > > >
>> > > > > <build>
>> > > > >   <plugins>
>> > > > >     <plugin>
>> > > > >       <groupId>org.codehaus.mojo</groupId>
>> > > > >       <artifactId>exec-maven-plugin</artifactId>
>> > > > >     </plugin>
>> > > > >   </plugins>
>> > > > > </build>
>> > > > >
>> > > >
>> > > > I'm fairly sure this is not required. The build/plugins section is
>> for
>> > > > binding to the build lifecycle, but when you execute a mojo directly
>> > > (like
>> > > > maven exec:exec) the build lifecycle is not executed. I like to view
>> > this
>> > > > as there are actually two ways of using Maven:
>> > > > 1) As a build tool. You execute the build lifecycle, like "mvn
>> verify".
>> > > > 2) As a utility tool. You then execute a specific mojo, that could
>> do
>> > > > pretty much anything. Like "mvn exec:exec".
>> > > >
>> > > > Thinking harder about this specific scenario (which I don't really
>> > > > understand though, why two parents in the same build?), I believe
>> that
>> > > the
>> > > > problem could be that the build lifecycle is not executed. Thus,
>> there
>> > is
>> > > > no reactor and then the grand-parent might be retrieved from the
>> local
>> > > repo
>> > > > instead of from the subfolder (if you execute from the root folder).
>> > I.e.
>> > > > the relative path specified doesn't work. Just guessing here...
>> > > >
>> > > > What you could do is inspect the effective pom ("mvn
>> > help:effective-pom")
>> > > > and verify that the maven-exec-plugin configuration exists (in the
>> > > > pluginManagement section).
>> > > >
>> > > > /Anders
>> > > >
>> > > >
>> > > > >
>> > > > > Then, when executing the command mvn exec:exec in the /module1/
>> > > > directory,
>> > > > > you will see:
>> > > > > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
>> > > test-cli-module1
>> > > > > ---
>> > > > > hello world jar
>> > > > >
>> > > > > It would also work if you put this pluginManagement section in
>> your
>> > > > > "grand-parent" pom.
>> > > > >
>> > > > > Hope that helps,
>> > > > > Martin
>> > > > >
>> > > > > Op vr 17 jul. 2020 om 00:49 schreef Clément Guillaume
>> > > > > <[hidden email]
>> > > > > >:
>> > > > >
>> > > > > > Hum, I tried that
>> > > > > > <
>> > > > > >
>> > > > >
>> > > >
>> > >
>> >
>> https://github.com/guillaumecle/maven-configuration-test/commit/8b8caabd93a799dd5d68346338b5fa02c899cc8d
>> > > > > > >
>> > > > > > and it still not working
>> > > > > >
>> > > > > > On Thu, Jul 16, 2020 at 12:16 AM Anders Hammar <
>> [hidden email]>
>> > > > > wrote:
>> > > > > >
>> > > > > > > If you want to be able to execute the plugin from commandline
>> > (like
>> > > > > "mvn
>> > > > > > > exec:exec) and use the plugin config from the pom, the
>> > > configuration
>> > > > > > needs
>> > > > > > > to be in the pluginManagement section. Change that and it
>> should
>> > > work
>> > > > > > > regardless if it's in the parent or the "grand-parent".
>> > > > > > >
>> > > > > > > /Anders
>> > > > > > >
>> > > > > > > On Thu, Jul 16, 2020 at 3:22 AM Clément Guillaume
>> > > > > <[hidden email]
>> > > > > > >
>> > > > > > > wrote:
>> > > > > > >
>> > > > > > > > Hello,
>> > > > > > > >
>> > > > > > > > I have a setup with 2 parent poms, one being the parent of
>> the
>> > > > other.
>> > > > > > > > I'm not able to run a plugin configuration (the
>> configuration
>> > is
>> > > > not
>> > > > > > > found)
>> > > > > > > > from command line if it's defined in the (first level)
>> parent
>> > > pom.
>> > > > > > > > But it does work if the configuration is defined in the
>> > > > "grandparent"
>> > > > > > > pom..
>> > > > > > > >
>> > > > > > > > Is it a bug, or designed to be like that?
>> > > > > > > > If it's designed to be like that, am I missing something to
>> get
>> > > the
>> > > > > > > > configuration defined in my parent pom to be recognized?
>> > > > > > > >
>> > > > > > > > Here is a sample project to reproduce
>> > > > > > > > https://github.com/guillaumecle/maven-configuration-test
>> > > > > > > (test-cli-parent
>> > > > > > > > has the configuration for exec:exec but it's not found)
>> > > > > > > >
>> > > > > > > > mvn exec:exec
>> > > > > > > > > [INFO] Scanning for projects...
>> > > > > > > > > [INFO]
>> > > > > > > > >
>> > > > > > >
>> > > > >
>> > >
>> ------------------------------------------------------------------------
>> > > > > > > > > [INFO] Reactor Build Order:
>> > > > > > > > > [INFO]
>> > > > > > > > > [INFO] test-cli-grand-parent
>> > > > > > > > >  [pom]
>> > > > > > > > > [INFO] test-cli-parent
>> > > > > > > > >  [pom]
>> > > > > > > > > [INFO] test-cli-module1
>> > > > > > > > > [jar]
>> > > > > > > > > [INFO]
>> > > > > > > > > [INFO] ----------------<
>> bzh.guillaume:test-cli-grand-parent
>> > > > > > > > > >-----------------
>> > > > > > > > > [INFO] Building test-cli-grand-parent 0.0.1-SNAPSHOT
>> > > > > > > > >  [1/3]
>> > > > > > > > > [INFO] --------------------------------[ pom
>> > > > > > > > > ]---------------------------------
>> > > > > > > > > [INFO]
>> > > > > > > > > [INFO] --- exec-maven-plugin:3.0.0:exec (default-cli) @
>> > > > > > > > > test-cli-grand-parent ---
>> > > > > > > > > [INFO]
>> > > > > > > > >
>> > > > > > >
>> > > > >
>> > >
>> ------------------------------------------------------------------------
>> > > > > > > > > [INFO] Reactor Summary for test-cli-parent 0.0.1-SNAPSHOT:
>> > > > > > > > > [INFO]
>> > > > > > > > > [INFO] test-cli-grand-parent
>> ..............................
>> > > > > FAILURE [
>> > > > > > > > >  0.586 s]
>> > > > > > > > > [INFO] test-cli-parent
>> ....................................
>> > > > SKIPPED
>> > > > > > > > > [INFO] test-cli-module1
>> ...................................
>> > > > SKIPPED
>> > > > > > > > > [INFO]
>> > > > > > > > >
>> > > > > > >
>> > > > >
>> > >
>> ------------------------------------------------------------------------
>> > > > > > > > > [INFO] BUILD FAILURE
>> > > > > > > > > [INFO]
>> > > > > > > > >
>> > > > > > >
>> > > > >
>> > >
>> ------------------------------------------------------------------------
>> > > > > > > > > [INFO] Total time:  1.034 s
>> > > > > > > > > [INFO] Finished at: 2020-07-15T18:09:15-07:00
>> > > > > > > > > [INFO]
>> > > > > > > > >
>> > > > > > >
>> > > > >
>> > >
>> ------------------------------------------------------------------------
>> > > > > > > > > [ERROR] Failed to execute goal
>> > > > > > > > > org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
>> (default-cli)
>> > on
>> > > > > > project
>> > > > > > > > > test-cli-grand-parent: The parameter 'executable' is
>> missing
>> > or
>> > > > > > invalid
>> > > > > > > > ->
>> > > > > > > > > [Help 1]
>> > > > > > > > > [ERROR]
>> > > > > > > > > [ERROR] To see the full stack trace of the errors, re-run
>> > Maven
>> > > > > with
>> > > > > > > the
>> > > > > > > > > -e switch.
>> > > > > > > > > [ERROR] Re-run Maven using the -X switch to enable full
>> debug
>> > > > > > logging.
>> > > > > > > > > [ERROR]
>> > > > > > > > > [ERROR] For more information about the errors and possible
>> > > > > solutions,
>> > > > > > > > > please read the following articles:
>> > > > > > > > > [ERROR] [Help 1]
>> > > > > > > > >
>> > > > > > >
>> > > > >
>> > >
>> http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
>> > > > > > > >
>> > > > > > > >
>> > > > > > > > Thank you,
>> > > > > > > >
>> > > > > > >
>> > > > > >
>> > > > >
>> > > >
>> > >
>> >
>>
>