You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Enrico Olivelli <eo...@gmail.com> on 2020/01/05 16:30:59 UTC

Multiple executions of Maven with a single run

Hello,
Sometimes it happens that you have to launch twice Maven to:
- build a whole reactor project (warmup)
- run some specific mojo only a selection of modules

mvn clean install -DskipTests -Dmaven.repo.local=tmprepo

mvn do:something -pl module1,module1-Dmaven.repo.local=tmprepo

I think that in the general case there is no way to do this with one single
execution of Maven, for instance from CI.

I am thinking about a simple enhancement to workaround this problem:
We can let Maven executable to accept a list of command line execution
arguments and loop executing the list, halting at the first failure

Re: Multiple executions of Maven with a single run

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Out of my head, reusing the cli/clibuilder was easier and avoids all the
fork config we want to avoid for such command but guess both work.

Le sam. 11 janv. 2020 à 14:11, Enrico Olivelli <eo...@gmail.com> a
écrit :

> Romain
>
> Il giorno dom 5 gen 2020 alle ore 18:14 Romain Manni-Bucau <
> rmannibucau@gmail.com> ha scritto:
>
> > Hi Enrico
> >
> > Technically concatenating all goals for all modules will do it but will
> be
> > quite long - guess it is why we do it in 2 times.
> >
> > That said i always wondered why maven can read commands from a file/stdin
> > as any unix like soft so it would be something like:
> >
> > mvn --commands-file ci.cmdlist
> >
> > Using stdin/echo it would also match ypur ci need maybe?
> >
>
> (I am sorry, It seems that my original email was truncated or the email
> client sent some draft of the email.)
>
> This is exactly my second proposal.
>
> Currently I am also thinking that this can simply be a new mojo of the
> 'invoker' plugin
>
> mvn invoker:commandlist -Dcommandlist=/path/tofile
> or getting the list from stdin
>
> I have never dug into invoker but it seems to me that it should have all of
> the facilities to perform this task.
> The only challenge I see is about Java System properties to be set at
> bootstrap time, like -Dfile.encoding....
> but the Invoker plugin may fork new JVMs so it should not be a big problem
> and btw it is a secondary issue
>
> Enrico
>
>
>
>
>
> >
> >
> > Le dim. 5 janv. 2020 à 17:31, Enrico Olivelli <eo...@gmail.com> a
> > écrit :
> >
> > > Hello,
> > > Sometimes it happens that you have to launch twice Maven to:
> > > - build a whole reactor project (warmup)
> > > - run some specific mojo only a selection of modules
> > >
> > > mvn clean install -DskipTests -Dmaven.repo.local=tmprepo
> > >
> > > mvn do:something -pl module1,module1-Dmaven.repo.local=tmprepo
> > >
> > > I think that in the general case there is no way to do this with one
> > single
> > > execution of Maven, for instance from CI.
> > >
> > > I am thinking about a simple enhancement to workaround this problem:
> > > We can let Maven executable to accept a list of command line execution
> > > arguments and loop executing the list, halting at the first failure
> > >
> >
>

Re: Multiple executions of Maven with a single run

Posted by Enrico Olivelli <eo...@gmail.com>.
Romain

Il giorno dom 5 gen 2020 alle ore 18:14 Romain Manni-Bucau <
rmannibucau@gmail.com> ha scritto:

> Hi Enrico
>
> Technically concatenating all goals for all modules will do it but will be
> quite long - guess it is why we do it in 2 times.
>
> That said i always wondered why maven can read commands from a file/stdin
> as any unix like soft so it would be something like:
>
> mvn --commands-file ci.cmdlist
>
> Using stdin/echo it would also match ypur ci need maybe?
>

(I am sorry, It seems that my original email was truncated or the email
client sent some draft of the email.)

This is exactly my second proposal.

Currently I am also thinking that this can simply be a new mojo of the
'invoker' plugin

mvn invoker:commandlist -Dcommandlist=/path/tofile
or getting the list from stdin

I have never dug into invoker but it seems to me that it should have all of
the facilities to perform this task.
The only challenge I see is about Java System properties to be set at
bootstrap time, like -Dfile.encoding....
but the Invoker plugin may fork new JVMs so it should not be a big problem
and btw it is a secondary issue

Enrico





>
>
> Le dim. 5 janv. 2020 à 17:31, Enrico Olivelli <eo...@gmail.com> a
> écrit :
>
> > Hello,
> > Sometimes it happens that you have to launch twice Maven to:
> > - build a whole reactor project (warmup)
> > - run some specific mojo only a selection of modules
> >
> > mvn clean install -DskipTests -Dmaven.repo.local=tmprepo
> >
> > mvn do:something -pl module1,module1-Dmaven.repo.local=tmprepo
> >
> > I think that in the general case there is no way to do this with one
> single
> > execution of Maven, for instance from CI.
> >
> > I am thinking about a simple enhancement to workaround this problem:
> > We can let Maven executable to accept a list of command line execution
> > arguments and loop executing the list, halting at the first failure
> >
>

Re: Multiple executions of Maven with a single run

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

Technically concatenating all goals for all modules will do it but will be
quite long - guess it is why we do it in 2 times.

That said i always wondered why maven can read commands from a file/stdin
as any unix like soft so it would be something like:

mvn --commands-file ci.cmdlist

Using stdin/echo it would also match ypur ci need maybe?


Le dim. 5 janv. 2020 à 17:31, Enrico Olivelli <eo...@gmail.com> a
écrit :

> Hello,
> Sometimes it happens that you have to launch twice Maven to:
> - build a whole reactor project (warmup)
> - run some specific mojo only a selection of modules
>
> mvn clean install -DskipTests -Dmaven.repo.local=tmprepo
>
> mvn do:something -pl module1,module1-Dmaven.repo.local=tmprepo
>
> I think that in the general case there is no way to do this with one single
> execution of Maven, for instance from CI.
>
> I am thinking about a simple enhancement to workaround this problem:
> We can let Maven executable to accept a list of command line execution
> arguments and loop executing the list, halting at the first failure
>

Re: Multiple executions of Maven with a single run

Posted by Robert Scholte <rf...@apache.org>.
If you want to execute a plugin goal apart from a lifecycle, then I think it should be for only one module.
So I'd expect the call more to be like -pl module -am
That said, if you know you want to execute this goal for 1 specific module, I would like to be able to start from that pom and run "mvn verify do:something -am".
With -am you trigger Maven to include all modules below the .mvn folder (the existence of this folder will be a requirement).
And for Maven 5 or 6 "mvn do:something" might be all you need.
I'm not sure if there's already a JIRA issue for it, but it feels more natural: go to the specific module and run the plugin goal from there. Maven can get all the requirement stuff from there.

thanks,
Robert
On 5-1-2020 17:31:17, Enrico Olivelli <eo...@gmail.com> wrote:
Hello,
Sometimes it happens that you have to launch twice Maven to:
- build a whole reactor project (warmup)
- run some specific mojo only a selection of modules

mvn clean install -DskipTests -Dmaven.repo.local=tmprepo

mvn do:something -pl module1,module1-Dmaven.repo.local=tmprepo

I think that in the general case there is no way to do this with one single
execution of Maven, for instance from CI.

I am thinking about a simple enhancement to workaround this problem:
We can let Maven executable to accept a list of command line execution
arguments and loop executing the list, halting at the first failure