Skip to content

Force javac instead of eclipse jdt as compiler #3007

Open
@dawosch

Description

@dawosch

Hey, i'm using visual studio code with the "extension pack for java" extension.
Local i have installed java 17 (microsoft edition).
When i build my project with mvn -U clean install there will be classes generated and everything is fine.
But when i press shift + alt + B like your readme says, the code will be compiled with the eclipse jdt compiler, which seems to have problems with a dependecy called MapStruct.

Here is one file compiled with maven:
image

And here is the same file after pressing shift + alt + B:
image

Have a look at line 20.
When i start my project the java extension always recompile my code (with the eclipse compiler).
I disabled the auto build feature, but that changed nothing.
I also configured the runtimes for java 17 in hope that this version will be used for compiling my code, but it doesn't.

Here is a repository i created to reproduce the error: Repository

Here are also some settings of vscode:

{
  "java.configuration.updateBuildConfiguration": "automatic",
  "java.debug.settings.onBuildFailureProceed": true,
  "java.autobuild.enabled": false,
  "java.debug.settings.forceBuildBeforeLaunch": false,
  "java.jdt.ls.java.home": "C:\\Program Files\\Microsoft\\jdk-17.0.5.8-hotspot",
  "spring-boot.ls.java.home": "C:\\Program Files\\Microsoft\\jdk-17.0.5.8-hotspot",
  "java.compile.nullAnalysis.mode": "disabled",
  "java.configuration.runtimes": [
    {
      "name": "JavaSE-17",
      "path": "C:\\Program Files\\Microsoft\\jdk-17.0.5.8-hotspot",
      "default": true
    }
  ]
}
Environment
  • Operating System: Windows 10
  • JDK version: 17 (microsoft edition)
  • Visual Studio Code version: 1.76.2 (user setup)
  • Java extension version: 1.16.0
Steps To Reproduce
  1. Clone my test repository
  2. Run mvn -U clean install in the terminal
  3. Have a look at the generated source file TestMapperInterfaceImpl.java on line 20 (the setter)
  4. Press shift + alt + B to compile the project
  5. Have a look at the same file and you will notice that the setter is gone

Test repository: Link to the repository

Current Result

The eclipse jdt compiler messed something up so the generated files are not working.

Expected Result

The compiler i defined in the runtime settings should be used to compile my code.

Additional Informations

I also opened a issue at the microsoft/vscode-spring-dashboard extension because i first thought that the error is a problem ob this extension because i started my project over this extension. But i noticed that before it starts it will be recompiled.
Link to the issue of the spring boot extension

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions