Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Install: "Annotations are not supported in -source 1.3"

When running mvn install on my project, i see it fail due to the following errors:

C:\Repositories\blah\src\test\java\com\xxx\qm\testrunner\test\ATest.java:[11,5] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
    @Test

C:\Repositories\blah\src\test\java\com\xxx\qm\common\test\BTest.java:[11,5] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
    @Test

My Maven dependency includes jUnit 4.8, however and has no reference to 1.3 anything.

What would cause these errors? Please advise

like image 432
James Raitsev Avatar asked Jun 28 '11 21:06

James Raitsev


2 Answers

You need to specify the source version of your maven project through the use of the maven-compiler-plugin. Add the following to your pom build element and set the appropriate java source and target levels.

<build>
     <defaultGoal>install</defaultGoal>
     <plugins>
          <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
               <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
               </configuration>
          </plugin>
      </plugins>
</build>

http://maven.apache.org/plugins/maven-compiler-plugin/

like image 90
gregwhitaker Avatar answered Oct 12 '22 00:10

gregwhitaker


A shorter version:

<project>
    <properties>
        <maven.compiler.source>1.5</maven.compiler.source>
        <maven.compiler.target>1.5</maven.compiler.target>
    </properties>
....
like image 32
rzymek Avatar answered Oct 12 '22 02:10

rzymek