Import maven project always "forgets" to set JDK version and language level

Answered

Hi all,

When I create a new project by importing a Maven pom all of the settings are read except two:

- the project SDK is always undefined when I import, so I have to set it manually

- the project's language level seems to be more or less random.

The POM specifies using Java 8, so I wonder: is there something special I need to mention inside the POM to get this working?

Regards,

Frits

3
13 comments

See http://stackoverflow.com/a/12900859/104891.

Also try setting JDK in File | Other Settings | Default Project Structure.

-1

Thanks a lot, Serge. I know about how to fix the settings, and my poms contain both the properties that set the java level and the configuration on the maven-compiler-plugin. The settings on modules inside the projects are read correctly without trouble, that works fine.

I just do not understand how to get IntelliJ to also set the project settings.

The "default project structure" thing was new for me. But it appears that those settings are part of the workspace; when I start from scratch those settings are empty/wrong even though I set them before. so they are not "global" settings, apparently. This means that it does not really help, I still have to set the sdk and project language level.

BTW: the whole "settings" thing in IntelliJ is about the only thing that I am unhappy with. They seem to be stored willy nilly everywhere, and it's very hard to get settings to be persisted with the project. Which means we have way more trouble in the team keeping settings synchronized, and people are continuously surprised that settings have "disappeared" or reverted to some default. In this I liked Eclipse way better: for the most cases it properly separated personal settings and project settings correctly by default, so a pull would update everyone's data...

2

Project JDK/level information is stored inside .idea/misc.xml file which can be shared via the version control.

See https://intellij-support.jetbrains.com/hc/articles/206544839.

-3

I know; once the project is set it remembers it. But every time you make a new project you will have to do it again. You would expect the "default project structure" to be stored somewhere inside ~/.IntelliJIdea2017.x.

1

Default project structure is stored in IDE config directory, see options/project.default.xml:

<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
-2
Avatar
Permanently deleted user

Ridiculous! Frits keep saying the language level is not imported from Maven and Serge keep answering how to manually set it.  This is pathetic. Why IntelliJ does not import the language level from the pom.xml? We are not asking for work around. 

6

It does import the language level per https://stackoverflow.com/a/12900859/104891. If it doesn't work for you, please report a bug at https://youtrack.jetbrains.com/issues/IDEA and attach a sample project to reproduce the issue.

0

I'm sorry, but for me it clearly does not. See the attached example. When I import that my JDK remains on 11 and language level stays at 6 in project settings -> Project:

I thought I posted this as an issue already, but I was evidently mistaken. So it is there now: https://youtrack.jetbrains.com/issue/IDEA-215058

Regards,

 

Frits

 

 

1

Answered in YouTrack, your sources in the module have the correct language level. Project setting is not relevant.

-5

The language level within the compiler preferences is upgraded. However, the project SDK and language level is not. So basically all run configurations including maven builds will continue to use a wrong JDK (possibly incompatible to the selected version)

1

Why is this simple thing so difficult? It does not work. I have to import multiple projects and then go and change the JDK manually.

3

>I have to import multiple projects and then go and change the JDK manually.

JDK must be specified manually, it is expected that it is not set from the pom.xml automatically. Please vote for related request: https://youtrack.jetbrains.com/issue/IDEA-171925

0

Please sign in to leave a comment.