1

I'm using Java 7 syntax in a project, but when I go to mvn clean install maven is telling me:

[ERROR] /Users/mosawi/Perforce/src/main/java/com/generalatomics/compilers/Engine.java:[47,45] diamond operator is not supported in -source 1.5
[ERROR] (use -source 7 or higher to enable diamond operator)

I'm pretty sure my project is Java 7, and my java build path is set to Java 7

enter image description here

EDIT:

Here is the relevant info concerning my pom.xml ...etc

<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <version>2.8</version>
            <configuration>
                <dependencyLocationsEnabled>true</dependencyLocationsEnabled>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <formats>
                    <format>html</format>
                    <format>xml</format>
                </formats>
            </configuration>
        </plugin>
    </plugins>
</reporting>

...etc.

messivanio
  • 2,263
  • 18
  • 24
mosawi
  • 1,283
  • 5
  • 25
  • 48
  • 2
    What does your maven compiler plugin configuration say? It is probably set on Java 5. It is not using your IDE-Compiler settings. - maybe include your pom.xml here. – Carsten Jul 30 '15 at 00:20

1 Answers1

4

Usually IDEs use maven pom.xml file as a source of project configuration. Changing the compiler settings in the IDE not always has effect on the maven build. The best way to keep a project always manageable with maven is edit the pom.xml files and instruct the IDE to sync with maven.

In this particular case you have to check two things:

  1. Configure the maven compiler plugin in the pom.xml
    <build>

    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
    ...
  1. Be sure that the mvn clean command actually is launched with a jdk7 (if you launch it from the IDE something like a "Maven settings" could be a good place to look at.
messivanio
  • 2,263
  • 18
  • 24
Fabio Bonfante
  • 5,128
  • 1
  • 32
  • 37
  • This did the trick! Thanks – mosawi Jul 30 '15 at 00:38
  • 1
    There is also a simplier configuration that doesn't require a use of a plugin: `1.7 1.7` if you already have an properties section just add the two variables. This is just a follow up. – Jorge Campos Jul 30 '15 at 02:30