Sites and Inheritence
Maven's support for sites that span multiple projects has generally been limited to date. The following are some features that will assist in this.
Requirements
- Inherited navigational elements
- Using submenus
- Ability to generate within the subproject, or at the top level and get the same results (with the exception of aggregated reports)
- No strict requirements on filesystem layout other than those that already exist for Maven projects
- Ability to aggregate reports (individual report technique out of scope here)
- Breadcrumbing
- Skinning
- Separation of user and developer documentation
- Separation of different releases in documentation
Proposed Solutions
Inherited Navigational Elements
The site descriptor will be deployed to the repository whenever the artifact is (through the deploy phase) or the site is (through the site-deploy phase). It will also be discoverable via the parent POM using ${basedir}/src/site/site.xml using the normal workspace location. When deployed to the repository, it will be located at /groupId/artifactId/version/artifactId-version-site.xml
.
We can add inherit="top|bottom|none"
to the menu
element, with none
as the default.
Code Block | ||||
---|---|---|---|---|
| ||||
<menu name="Commons Common"> <item ... /> </menu> <menu name="Commons Specifics" inherit="bottom"> <item ... /> </menu> |
Including Generated Content
Currently there are elements like ${reports} and ${modules} in the site descriptor. These will be deprecated in favour of:
Code Block | ||||
---|---|---|---|---|
| ||||
<!-- Include all info and reports --> <menu ref="reports" /> <menu ref="modules" /> |
~~TODO: not happy with this yet
Symmetric generation
When generating within the top level, content will be generated into the target/site
location of the subproject, using the difference between the top level URL and the subproject's URL as the relative path to use. It will not be possible to navigate between the sites on the filesystem - you must push to staging to achieve this.
When generated within the subproject, it is only generated into the subproject. The site will appear correctly, but navigating to upper levels will not be possible when previewing. However, it can be deployed from there directly into the right subdirectory on the site.
Filesystem layout constraints
The location of site.xml
relative to a project is determined by plugin configuration as normal, and defaults to src/site
. When locating a parent project, this is done using the normal workspaces/USD technique (using relativePath
in the POM, falling back to the repository. Parent project documents are not needed - only the site descriptor.
Report aggregation
Most of the work of this is covered in the individual plugins and the Maven Dashboard discussion, and is out of scope for this document. While the site mojo itself will not be an @aggregator, individual reports are free to do so and should behave correctly.
Breadcrumbing
Breadcrumbs will be stored in the <breadcrumbs />
element.
Code Block | ||||
---|---|---|---|---|
| ||||
<body> <breadcrumbs> <item href="http://www.apache.org/" name="Apache" /> <item name="Maven"/> <!-- href is derived from project.url --> </breadcrumbs> |
Note: Generally you'll only specify one breadcrumb, but it is a list to facilitate the root to have additional breadcrumbs that navigate back beyond the Maven hierachy.
By default, the name
element of the project will be used as the breadcrumb.
Skinning
Skinning support will provided by a separate artifact that contains CSS, images and is unpacked over a site. It can optionally contain a replacement /META-INF/maven/site.vm
velocity template for generating the final XHTML.
It is built as a normal JAR. To configure the skin in the client, add it to the site descriptor:
Code Block | ||||
---|---|---|---|---|
| ||||
<project> ... <skin> <groupId>org.apache.maven.skins</groupId> <artifactId>maven-default-skin</artifactId> <version>1.0</version> <!-- optional --> </skin> ... |