vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Gradle projects compile to `bin/` instead of `build/`

Open brunovieira97 opened this issue 4 years ago • 5 comments

Gradle projects default their builds to build/, however the vscode plugin compiles a completely separate version of all the class files to bin/, so it does require adding a completely separate directory to source control, along with actually performing all the compiles twice (once for gradle, and once for vscode).

Originally posted by @ThadHouse in https://github.com/redhat-developer/vscode-java/issues/466#issuecomment-373542235

brunovieira97 avatar Mar 03 '22 14:03 brunovieira97

Was looking for a solution for my problem when I stumbled upon this mentioned comment.

The problem here is the Java extension for VS Code compiles binaries to bin/ directly.

Is there a way for VS Code to follow Gradle's settings for the build folder?

brunovieira97 avatar Mar 03 '22 14:03 brunovieira97

@brunovieira97 You may want to take a look at https://github.com/eclipse/buildship/issues/1131

snjeza avatar Mar 03 '22 16:03 snjeza

Wasn't aware of this Buildship project.

However, Maven support does not seem to be affected at all. AFAIK, it just compiles binaries directly to target/, same as Eclipse (in this case, VS Code).

brunovieira97 avatar Mar 03 '22 18:03 brunovieira97

Wasn't aware of this Buildship project.

See

  • https://github.com/redhat-developer/vscode-java/wiki/Gradle-Support
  • https://github.com/redhat-developer/vscode-java/issues/1615#issue-701705496

snjeza avatar Mar 03 '22 20:03 snjeza

I don't think java extension even uses gradle to build these classes. I have registered a task with

classes.finalizedBy mergeMethods

And none of the changes got applied by this task. Additionally, debug extension uses bin/ for runtime classpath which caused issues due to my task not applying these changes

Lassebq avatar Aug 27 '24 21:08 Lassebq