I have a checkstyle configuration XML file and want to automatically generate an Eclipse formatter configuration from this. Is there any tool that can do this?
Asked
Active
Viewed 2.8k times
41
-
1Dear Ken, some of us think you really should accept the above answer as the best (not sure that Paul is running after the Unsung hero's badge ;)) – Jean-Rémy Revy Jan 04 '16 at 14:58
-
1@Jean-RémyRevy done, thanks for the ping! – Ken Liu Jan 05 '16 at 17:16
-
@Jean-RémyRevy It's good that the answer was accepted, but unsung hero would be for users that have accepted answers with 0 votes, rather than lots of votes without being accepted. (Just trying to save others from having to search what unsung hero badge means) – Vivek Chavda Aug 02 '17 at 13:22
2 Answers
75
In Eclipse (3.6):
- Install Checkstyle plug-in
- Import stylesheet using Windows --> Preferences, General --> Checkstyle --> New. Since you have an external file, choose "external file" as the type.
Right-click on your project in the Package view and select Checkstyle --> Create Formatter-Profile.
Then enable the formatter for your workspace: Windows --> Preferences --> Java --> Code Style --> Formatter. Select formatter: "eclipse-cs [project name]".
Click OK!
-
which file should I import into the Eclipse check-style plug-in for the Google Java style - http://google-styleguide.googlecode.com/svn/trunk/? I tried `styleguide.css`, but that failed. – Kevin Meredith Feb 26 '14 at 14:49
-
1Looks like it depends on the programming language: [C++](http://google-styleguide.googlecode.com/svn/trunk/eclipse-cpp-google-style.xml) [Java](http://google-styleguide.googlecode.com/svn/trunk/eclipse-java-google-style.xml) You need an XML file in any case, not a CSS. – Paul Feb 27 '14 at 20:46
-
2This feature is broken and the Eclipse plugin authors said in March 2019 that they were planning to remove it. https://stackoverflow.com/a/55323793/733092 – Noumenon Dec 10 '19 at 23:20
-
-
0
Here they say, that you can import a checkstyle configuration directly into the eclipse formatter. Didn't verify, but at least, it's a hint.
If the link doesn't work in your browser, please copy'n'paste this url: http://dbestudio.wiki.sourceforge.net/Code+Formatting+with+Checkstyle
Andreas Dolk
- 111,016
- 17
- 174
- 259
-
1There seems to be a problem with the generated links. After getting 'Bad Wiki Name', replace all %2B with + – Robert Munteanu Jun 12 '09 at 08:23
-
hm, maybe a firefox issue. it automatically urlencode the plusses, which leads to the "bad wiki name" 404 page. manually fixing this/typing the url works. – Karsten Jun 12 '09 at 08:24
-
Sorry for this inconvenience - I added the full url to the answer. – Andreas Dolk Jun 15 '09 at 16:06