Monday, September 19, 2011

maven-compiler-plugin configuration for annotations support

Several times I encountered the same problem when building with Maven:
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to /home/stefano/works/stefanocazzola.it/sc/target/classes
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure
/home/stefano/works/test/src/main/java/it/stefano/Test.java:[17,2] annotations are not supported in -source 1.3
(use -source 5 or higher to enable annotations)
 @Override
As I said I encountered it many times: I know it's a silly error, but every time I got to search the forums to find the soution (my short-time memory isn't so good, I admit....) so I decided to write a post about that.
The solution os very very simple. Just configure the maven-compiler-plugin like that:
<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <configuration>
  <source>1.5</source>
  <target>1.5</target>
 </configuration>
</plugin>

No comments:

Post a Comment