Sunday, 1 July 2012

Maven 2.2.1 Java Code Review

Following POM.xml template is a cool and automated way to generate maven site. This site will have reports  publishing findbugs, checkstyle, PMD, CPD, Emma, and plenty others.

Requirements: MAVEN 2.2.1
JDK 1.6 and over (May work with 1.5)

If there are plenty of class files then you will need to set MAVEN_OPTS=-Xmx512m -Xms512m based on memory requirements.



<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.mujahed</groupId>
<artifactId>myproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Name Of the Project</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
</properties>

<organization>
<name>My Company</name>
</organization>

<developers>
<developer>
<name>Mujahed Syed</name>
<email>msyed1983@gmail.com</email>
</developer>
</developers>

<profiles>
<profile>
<id>project_profile</id>
</profile>
</profiles>

<build>
<sourceDirectory>C:\work\aix_workspace\aix\src</sourceDirectory>
<scriptSourceDirectory>C:\work\aix_workspace\aix\BuildScripts\</scriptSourceDirectory>
<testSourceDirectory>C:\work\aix_workspace\aix\BuildScripts\test\</testSourceDirectory>
<outputDirectory>C:\work\aix_workspace\aix\target\classes</outputDirectory>
<testOutputDirectory>C:\work\aix_workspace\aix\target\test-classes</testOutputDirectory>

<resources>
<resource>
<directory>C:\work\aix_workspace\aix\resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>C:\work\aix_workspace\aix\test\resources</directory>
</testResource>
</testResources>
<directory>C:\work\aix_workspace\aix\target</directory>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>C:\work\jdk1.6.0_07\bin\javac.exe</executable>
<compilerVersion>1.6</compilerVersion>
<source>1.6</source>
<target>1.6</target>
<meminitial>1028m</meminitial>
<maxmem>1028m</maxmem>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>${output.dir}</outputDirectory>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pdf-plugin</artifactId>
<version>1.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<formats>
<format>html</format>
</formats>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.4.0</version>
</plugin>
<plugin>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.9</version>
<configuration>
<configLocation>C:/lib/checkstyle-5.4/sun_checks.xml</configLocation>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<minmemory>512m</minmemory>
<maxmemory>1g</maxmemory>
<links>
<link>http://commons.apache.org/lang/api</link>
<link>http://docs.oracle.com/javase/6/docs/api/</link>
</links>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>surefire-report-maven-plugin</artifactId>
<version>2.0-beta-1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
</plugin>
<plugin>
<artifactId>maven-clover-plugin</artifactId>
<version>2.4</version>
</plugin>
                        <plugin>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<configuration>
<targetJdk>1.6</targetJdk>
<minimumPriority>3</minimumPriority>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
<version>2.0-beta-2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dashboard-maven-plugin</artifactId>
<version>1.0.0-beta-1</version>
</plugin>

</plugins>
    </reporting>

<dependencies>
</dependencies>

</project>