How to set up your Maven2 POM to support Java5

Seeing this?
[bash highlight="3,4"]
$ mvn compile

generics are not supported in -source 1.3
(try -source 1.5 to enable generics)
[/bash]

You need to tell the maven-compiler-plugin to use java 1.5. Add this to your pom.xml:

<project>
...
  <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>
</project>

Related posts:

  1. How to increase maven heapspace in hudson builds
    If your maven-built project fails in hudson (especially when you’re using the assembly plugin) and it isn’t a compile or test failure, check the console output. If it says “java.lang.OutOfMemoryError:......
  2. How to add a version number to your maven webapp
    I couldn’t find a simple recipe to add a version number to a maven-built webapp. The maven-war-plugin talks about how to filter, but no simple example is given. So. I’ll......
  3. How to add a version number to your hudson-built maven jar
    Maven’s jar plugin will automatically add a “pom.properties” in your jar’s META-INF/maven/$groupId/$artifactId directory. If you build with hudson, there are a number of other values that you might want to......
  4. Java for Mac OS X 10.5 Update 1 adds support for Java SE 6
    Java for Mac OS X 10.5 Update 1 adds support for Java SE 6 Update: Apple’s java6 port can’t run IDEA… Back to java5. :-\......

This entry was posted in Technical HOWTOs and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Additional comments powered by BackType