I'm not familiar with Maven Invoker, but the Maven Invoker Plugin does not
have such code.
It will call setMavenHome only if there's a configured value:
https://github.com/apache/maven-invoker-plugin/blob/dfd3c3680f31cb36ef1c14c18f4ea8b8d6115151/src/main/java/org/apache/maven/plugins/invoker/AbstractInvokerMojo.java#L2104-L2109
See also
https://maven.apache.org/shared/maven-invoker/usage.html#Configuring_the_Maven_Home_Directory:
“You can use the method Invoker.setMavenHome() to specify which Maven
executable it should use. If you don't provide an explicit value for this
setting, the Invoker will automatically try to detect a Maven installation
by evaluating the system property maven.home and the environment variable
M2_HOME.”

On Mon, Nov 2, 2020 at 1:00 PM Nick Stolwijk <nick.stolw...@gmail.com>
wrote:

> Thanks,
>
> I looked at the Maven Release Plugin and I see that the logic of where
> Maven is installed is not in the Maven-Invoker, but in the release plugin
> [1]. There is some logic on how to 'find' Maven, using environment
> variables like 'maven.home', 'MAVEN_HOME' and 'M2_HOME'. Does this mean
> that the choice of which setting is used and in which order is still the
> responsibility of the calling plugin? Or is there some standard for that?
>
> [1]
>
> https://github.com/apache/maven-release/blob/dbdf3a4a8cb8db51fa73963912555be4f39a89b8/maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/InvokerMavenExecutor.java#L318
>
> With regards,
>
> Nick Stolwijk
>
> ~~~ Try to leave this world a little better than you found it and, when
> your turn comes to die, you can die happy in feeling that at any rate you
> have not wasted your time but have done your best ~~~
>
> Lord Baden-Powell
>
>
> On Mon, Nov 2, 2020 at 12:27 PM Thomas Broyer <t.bro...@gmail.com> wrote:
>
> > Maybe have a look at Maven Invoker:
> > https://maven.apache.org/shared/maven-invoker/
> > (it's what the Maven Invoker Plugin and Maven Release Plugin use)
> >
> > On Mon, Nov 2, 2020 at 11:28 AM Nick Stolwijk <nick.stolw...@gmail.com>
> > wrote:
> >
> > > Hi folks,
> > >
> > > We are struggling with our buildserver (Jenkins) and the Git-Flow Maven
> > > Plugin[1] with regards to execute the Maven executable to run specific
> > > goals and phases during release (i.e. run versions plugin to change
> > version
> > > or run `mvn verify` to check project).
> > >
> > > The gitflow-m-p uses a flag to set the executable which needs to know
> if
> > it
> > > is on Linux (run mvn) or Windows (run mvn.cmd).
> > >
> > > I was wondering what is the 'right' way to execute Maven from a plugin.
> > > I've taken a look at the Maven Release Plugin and that one uses an
> > internal
> > > Executor framework. I have thought about Toolchain, but I didn't find
> an
> > > example of a toolchain with Maven itself.
> > >
> > > Can anyone enlighten me?
> > >
> > > [1] https://github.com/aleksandr-m/gitflow-maven-plugin
> > >
> > > With regards,
> > >
> > > Nick Stolwijk
> > >
> > > ~~~ Try to leave this world a little better than you found it and, when
> > > your turn comes to die, you can die happy in feeling that at any rate
> you
> > > have not wasted your time but have done your best ~~~
> > >
> > > Lord Baden-Powell
> > >
> >
> >
> > --
> > Thomas Broyer
> > /tɔ.ma.bʁwa.je/ <http://xn--nna.ma.xn--bwa-xxb.je/> <
> http://xn--nna.ma.xn--bwa-xxb.je/> <
> > http://xn--nna.ma.xn--bwa-xxb.je/>
> >
>


-- 
Thomas Broyer
/tɔ.ma.bʁwa.je/ <http://xn--nna.ma.xn--bwa-xxb.je/>

Reply via email to