Wednesday, December 12, 2012

Specify Java compiler version in Maven

Sometime you want to compile your Java codes in one particular version in Maven it is quite easy to do so by specifying this in maven-compiler-plugin.  It is shown as:


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

In the above example you specify Java is compiled in verison 1.5 and generated classes are compatible with JVN 1.5.

No comments:

Post a Comment