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

Overwrites java home in .settings/org.eclipse.buildship.core.prefs

Open MartinEmrich opened this issue 3 years ago • 3 comments

As vscode-java is apparently not capable of generating the .settings/org.eclipse.buildship.core.prefs file (mabe #666), I have to check it into git. But everytime vscode-java tries to set the java.home= field in this file to my local path to the local JDK, which might differ from other developers workspace setups.

Environment
  • Operating System: Windows 10
  • JDK version: Amazon Corretto 11
  • Visual Studio Code version: 1.63.2
  • Java extension version: 1.2.0
Steps To Reproduce
  1. Open/Import a Java project folder with Gradle build (worked for me only after having an Eclipse IDE instance generate the .settings/org.eclipse.buildship.core.prefs file)
  2. set the java.home= line to an empty value. VSCode seems to work fine nevertheless.
  3. Use VSCode, run your project, develop... At some point something changes the file to set the value to the lokal JDK path (e.g. C\:/Program Files/Amazon Corretto/jdk11.0.12_7) This can be forced by "Java: Clean the Java Language Server Workspace"

[Please attach a sample project reproducing the error] I guess it's not an error per se.

Please attach logs vscode-java.log

Current Result

See above.

Expected Result

The .settings/org.eclipse.buildship.core.prefs file should either be committable (thus workspace-agnostic) or generateable (so it does not have to be committed to git).

Additional Informations

MartinEmrich avatar Jan 20 '22 14:01 MartinEmrich

try using "java.import.generatesMetadataFilesAtProjectRoot"=true in your settings.json

fbricon avatar Jan 20 '22 15:01 fbricon

@fbricon Thanks!

In my settings.json, It got grayed out, with a popup stating "Diese Einstellung kann in diesem Arbeitsbereich nicht angewendet werden. Sie wird angewendet, wenn Sie den enthaltenden Arbeitsbereichordner direkt öffnen." (roughly: "This setting cannot be used in this workspace. It will be used when you open the containing workspace folder directly").

But adding the setting to my workspace settings worked. After deleting the .settings/org.eclipse.buildship.core.prefs file, closing and restarting vscode, the file got autogenerated!

So all I need is to make vscode use the setting from the .vscode/settings.json, which looks clean enough to be committed to the git repository...

MartinEmrich avatar Jan 20 '22 15:01 MartinEmrich

So all I need is to make vscode use the setting from the .vscode/settings.json, which looks clean enough to be committed to the git repository...

I ran into same issue. When the project workspace is already generated, you need to [Ctrl] + [Shift] + P and run "Java: Clean Java Language Server Workspace" to re-apply the import setting and generate missing files. 😉

Would be nice if this was auto-detected insteaad of simply failing the build, because people that check out the removed file commit with updated settings most likely are not aware of having to clean their project workspace.

In addition, I think it should be default to enable that setting. At least for the gradle build system, which relies on the .settings/org.eclipse.buildship.core.prefs file.

everHannes avatar Sep 28 '24 09:09 everHannes