Wednesday, October 19, 2011

Maven: Making your application to be compatible with JDK 1.4, 1.5 or 1.6

If you want to compile maven projects to be JDK 1.4, 1.5 and 1.6 compatible, here is the info:

I write my code using JDK 1.5 syntax but I need the library to be JDK 1.4 compatible, so here is my configuration.
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
        <source>1.5</source>
        <target>jsr14</target>
    </configuration>
</plugin>
To compile it to be JDK 1.5 compatible,
<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>
To compile it to be JDK 1.6 compatible,
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
</plugin>



No comments:

Post a Comment