You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by st...@tolina.com on 2011/03/30 12:37:39 UTC
changing a long mvn command with many goals to a simple command?
To generate a site, using the clover and dashboard plugin currently I need
to use the following command-line:
mvn clover2:setup site clover2:aggregate clover2:clover
dashboard:dashboard site:deploy
(this is to overcome some problems with the site-plugin, which in
multi-module builds seems to have problems running some targets after all
children have been built).
Is there any way to shorten this to a simple command, like
mvn doMyFullSite
I could of course use a shell-script, but I had to copy this to any
multi-module build, which I want to avoid ("don't repeat yourself").
I'd rather prefer to have a construct that I can embed in my parent-pom.
I gave the maven-invoker-plugin a try, just bound to the initialize phase
and put into a profile, so I could start it with
mvn -PdoMyFullSite
(see snippet of the configuration below).
BUT: in a multimodule build now these targets are run for every child as
well, so this is not what I want :(
Any other ideas ?
-- invoker-plugin-configuration ---------
<profile>
<id>doMyFullSite</id>
<build>
<defaultGoal>initialize</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<pom>pom.xml</pom>
<noLog>true</noLog>
<streamLogs>true</streamLogs>
<suppressSummaries>true</suppressSummaries>
</configuration>
<executions>
<execution>
<id>doItAll</id>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<goals>
<goal>clover2:setup</goal>
<goal>site</goal>
<goal>clover2:aggregate</goal>
<goal>clover2:clover</goal>
<goal>dashboard:dashboard</goal>
<goal>site:deploy</goal>
</goals>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
-------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Re: changing a long mvn command with many goals to a simple command?
Posted by Stephen Connolly <st...@gmail.com>.
Also it is important to note that this trick only works if the profile
id contains the string "-superugly-hack"
On 30 March 2011 12:34, Stephen Connolly
<st...@gmail.com> wrote:
> At the root project create a profile for running these tasks, e.g.
>
> <profile>
> <id>my-superugly-hack</id>
> ...
> </profile>
>
> into that profile you put a <build> section with a <defaultGoal>
> containing all the stuff you want to do separated by spaces
>
> ideally you would also configure all the executions and the
> default-cli executions of the mojos you are invoking directly
>
> then
>
> mvn -Pmy-superugly-hack
>
> and your grandmother has just given birth to a boy... she'll calling him bob.
>
> -Stephen
> On 30 March 2011 12:14, <st...@tolina.com> wrote:
>>>> Bind the goals you want to run to chosen phases.
>>
>> This unfortuntaly is not possible in a multimodule build, let's take the
>> dashboard plugin as an example:
>>
>> The dashboard:dashboard needs to run AFTER the full site has been created
>> in a multimodule build (because it needs access to all checkstyle.xml of
>> all child builds).
>> This is because if it is just bound to some phase it would run in the
>> following order:
>>
>> Parent-Build: dashboard (<= empty, as the dashboard want's to aggregate
>> sub-builds, which didn't run yet)
>> Child-Build1: dashboard (creates a dashboard for that child)
>> Child-Build2: dashboard (dito)
>> Build succesful.
>>
>> Now unfortunately the dashboard-report for the Parent-Build is still empty
>> (and actually it's the most important report aggregating all others and
>> giving a good overview).
>> That's why
>> dashboard:dashboard
>> is run as a seperate goal after the full buildcycle: it is then able to
>> get any report it want's to aggregate.
>>
>> It's the same with clover. On the parent-level to create a report, the
>> childs need to be build first, for clover to be able to create a report
>> aggregating all childs.
>> Unfortunately maven decides not to build the childs first before running
>> the life-cycle for the parent.
>>
>> Regards
>> Stefan
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: changing a long mvn command with many goals to a simple command?
Posted by st...@tolina.com.
Was happy too soon.
If I move the invoker plugin profile to my company-parent pom, then all
steps to remove the recursion problem make it not work anymore for my
multimodule build :(
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Antwort: Re: changing a long mvn command with many goals to a simple
command?
Posted by st...@tolina.com.
>> 1. needs to be bound in a non-default profile
>> 2. needs to have <inherited>false</inherited> to stop the child
>> projects running invoker
>> 3. need to set invoker.nonRecursive or invoker.nonRecursive.N where N
>> is the invokation you want only on the root pom.
Now invoker plugin is doing what I want now!
Thanks a lot!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: changing a long mvn command with many goals to a simple command?
Posted by Stephen Connolly <st...@gmail.com>.
On 30 March 2011 13:27, <st...@tolina.com> wrote:
>>> Please always keep replies on the list for future queries.
> Sorry, answered to the wrong mail, will keep an eye on it in the future.
>
>>> Maven invoker plugin could do what you want... you would bind it in a
>>> profile to e.g. the validate phase of the lifecycle. then you can use
>>> defaultGoal as validate and have invoker invoke all that you need....
>
> I tried that first! (see the config from my first post)
> But in a multimodule build I get an unwanted recursion.
1. needs to be bound in a non-default profile
2. needs to have <inherited>false</inherited> to stop the child
projects running invoker
3. need to set invoker.nonRecursive or invoker.nonRecursive.N where N
is the invokation you want only on the root pom.
>
> Think of invoker plugin, bound to validate, just calling 'site'.
> Now running:
>
> mvn -PinvokerPluginCallingSite
>
> starts a reactor build with the phase validate in the following order:
> [INFO] -----------------------------------------
> [INFO] Reactor Build Order:
> [INFO]
> [INFO] Master
> [INFO] MasterSub1
> [INFO] MasterSub2
> [INFO]
>
> and now invoker-plugin calls site for
> Master => (still a full multimodule build, which runs site for Master,
> MasterSub1, MasterSub2)
> MasterSub1 => (unwanted extra site)
> MasterSub2 => (unwanted extra site)
>
> That's why I didn't succeed with the invoker plugin.
>
> Cheers
> Stefan
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: changing a long mvn command with many goals to a simple command?
Posted by st...@tolina.com.
>> Please always keep replies on the list for future queries.
Sorry, answered to the wrong mail, will keep an eye on it in the future.
>> Maven invoker plugin could do what you want... you would bind it in a
>> profile to e.g. the validate phase of the lifecycle. then you can use
>> defaultGoal as validate and have invoker invoke all that you need....
I tried that first! (see the config from my first post)
But in a multimodule build I get an unwanted recursion.
Think of invoker plugin, bound to validate, just calling 'site'.
Now running:
mvn -PinvokerPluginCallingSite
starts a reactor build with the phase validate in the following order:
[INFO] -----------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Master
[INFO] MasterSub1
[INFO] MasterSub2
[INFO]
and now invoker-plugin calls site for
Master => (still a full multimodule build, which runs site for Master,
MasterSub1, MasterSub2)
MasterSub1 => (unwanted extra site)
MasterSub2 => (unwanted extra site)
That's why I didn't succeed with the invoker plugin.
Cheers
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: changing a long mvn command with many goals to a simple command?
Posted by Stephen Connolly <st...@gmail.com>.
Please always keep replies on the list for future queries.
On 30 March 2011 12:56, <st...@tolina.com> wrote:
>>> At the root project create a profile for running these tasks, e.g.
>>>
>>> <profile>
>>> <id>my-superugly-hack</id>
>>> ...
>>> </profile>
>
>>> into that profile you put a <build> section with a <defaultGoal>
>>> containing all the stuff you want to do separated by spaces
>
> Yes - works as expected, thank you very much!
>
> Care to elaborate why you consider this to be a superugly-hack?
>
> - because I have to call so many goals to circumvent maven limitations (at
> least I didn't find another way yet), or
Nope
> - because using a profile this way is not recommended or
More that specifying anything other than a single lifecycle phase is
not supposed to be supported IIRC... so you are relying on a bug =>
hack
> - both ?
>
> If anyone tells me another way how to call some goals after all childs
> have been built, I'm happy to use this instead!
Maven invoker plugin could do what you want... you would bind it in a
profile to e.g. the validate phase of the lifecycle. then you can use
defaultGoal as validate and have invoker invoke all that you need....
Note that you may run into issues if you require to fetch something
out of the reactor for your subsequent invokations... but at least you
can have invoker invoke all the goals in one go... and that is a
supported way to invoke multiple goals
>
> Cheers
> Stefan
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Re: changing a long mvn command with many goals to a simple command?
Posted by Stephen Connolly <st...@gmail.com>.
At the root project create a profile for running these tasks, e.g.
<profile>
<id>my-superugly-hack</id>
...
</profile>
into that profile you put a <build> section with a <defaultGoal>
containing all the stuff you want to do separated by spaces
ideally you would also configure all the executions and the
default-cli executions of the mojos you are invoking directly
then
mvn -Pmy-superugly-hack
and your grandmother has just given birth to a boy... she'll calling him bob.
-Stephen
On 30 March 2011 12:14, <st...@tolina.com> wrote:
>>> Bind the goals you want to run to chosen phases.
>
> This unfortuntaly is not possible in a multimodule build, let's take the
> dashboard plugin as an example:
>
> The dashboard:dashboard needs to run AFTER the full site has been created
> in a multimodule build (because it needs access to all checkstyle.xml of
> all child builds).
> This is because if it is just bound to some phase it would run in the
> following order:
>
> Parent-Build: dashboard (<= empty, as the dashboard want's to aggregate
> sub-builds, which didn't run yet)
> Child-Build1: dashboard (creates a dashboard for that child)
> Child-Build2: dashboard (dito)
> Build succesful.
>
> Now unfortunately the dashboard-report for the Parent-Build is still empty
> (and actually it's the most important report aggregating all others and
> giving a good overview).
> That's why
> dashboard:dashboard
> is run as a seperate goal after the full buildcycle: it is then able to
> get any report it want's to aggregate.
>
> It's the same with clover. On the parent-level to create a report, the
> childs need to be build first, for clover to be able to create a report
> aggregating all childs.
> Unfortunately maven decides not to build the childs first before running
> the life-cycle for the parent.
>
> Regards
> Stefan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Antwort: Re: changing a long mvn command with many goals to a simple
command?
Posted by st...@tolina.com.
>> Bind the goals you want to run to chosen phases.
This unfortuntaly is not possible in a multimodule build, let's take the
dashboard plugin as an example:
The dashboard:dashboard needs to run AFTER the full site has been created
in a multimodule build (because it needs access to all checkstyle.xml of
all child builds).
This is because if it is just bound to some phase it would run in the
following order:
Parent-Build: dashboard (<= empty, as the dashboard want's to aggregate
sub-builds, which didn't run yet)
Child-Build1: dashboard (creates a dashboard for that child)
Child-Build2: dashboard (dito)
Build succesful.
Now unfortunately the dashboard-report for the Parent-Build is still empty
(and actually it's the most important report aggregating all others and
giving a good overview).
That's why
dashboard:dashboard
is run as a seperate goal after the full buildcycle: it is then able to
get any report it want's to aggregate.
It's the same with clover. On the parent-level to create a report, the
childs need to be build first, for clover to be able to create a report
aggregating all childs.
Unfortunately maven decides not to build the childs first before running
the life-cycle for the parent.
Regards
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: changing a long mvn command with many goals to a simple
command?
Posted by "maxime.lem" <ma...@gmail.com>.
Bind the goals you want to run to chosen phases.
This is done in through build/plugins/plugin/executions/execution in your
pom
--
View this message in context: http://maven.40175.n5.nabble.com/changing-a-long-mvn-command-with-many-goals-to-a-simple-command-tp4271214p4271230.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org