4

I'm trying to build a java project using maven. In the pom.xml file at the root of the project I have the following lines:

  <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <source>1.6</source>                                                                             
    <target>1.6</target>
    <debug>true</debug>
    <encoding>UTF-8</encoding>
  </configuration>
</plugin>

but when I try to build with mvn -DskipTests -U install, I get the following error: static import declarations are not supported in -source 1.3

maven is not using the source and target (1.6) that i've specified in the pom.

java -version
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

mvn --version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_11, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.5.0-21-generic", arch: "amd64", family: "unix"

uname -a
Linux ubuntu 3.5.0-21-generic #32-Ubuntu SMP Tue Dec 11 18:51:59 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Is there anywhere else that maven might be getting its default source and target settings from? Why isnt it using the settings from the pom?

Here is a snippet of error message when maven is ran in debug mode:

 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project LeaderLines: Compilation failure
 [ERROR] /path/geoserver-2.2/geotools-plugin/LeaderLines/src/org/geotools/filter/function/FilterFunction_leaderLine.java:[22,7] error: static import declarations are not supported in -source 1.3

 [ERROR] -> [Help 1]                                                                                
 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins: maven-compiler-plugin:2.0.2:compile (default-compile) on project LeaderLines: Compilation failure
 /path/geoserver-2.2/geotools-plugin/LeaderLines/src/org/geotools/filter/function/FilterFunction_leaderLine.java:[22,7] error: static import declarations are not supported in -source 1.3
cdk
  • 6,698
  • 24
  • 51
  • Do you have JDK 6 installed? – Ilya Jan 16 '13 at 15:57
  • Can you paste the relevant snippet of the output when run in debug mode - i.e. `mvn -X -DskipTests -U install` ? – Raghuram Jan 16 '13 at 16:02
  • @Ilya: no, i have the ubuntu package `oracle-jdk7-installer` which provides JDK7 – cdk Jan 16 '13 at 16:14
  • 1
    I see that version 2.0.2 of `maven-compiler-plugin` is being used. How about specifying `3.0` which is the recent version of the plugin and retrying? – Raghuram Jan 16 '13 at 16:16
  • 1
    Do check your profiles in *settings.xml*, that might have some other configurations. – mtk Jan 16 '13 at 16:18
  • @Raghuram: i've added `3.0` to the plugin settings, and the error message still says its using 2.0.2. It appears that maven is ignoring the settings in the pom file – cdk Jan 16 '13 at 16:19
  • 4
    You could try `mvn help:effective-pom` - this will confirm the version used. Also run `mvn help:all-profiles` to see what profiles exist and `mvn help:active-profiles` if one of them is overriding the pom plugin configuration – Raghuram Jan 16 '13 at 16:37
  • `mvn help:active-profiles` doesnt report any active profiles and `mvn help:effective-pom` contains the same maven-compiler-plugin settings that I expect it to. This is really strange, I have no idea where this `-source 1.3` is coming from. – cdk Jan 16 '13 at 16:53
  • Try cleaning out your local artifact repo. In my experience sometimes that works for strange issues like these, don't always know why. – user944849 Jan 17 '13 at 18:29

2 Answers2

0

Try setting the source level and source encoding with the following properties:

<properties>
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Raphaël
  • 3,646
  • 27
  • 28
0

Try to clear you local Maven repo and run your build again (maybe, try also to run it with '-o' option)

daniilyar
  • 2,602
  • 3
  • 22
  • 25