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

27,977

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!

Share:
27,977
Ken Liu
Author by

Ken Liu

Director of Engineering at Cockroach Labs. Github: kenliu Twitter: @kenliu

Updated on April 28, 2020

Comments

  • Ken Liu
    Ken Liu about 4 years

    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?

    • Jean-Rémy Revy
      Jean-Rémy Revy over 8 years
      Dear 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 ;))
    • Ken Liu
      Ken Liu over 8 years
      @Jean-RémyRevy done, thanks for the ping!
    • Vivek Chavda
      Vivek Chavda almost 7 years
      @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)
  • Robert Munteanu
    Robert Munteanu almost 15 years
    There seems to be a problem with the generated links. After getting 'Bad Wiki Name', replace all %2B with +
  • Andreas Dolk
    Andreas Dolk almost 15 years
    Sorry for this inconvenience - I added the full url to the answer.
  • Kevin Meredith
    Kevin Meredith about 10 years
    which file should I import into the Eclipse check-style plug-in for the Google Java style - google-styleguide.googlecode.com/svn/trunk? I tried styleguide.css, but that failed.
  • Paul
    Paul about 10 years
    Looks like it depends on the programming language: C++ Java You need an XML file in any case, not a CSS.
  • Noumenon
    Noumenon over 4 years
    This feature is broken and the Eclipse plugin authors said in March 2019 that they were planning to remove it. stackoverflow.com/a/55323793/733092
  • Marco Bolis
    Marco Bolis about 3 years
    @Noumenon is there an alternative AFAYK?
  • Noumenon
    Noumenon about 3 years
    @MarcoBolis I never found one and just ran it from the command line.