Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio Code complains if <release>8</release> #50

Open
Logics4 opened this issue Oct 24, 2020 · 1 comment
Open

Visual Studio Code complains if <release>8</release> #50

Logics4 opened this issue Oct 24, 2020 · 1 comment

Comments

@Logics4
Copy link

Logics4 commented Oct 24, 2020

I use Visual Studio Code (version 1.50.1 as I write this) with the Language Support for Java(TM) extension by RedHat (version 0.69.0 as I write this) to pretty much write all my Java code.

I have it like this in my pom.xml file:

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
            <release>8</release>
            <source>11</source>
            <target>11</target>
            <compilerArgs>
                <arg>-Xplugin:jabel</arg>
            </compilerArgs>
        </configuration>
    </plugin>
</plugins>

Just like how it says to do on this project's README. However, the Java support extension read the <release>8</release> tag and sets the language level of the project to JavaSE-1.8, so VS Code complains if I use syntax from Java 9+:

image

My project compiles correctly through the command prompt, though.
VS Code won't give me an error if I set the <release> tag to 11, as it will set the language level to JavaSE-11, or if I omit it from the pom.xml, as it will default to the JDK I use to run the Java support extension (11 is the minimum):

image

... but then I imagine the compiler won't actually make the final jar a Java 8 app, right?
Is there a way to fix this?

@rkraneis
Copy link

Well, the fix for IntelliJ is the intellij-idea-only profile. My solution for NetBeans is to have this profile always active (unfortunately I did not find a trigger like for IntelliJ) and disallow this profile for all maven tasks (so NetBeans is actually running mvn -P intellij-idea-only, !intellij-idea-only ... which for me resulted in the profile staying inactive for actual compilation/ tests 🤞).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants