HomeBlogAboutTools

Some tips for customising Maven built websites

java

Struggling to work out how to customise your Maven built website? Here’s a few thing I’ve figured out. All this is actually documented on the Maven site, but I found it a little hard to find.

The first thing I wanted to do was include some custom pages on my site. To do this, you need to create an “xdocs” directory in the root of your project, and put the files you want to end up on your site in there. Anything except .xml files will be copied to the target/docs directory, which allows you to use images or plain HTML files. If you want your pages to be generated in the same style as the rest of the Maven generated pages, you need to use a format called xdocs. The xdocs format is (somewhat) documented on
the Jakarta site
(ie, there is an example file). In my experience so far, it is basically a cut down, xmlised version of html.

Now you can run maven site:generate and your new page will be generated. However, it will not show up on the menu yet. To do that you will need to create a file called navigation.xml in your xdocs directory. The format for this file is documented on the Maven site. I needed to leave out the encoding from the example for it to work for me, however.

navigation.xml also controls what Maven calls the “navigation bar”. This is the bar across the top of the page, that typically has a link to the Maven site at the top right side. To modify that, create a “links” section inside the body of navigation.xml.

Here’s an example navigation.xml:


<?xml version="1.0"?>
<project name="${project}">
	<title>Classifier4J</title>
	<body>
		<links>
			<item name="Sourceforge"  href="http://sourceforge.net/" />
			<item name="Blog"  href="http://www.mackmo.com/nick/blog/"/>
		</links>
		<menu>
			<item name="Home" href="index.html" >
				<item name="Usage" href="usage.html" />
				<item name="Applications" href="applications.html" />
				<item name="Download" href="download.html" />
			</item>
		</menu>
		<!-- footer will be placed above the (c) -->
		<footer>
			<a href="http://sourceforge.net/projects/classifier4j">
			<img src="http://sourceforge.net/sflogo.php?group_id=72748"
			border="0" alt="sf logo"/>
			</a>
		</footer>
	</body>
</project>

Now I’m trying to figure out how to customise the Checkstyle plug-in settings…

Some links I found useful: