Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » [Solved] Format: manual override of org.eclipse.jdt.core.prefs and org.eclipse.jdt.ui.prefs works?(Overriding these files change Eclipse's behavior but not the IDE's settings )
[Solved] Format: manual override of org.eclipse.jdt.core.prefs and org.eclipse.jdt.ui.prefs works? [message #1820590] Thu, 23 January 2020 15:11 Go to next message
Chkiron Chronos is currently offline Chkiron ChronosFriend
Messages: 8
Registered: October 2019
Junior Member
Hi all

I have a task that is to programatically configure an Eclipse code style formatter. Idea is that a developer will check out code from repo and, as part of the build, Eclipse will be configured with the intended settings.

The way I discovered on how to do that is to create or overwrite the files org.eclipse.jdt.core.prefs and org.eclipse.jdt.ui.prefs in {$project}/.settings

In my tests in a fresh Eclipse installation, it seems that is working - if i change a property in core.prefs or ui.prefs and refresh the project, they will become active.

However, if I go to Preferences | Java | Code Style | Formatter, the Active profile is still Eclipse [built-in].

So, I am wondering:

1. is this the way to go, to achieve this objective? Or there is a smarter way?

2. why changing the files do not change the Formatter Preferences | Java | Code Style | Formatter? For example, I can see org.eclipse.jdt.core.formatter.lineSplit=200 working when I press CTRL+SHIFT+F, but on the Preferences GUI the value for "maximum line width" is still 120

Many thanks,
Kind regards,
2CH

[Updated on: Mon, 27 January 2020 10:47]

Report message to a moderator

Re: Code Format: manual override of org.eclipse.jdt.core.prefs and org.eclipse.jdt.ui.prefs works? [message #1820682 is a reply to message #1820590] Sun, 26 January 2020 07:28 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33258
Registered: July 2009
Senior Member
Note that many preferences can be specified at workspace/instance scope as well with project scope. The things in the .settings folder are project scoped and you can access those from the Properties context menu of the project.

I wonder why you don't just commit the project scoped preferences (the things in the .settings folder or each project) to the Git repository so they are available when you check out the project?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Code Format: manual override of org.eclipse.jdt.core.prefs and org.eclipse.jdt.ui.prefs works? [message #1820693 is a reply to message #1820682] Mon, 27 January 2020 07:02 Go to previous messageGo to next message
Chkiron Chronos is currently offline Chkiron ChronosFriend
Messages: 8
Registered: October 2019
Junior Member
Hi Ed,

first of all, thanks for your reply!

Quote:
I wonder why you don't just commit the project scoped preferences


Myself, I would just commit the XML file containing the Java Style and every developer would just import it when setting up the environment. However, what was agreed by the majority was to automate this process using a Gradle build script.

In that sense, would you know why creating these two files is not updating the Preferences | Java | Code Style | Formatter window? The Active profile is still Eclipse [built-in].

Thanks!


Re: Code Format: manual override of org.eclipse.jdt.core.prefs and org.eclipse.jdt.ui.prefs works? [message #1820698 is a reply to message #1820693] Mon, 27 January 2020 08:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33258
Registered: July 2009
Senior Member
Yes, because you did not modify the workspace preferences, you modified the project specific preferences for each project. As such, you will not find project-specific preferences via Preference -> Java -> Code Style -> Formatter. You'll only find them in the context menu of the project via Properties -> Java -> Code Style -> Formatter.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Code Format: manual override of org.eclipse.jdt.core.prefs and org.eclipse.jdt.ui.prefs works? [message #1820704 is a reply to message #1820698] Mon, 27 January 2020 10:46 Go to previous message
Chkiron Chronos is currently offline Chkiron ChronosFriend
Messages: 8
Registered: October 2019
Junior Member
Fantastic, thanks very much!
Previous Topic:how to create a button?
Next Topic:Error fixing window takes a long time to open and other responsiveness problems
Goto Forum:
  


Current Time: Sun Dec 08 09:33:24 GMT 2024

Powered by FUDForum. Page generated in 0.02964 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top