Saturday, March 20, 2010

Specify Java Source Level using Maven

To develop Java applications using Java 5 or Java 6 with Maven, add this to the project's pom.xml :

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

Replace "1.5" if necessary. Valid values are: 1.3, 1.4, 1.5, 1.6.