Maven: site and install interchangable?

197 views Asked by At

In Maven, does mvn site install essentially the same as mvn install site, or does the first one generate a site from the previous install?

To be more precise: Is site independent from install or does site include results that were generated from install?

2

There are 2 answers

5
DamCx On

Maven executes the goals in the order you give it, so it will site the previous install then do the new install

Another simple exemple to prove it is to make a mvn install clean and you will see the result as all targets will be removed by the end of the build

0
Marinos An On

By design, plugin goals that can be used as part of site generation ( site lifecycle), will either not require the execution of default lifecycle or they will trigger it automatically. Most of them are "reporting" goals. e.g. when javadoc is added in <reporting> section, it will additionally trigger the default lifecycle, when the user executes mvn site.

So in general install does not need to be executed before site.
Possible exceptions can be:

  • A reporting plugin expects some input that is generated on the default lifecycle, but it does not trigger that lifecycle. In that case you should trigger the default lifecycle manually.
  • A custom operation involving copy or download of a site resource is attached to a default lifecycle phase. Again you should trigger the default lifecycle manually.

Example:

Let's say you want to include the README.md (located on the root of your project) to the site. You will need to copy it inside src/site/markdown before the site generation.
For this you can use copy-resources goal from resources plugin.

Then you need to specify an execution phase for copy-resources:

  • Declaring process-resources as execution phase: then mvn process-resources site (or mvn install site) is required, and the opposite won't work.
  • Declaring pre-site as execution phase (which is more correct): then mvn site will be enough (since pre-site is a phase of site lifecycle and will be executed anyway).