Within a Maven project it is easy to create a project site. We need to create the src/site
directory and place a site.xml
file in it. Here is a very simple and basic site.xml
:
<?xml version="1.0" encoding="UTF-8"?> <project name="app"/>
And of course we can add content files for the project site. To generate the site we only have to run mvn site
. And if we use NetBeans we can generate the site with a mouse click.
In our Maven project we have a Project site node. If we right-click on the node we get the following pop-up menu:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRLoD3yH52w-zJ9A9Mm56uOobIoGjCsQExxQ_lbD6yYC_Reys7zQh3VuJTMn6YD5XNHeFkRnFzhi0XB5J79eFS61V7k3gw-RXcOnagWHIfFa3BSi-nh9TYKvVOQjwKhB86VEO8johysxEb/s320/mavensite1.png)
We notice the options Generate Site and Deploy Site. If we select Generate Site we get a dialog window with the Maven command that is about to run:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW_oo-8kwTf_a6n8JvfyFG_FuI1fa4Gd1RpvXd3zlQNizX6QTPIKLCA5tbnKDqX0EK421YUbQ1GCXT71qCEJYZ06dCMKrw7xM25qRLoDJiXmJ34kqjBGSjZGIaZX-TaHViEaWTOEQaKyK9/s320/mavensite2.png)
We could change some fields here, but most of the time we just press the OK button. And the project site is generated. The generated site is placed in the target/site
directory. If we look at the output window and see the Maven output we notice a link View Generated Project Site:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhk3JFNnK8iTiMWWpeYWl2ZKiTzVDJMUoRJvNyedBQgFOYq-xwwzDyQVLV9tphpZSZOPhK30FtRTItEDN3MtgqMydbwIzBjZA1098vhdOAqBdU66ZJvb5NbH-yzhx5TJxRWfPRa50A2A70P/s320/mavensite3.png)
We can click on this link and NetBeans will open the site's index.html file in a web browser.
We can also deploy the project site to a web server with the Deploy Site option from the pop-up menu. This command is executed immediately by NetBeans and the if the configuration in our pom.xml
is correct, the site is deploy to a web server.