Thursday, 3 October 2013

Apache Maven Tips: Customizing Maven Site generation via Site Descriptor (Site.xml), Maven Site Plugin and Velocity Template

apache-mavenThere are two kind of customizations you can do with Maven Site generation:

(1) Configuring the Site Descriptor (Simple) – This is a higher level customization, where you can change or configure certain sections/areas of the site layout including the navigation/menu. Read more on Maven website.

(2) Custom Velocity Template (Complex) – This is a low level customization, where you have full control over the generated html content. However it is more complex than the first one because you need to have an understanding of Apache Velocity templating language.

To begin with, add Maven Site Plugin configuration under the <build/> tag of your POM:

<plugin>
    <artifactId>maven-site-plugin</artifactId>
    <version>3.3</version>
    <configuration>
        <templateFile>${basedir}/src/site/maven-site-template.vm</templateFile>
    </configuration>

</plugin>

Recommended way to develop/design a custom maven site template, is to start with the default template provided by maven itself, and then change it to your desired layout.

No comments:

Post a Comment