Skip to content

Reference project template with code style settings for Java / Gradle projects

License

Notifications You must be signed in to change notification settings

rbiedrawa/java-gradle-codestyle-setup

Repository files navigation

Reference project template with code style settings for Java / Gradle projects

This repository contains code style settings that can be used to ensure formatting consistency inside Java / Gradle projects.

Project is configured to use Spotless with Palantir java format which is based on the Google java format.

Getting Started

Usage

Gradle

Use below command to apply Spotless code formatting steps

./gradlew spotlessApply

Git (pre-commit Hook)

Run spotlessApply automatically on every commit.

Installation:

  1. Install pre-commit
    brew install pre-commit
  2. Open new terminal and go to project directory
  3. Install pre-commit hook using .pre-commit-config.yaml
    pre-commit install

Uninstall:

rm ./.git/hooks/pre-commit

Intelij plugin

Installation:

A palantir-java-format IntelliJ plugin is available from the plugin repository. To install it, go to your IDE's settings and select the Plugins category. Click the Marketplace tab, search for the palantir-java-format plugin, and click the Install button.

Usage:

The plugin will be disabled by default on new projects but if using the com.palantir.java-format gradle plugin, it will be recommended in IntelliJ and automatically configured.

To manually enable it in the current project, go to File→Settings...→palantir-java-format Settings ( or IntelliJ IDEA→Preferences...→Other Settings→palantir-java-format Settings on macOS) and check the Enable palantir-java-format checkbox.

When enabled, it will replace the normal Reformat Code action, which can be triggered from the Code menu or with the Ctrl-Alt-L (by default) keyboard shortcut.

Caution:

Custom codeStyles settings are stored inside this repository and they will be used automatically, in order to ensure correct import orders and other formatting rules inside Intelij IDE.

References

License

Distributed under the MIT License. See LICENSE for more information.

About

Reference project template with code style settings for Java / Gradle projects

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages