Can the Eclipse Java formatter be used stand-alone

前端 未结 3 389
鱼传尺愫
鱼传尺愫 2020-12-03 01:59

Is there a way to use the formatter that comes with eclipse, outside of eclipse? I would like to format some java files using my formatter.xml file that I have configured u

3条回答
  •  臣服心动
    2020-12-03 02:08

    Here's the offical eclipse docs on how to do this

    Dump of those docs:

    Running the formatter application is as simple as running the org.eclipse.jdt.core.JavaCodeFormatter application from the commandline:

    eclipse -vm  -application org.eclipse.jdt.core.JavaCodeFormatter [ OPTIONS ] 
    

    When invoked on MacOS, the paths to point to the configuration file or the source files can be relative, but they will be computed from the location of the eclipse.ini file. This is a limitation of the Eclipse launcher on MacOS. On all other platforms, the relative paths are computed relative to the current user directory.

    Java source files and/or directories to format. Only files ending with .java will be formatted in the given directory.

    -config

    Use the formatting style from the specified properties file. Refer to Generating a config file for the formatter application for details.

    -help

    Display the help message.

    -quiet

    Only print error messages.

    -verbose

    Be verbose about the formatting job.

提交回复
热议问题