Reference: Maven Site Mini-Guide
Let's look at a demonstration of a Maven project using the Patrodyne Site Skin, in detail. The pom.xml at the project root is a signature of any Maven project. The web page index is a convenient link to the site pages, more on that below. Next, we see a src folder containing all of the site files. Typically, the src folder contains two folders for Java source code, main and test; but, because the maven-site-plugin does not need these ubiquitous folders to generate a project web site, we will omit them from this demo.
patrodyne-site/demo |-- index.html |-- pom.xml |-- src | `-- site | |-- apt | | |-- index.apt | | `-- Todo.apt | |-- fml | | `-- faq.fml | |-- properties | | `-- css | | `-- ColorScheme-9BE893.properties | |-- resources | | `-- images | | `-- logos | | |-- SiteDemo.png | | `-- SiteDemo.txt | |-- site.xml | `-- templates | `-- css | `-- site.css
The Project Object Model is an XML file that contains information about the project and configuration details used by Maven to build the project. The Site Demo includes elements for a more informative web site:
This plugin generates a site for the project using reports configured within.
Look back to the pluginManagement configuration for this plugin to observe the output directory is set to the value of the $site.home property. That property is set in the properties section. It outputs the site to a folder in another project, a GitHub user (organization) project. We do this to centralize our sites under one GitHub repository. You can set $site.home property to a location to suit your deployment strategy.
In Maven 3, the reporting and reportSets sections have been deprecated (they won't cause an error with Maven 3, they will just be ignored), and have been replaced by a reportPlugins section in the configuration block of the maven-site-plugin itself.
For available reports, see Maven Project Info Reports Plugin
The Maven Changelog Plugin generates reports regarding the recent changes in your Software Configuration Management or SCM. These reports include:
Executing an Ant task is a powerful way to enhance how a site is generated.
FilterSite, we use the copy task with a filterset to copy src/site/templates/css/site.css to $site.home/css/site.css, at the same time, resolving color scheme properties provided by src/site/properties/css/ColorScheme-9BE893.properties. You can use other color schemes described at Color Schemes or create your own. This is an optional task, the default color scheme is F6D09C.
Important: Because site.css is generated from a template, your changes, if any, should be made to your project's copy of src/site/templates/css/site.css.
TweakSite is a task to normalize the end-of-line characters in the generated pages. It is an optional task.
CleanSite is executed when you do a mvn clean or mvn clean site. It deletes the generated web site.
The Maven Compiler Plugin is used to compile the sources of your project. The default compiler is javac and is used to compile Java sources. The default source setting is 1.5 and the default target setting is 1.5.
We include this plugin to set the default source/target settings to use Java 6; perhaps, it is time to bump that up to 1.7?
The Maven Jar Plugin provides the capability to build and sign jars.
We include this plugin to set the jar's manifest entries; but, this is quite optional.
At the base of our project is a simple index.html page to redirect a browser to the actual location for the site pages. In this case, the redirection is to a nearby project on our file system, ../../patrodyne.github.com/sites/site-demo/index.html. The site location for the demo is determined by a setting in the pom.xml. You can change this setting to a folder in the Site Demo project, say $basedir/site or anywhere else that suits your fancy.
At Patrodyne, we prefer to deploy all of our project sites under patrodyne.github.com which is sync'ed to our user (organization) page on GitHub. When deployed, this index.html is not used, we use it only during development, as a convenience link.
Hints:
A Maven Site Descriptor is a XML file used by the Maven Site Plugin to configure the layout of a site.
Almost Plain Text (APT) is the easiest way to add content to your project's web site. APT is a lightweight markup language that uses simple punctuation conventions to generate web pages.
The Maven Site Plugin scans the apt folder and any sub-folders for *.apt documents. Each document is transformed into a web page and saved in the corresponding location of the generated site.
Generally, index.html is the default web page for any given folder. This index.apt document is a demonstration page.
After writing your index.apt document, you can add any number of content pages to describe and promote your work. This todo.apt list is example to get you started!!!
FAQ Markup Language (FML) is another way to generate web pages. This language is designed for answering frequently asked questions about your project. FML is an XML document with elements geared to presenting information in a question and answer format.
The Maven Site Plugin scans the fml folder and any sub-folders for *.fml documents. Each document is transformed into a web page and saved in the corresponding location of the generated site.
This faq.fml document answers a couple of frequently asked questions about Maven and serves as starting point for your own FAQ.
This folder and its sub-folders contain property files for filtering name-value pairs at build time.
The Patrodyne Site Skin uses a property file to bind color values to site.css. The file is defined in the pom.xml as a Ant filter. For Ant, a filter is a property substitution process associated with a task like the copy task.
The Site Demo uses a Color Scheme with a light green background (color code #9BE893). Our convention is to name the property file after the background color. We use an accented analogic color scheme where primary and complimentary colors are at opposite positions (180 degrees) of the color wheel and secondary colors are found at 30 degrees from either side of the primary color.
The contents of the resources folder are copied to the base of the site where they can be referenced using hyper-links.
Typically, the leftBanner element of site.xml is used to display a project logo. This image is the logo for the Site Demo.
We like to give credit to the services we use, SiteDemo.txt is a citation for CoolText. We use CoolText to create many of our project logos.
This folder and its sub-folders contain template files for merging name-value pairs at build time.
This site.css is a template containing Ant property names. At build time, the names are filtered and replaced with values from a property file specified in the pom.xml.