Giter VIP home page Giter VIP logo

javacodeformatter's Introduction

Introduction

The Java code here uses Eclipse's code formatting capability to format Java code. You don't need Eclipse installed to use it; the build bundles all of the Eclipse libraries necessary.

Building

$ mvn package

Running

$ java -cp java-formatter-jar-with-dependencies.jar sample.opts

The only required argument is a file listing code formatter options for Eclipse's DefaultCodeFormatterOptions class that should be applied over the top of the standard Java settings. Each line in the file should be:

<field name>:<type>:<value>

A blank file ought to be fine. Comment lines starting with '#' and blank lines are ignored.

When run like the above, the formatter reads code from standard input. Formatted code is written to standard output.

$ java -cp java-formatter-jar-with-dependencies.jar sample.opts MyFile.java

You can pass a file name instead of using standard input.

$ java -cp java-formatter-jar-with-dependencies.jar sample.opts src/java

If you pass a directory, the formatter will recursively format all Java files in the directory. Formatted code is written to new files prefixed with "formatted_", e.g., formatted_MyFile.java is the formatted form of MyFile.java.

Credits

The formatter is heavily based on work published here:

https://ssscripting.wordpress.com/2009/06/10/how-to-use-the-eclipse-code-formatter-from-your-code/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.