Along with the clean
and default
lifecycle, Maven also consists of a site
lifecycle. Like clean
, site
is implemented by a Maven plugin, in this case, the Maven Site plugin.
Maven is set up on your system and is verified for work. To do this, refer to the first three recipes of Chapter 1, Getting Started.
Site
is one of the Maven lifecycles. When the mvn site
command is run, it invokes the site
phase of the site
lifecycle. The site
goal of the Maven Site plugin is bound to this phase and is invoked.
The site
goal performs a series of steps to generate the report. It uses various elements in the pom file related to this. Let us look at the various items in the default report:
In addition to this, the site
command generates reports based on the contents of the reporting
section of the pom:
<reporting> <plugins> <plugin> <artifactId>maven-project-info-reports-plugin</artifactId> <version>2.0.1</version> <reportSets> <reportSet></reportSet> </reportSets> </plugin> </plugins> </reporting>
A number of Maven plugins can generate reports defined and configured under the reporting
element. We will see many reports in the following sections.
We have only seen what the default site
command offers. The Maven Site plugin offers various configurations to make many more customizations. Some of them are as follows:
Let us see how to do some of these:
site.xml
file with the following content to the srcsite
folder of the project-with-documentation
project folder:<project xmlns="http://maven.apache.org/DECORATION/1.6.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/DECORATION/1.6.0 http://maven.apache.org/xsd/decoration-1.6.0.xsd" name="Project with Documentation"> <bannerLeft> <name>Left Banner</name> <src>images/packt.png</src> <href>http://www.packtpub.com</href> </bannerLeft> <body> <menu name="Project with Documentation"> <item name="Overview" href="EB9781785286124_3.html"/> </menu> <menu ref="reports"/> </body> </project>
packt.png
to the srcsite
esourcesimages
folder.index.apt
file in the srcsiteapt
folder with the following content:Welcome to Project with Documentation. This is a maven project created as part of apache maven cookbook by Packt Publishing. What is Project with Documentation? This maven project contains examples of how to use the site feature of maven.
mvn clean site
You can see a customized site page with the logo and the content that we specified.
18.118.198.81