WestCoastProjects
WestCoastProjects

Reputation: 63062

Intellij somehow thinks a maven project is intending to use java 1.4

As shown in following screenshot - the project SDK and language level are 1.8:

enter image description here

And I went through all of the project modules: they are all likewise defined as 1.8. One of them is shown below:

enter image description here

Yet somehow IJ attached a language level of 1.4 to one of the modules

enter image description here

But actually .. it is not even that straightforward. E.g. the intellisense thinks 1.4:

enter image description here

But when I click on the java.lang.String underlined in red, it DOES go to 1.8:

enter image description here

The pom.xml for the culprit module 'icloud' makes no mention of any java level - so it is not to blame:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.apache.ignite</groupId>
        <artifactId>ignite-parent</artifactId>
        <version>1</version>
        <relativePath>../../parent</relativePath>
    </parent>

    <artifactId>ignite-cloud</artifactId>
    <version>1.1.3-SNAPSHOT</version>

    <properties>
        <jcloud.version>1.9.0</jcloud.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.ignite</groupId>
            <artifactId>ignite-core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.jclouds</groupId>
            <artifactId>jclouds-allcompute</artifactId>
            <version>${jcloud.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.jclouds.labs</groupId>
            <artifactId>google-compute-engine</artifactId>
            <version>${jcloud.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.jclouds.labs</groupId>
            <artifactId>docker</artifactId>
            <version>${jcloud.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.jclouds.provider</groupId>
            <artifactId>cloudsigma-zrh</artifactId>
            <version>1.8.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.ignite</groupId>
            <artifactId>ignite-core</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

</project>

I have done Build|Rebuild twice. Also have done

mvn clean package

from command line twice. This is just a big time sink (/waste). So then: why is IJ sabotaging this module - and is there a workaround?

Upvotes: 2

Views: 121

Answers (2)

WestCoastProjects
WestCoastProjects

Reputation: 63062

The problem was that intellij could not handle the examples subproject being

  • underneath a parent directory containing the main parent project
  • but the directory is its own self contained project with no relation to the parent

The workaround is to create an entirely independent project for the examples module.

The other suggested answer - about adding the compiler plugin - made no difference.

Upvotes: 2

Harry.Chen
Harry.Chen

Reputation: 1610

Add a the compiler plugin to pom.xml and reimport the pom will solve this issue

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Upvotes: 2

Related Questions