This tutorial introduces the site plugin, one of the core plugins of the Maven build tool.
For an overview of the other core plugins, refer to this tutorial.
2. Plugin Goals
The Maven site lifecycle has two phases bound to goals of the site plugin by default: the site phase is bound to the site goal, and the site-deploy phase is bound to the deploy goal.
Here are the descriptions of those goals:
- site – generate a site for a single project; the generated site only shows information about the artifacts specified in the POM
- deploy – deploy the generated site to the URL specified in the distributionManagement element of the POM
In addition to site and deploy, the site plugin has several other goals to customize the content of the generated files and to control the deployment process.
3. Goal Execution
We can use this plugin without adding it to the POM as the super POM already includes it.
To generate a site, just run mvn site:site or mvn site.
To view the generated site on a local machine, run mvn site:run. This command will deploy the site to a Jetty web server at the address localhost:8080.
The run goal of this plugin isn’t implicitly bound to a phase in the site lifecycle, hence we need to call it directly.
If we want to stop the server, we can simply hit Ctrl + C.
This article covered the site plugin and how to execute its goals.
We can find more information about this plugin on the Maven website.