How to generate an Eclipse formatter configuration from a checkstyle configuration?

Viewed 28599

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?

2 Answers

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!

The answer currently marked as accepted does not work as is with Eclipse 2022-06 and Checkstyle Plug-in 10.0.0. These are the steps that worked for me:

  1. Install Checkstyle plug-in

  2. Import Checkstyle configuration: Windows -> Preferences -> Checkstyle -> New. Choose "external file" as the type.

  3. Right-click on your project in the Package view and select Checkstyle -> Create Formatter-Profile. The following files will be created in you project:

  • my-project-cs-cleanup.xml
  • my-project-cs-formatter.xml
  1. Add the generated my-project-cs-formatter.xml as a formatter: Windows -> Preferences -> Java -> Code Style -> Formatter -> Import
Related