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

Separation of shared configuration and IDE project metadata #3486

Closed
lmerynda opened this issue Feb 5, 2024 · 4 comments
Closed

Separation of shared configuration and IDE project metadata #3486

lmerynda opened this issue Feb 5, 2024 · 4 comments
Labels

Comments

@lmerynda
Copy link

lmerynda commented Feb 5, 2024

In our project we use $project_path/.settings/org.eclipse.jdt.core.prefs to store formatting configuration which everyone shares to achieve common style. This file is checked-in into the repo. It happens from time to time during some interactions that the content of this file will be updated for one reason or another (TODO ignore, compiler version, etc.) which we don't want to share. Why would we hardcode the compiler version here instead of setting it up in our buildsystem (gradle). How can we achieve a separation of configurations so that we can share formatting settings (and potentially some more), while making sure this file will not be updated automatically by tools or actions such as preference change, user's manual change, project import etc.

For example I've just did a clean of my project workspace because it became corrupted and suddenly this config file has received following content in addition to our formatting setup

eclipse.preferences.version=1
org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=ignore
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.source=17

 

Environment
  • Operating System: Windows + Docker based dev container
  • JDK version: OpenJDK17
  • Visual Studio Code version: 1.86
  • Java extension version: v1.27.0
@rgrunber
Copy link
Member

rgrunber commented Feb 5, 2024

Looks like you mentioned your project is Gradle based. You can create a file at the root of your project :

.vscode/settings.json

{
  "java.settings.url": ".vscode/settings.prefs"
}

.vscode/settings.prefs

...
...
Place your format/java preferences here
...
...

Another option is to use java.format.settings.url as explained at https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings . If you then generated an Eclipse-style format file, you could always reference that one.

@lmerynda
Copy link
Author

lmerynda commented Feb 6, 2024

That looks exactly like what we need, thanks i will play with it during next few days and provide feedback. Should we close it and reopen if need arise?

@rgrunber
Copy link
Member

rgrunber commented Feb 6, 2024

Feel free to close when you can confirm it works for you, or comment if there's some issue.

@lmerynda
Copy link
Author

everything seems to work as I'd expect it to, thanks!

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

No branches or pull requests

2 participants