Maven: Compile Your Application to be JDK 1.4, 1.5 or 1.6 Compatible
By admin on Mar 9, 2008 in Java, Programming
I need to compile some of my Maven projects to be JDK 1.4 compatible, some for JDK 1.5 or JDK 1.6. To do this in Maven is very straight forward since I have different pom.xml for different applications.
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
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.6</source>
<target>1.6</target>
</configuration>
</plugin>
