About

Jadira is the home for Sousan and Chris Pheby's open source projects. These are reusable open source Java modules that provide first class solutions using the most effective current JEE technologies.

Search
Tag Cloud
...
Login
« Release: Maven Dependency Navigator Version 1.0 beta 9 | Main | Configuring Open Source JTA Transaction Managers with Spring »
Tuesday
May042010

Maven Sites and Sourceforge

The Maven site for the User Type project is now online. This site makes use of the excellent Fluido Skin which gives a cleaner, crisper look in comparison to the standard skin.

There's a huge amount of metrics and reporting plugged into the site generation, but some of the features are of particular interest.

Class diagram visualisations can be found throughout the Javadocs. These are generated using the UML Graph doclet, using the following example configuration (suitable for Java 5):

			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-javadoc-plugin</artifactId>
 				<version>2.6.1</version>
 				<configuration>
 					<linksource>true</linksource>
 					<links>
 						<link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
 					</links>
 					<encoding>UTF-8</encoding>
 					<executions>
 						<execution>
 							<id>attach-javadocs</id>
 							<phase>package</phase>
 							<goals>
 								<goal>jar</goal>
 							</goals>
 						</execution>
 					</executions>
 					<aggregate>true</aggregate>
 					<doclet>gr.spinellis.umlgraph.doclet.UmlGraphDoc</doclet>
 					<docletArtifact>
 						<groupId>gr.spinellis</groupId>
 						<artifactId>UmlGraph</artifactId>
 						<version>4.6</version>
 					</docletArtifact>
 					<additionalparam>-attributes -enumconstants -enumerations -operations -types -visibility -inferrel -inferdep -hide (java.*)|(org.hibernate.*)|(org.joda.*)</additionalparam>
 				</configuration>
 			</plugin>

The enforcer plugin is being used to require Java 5, and Maven 2.2.1 - to help guarantee that builds are reproducible. Together with these requirements, the use of commons-logging is prohibited. This is a great practice which helps ensure all logging is performed using SLF4J:

 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-enforcer-plugin</artifactId>
 				<version>1.0-beta-1</version>
 				<executions>
 					<execution>
 						<id>enforce-versions</id>
 						<goals>
 							<goal>enforce</goal>
 						</goals>
 						<configuration>
 							<rules>
 								<requireMavenVersion>
 									<version>2.2.1</version>
 								</requireMavenVersion>
 								<requireJavaVersion>
 									<version>1.5.0</version>
 								</requireJavaVersion>
 								<bannedDependencies>
 									<excludes>
 										<exclude>commons-logging:*</exclude>
 									</excludes>
 								</bannedDependencies>
 								<requirePluginVersions>
 									<banLatest>true</banLatest>
 									<banRelease>true</banRelease>
 									<banSnapshots>true</banSnapshots>
 									<unCheckedPluginList></unCheckedPluginList>
 								</requirePluginVersions>
 							</rules>
 						</configuration>
 					</execution>
 				</executions>
 			</plugin>

You will also note that enforcer requires that exact versions are required for all utilised plugins. Again, this guarantees the reproducibility of builds.

Another point of interest is the use of toolchains. Toolchains allows you to externalise the JDK under which Maven runs from the JDK used for building. This would be particularly relevant for a project using recent builds of Maven which require Java 5, but needing to build using an older JDK.

			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-toolchains-plugin</artifactId>
 				<version>1.0</version>
 				<executions>
 					<execution>
 						<phase>validate</phase>
 						<goals>
 							<goal>toolchain</goal>
 						</goals>
 					</execution>
 				</executions>
 				<configuration>
 					<toolchains>
 						<jdk>
 							<version>5.0</version>
 							<vendor>sun</vendor>
 						</jdk>
 					</toolchains>
 			 	 </configuration>
 			</plugin>

Setting up a Maven site is surprisingly straightforward. A good howto guide is available on CommunityMapBuilder, and the Maven documentation describes the steps that need to performed to enable a shell which can be used with mvn site-deploy. You must display the Sourceforge logo on your Maven site, which can be achieved by including a 'poweredBy' entry in the site.xml file:

    <poweredBy>
        <logo name="Hosted by SourceForge" href="http://www.sourceforge.net/" img="http://sourceforge.net/sflogo.php?group_id=16035&amp;type=1" />
        ...
    </poweredBy>

			<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.6.1</version>
<configuration>
<linksource>true</linksource>
<links>
<link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
</links>
<encoding>UTF-8</encoding>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<aggregate>true</aggregate>
<doclet>gr.spinellis.umlgraph.doclet.UmlGraphDoc</doclet>
<docletArtifact>
<groupId>gr.spinellis</groupId>
<artifactId>UmlGraph</artifactId>
<version>4.6</version>
</docletArtifact>
<additionalparam>-attributes -enumconstants -enumerations -operations -types -visibility -inferrel -inferdep -hide (java.*)|(org.hibernate.*)|(org.joda.*)</additionalparam>
</configuration>
</plugin>

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>