Skip to main content
Version: 2.23

google-java-format


Google Java Format (https://github.com/google/google-java-format)

Backend: pants.backend.experimental.java.lint.google_java_format

Config section: [google-java-format]

Basic options

aosp

--[no-]google-java-format-aosp
PANTS_GOOGLE_JAVA_FORMAT_AOSP
pants.toml
[google-java-format]
aosp = <bool>
default: False

Use AOSP style instead of Google Style (4-space indentation). ("AOSP" is the Android Open Source Project.)

skip

--[no-]google-java-format-skip
PANTS_GOOGLE_JAVA_FORMAT_SKIP
pants.toml
[google-java-format]
skip = <bool>
default: False

If true, don't use Google Java Format when running pants fmt and pants lint.

Advanced options

artifacts

--google-java-format-artifacts="['<str>', '<str>', ...]"
PANTS_GOOGLE_JAVA_FORMAT_ARTIFACTS
pants.toml
[google-java-format]
artifacts = [
'<str>',
'<str>',
...,
]
default:
[
  "com.google.googlejavaformat:google-java-format:{version}"
]

Artifact requirements for this tool using specified as either the address of a jvm_artifact target or, alternatively, as a colon-separated Maven coordinates (e.g., group:name:version). For Maven coordinates, the string {version} version will be substituted with the value of the [google-java-format].version option.

jvm_options

--google-java-format-jvm-options="['<str>', '<str>', ...]"
PANTS_GOOGLE_JAVA_FORMAT_JVM_OPTIONS
pants.toml
[google-java-format]
jvm_options = [
'<str>',
'<str>',
...,
]
default: []

List of JVM options to pass to google-java-format JVM processes.

Options set here will be added to those set in [jvm].global_options. Please check the documentation for the jvm subsystem to see what values are accepted here.

lockfile

--google-java-format-lockfile=<str>
PANTS_GOOGLE_JAVA_FORMAT_LOCKFILE
pants.toml
[google-java-format]
lockfile = <str>
default: <default>

Path to a lockfile used for installing the tool.

Set to the string <default> to use a lockfile provided by Pants, so long as you have not changed the --version option. See https://github.com/pantsbuild/pants/blob/release_2.23.1/src/python/pants/backend/java/lint/google_java_format/google_java_format.default.lockfile.txt for the default lockfile contents.

To use a custom lockfile, set this option to a file path relative to the build root, then run pants jvm-generate-lockfiles --resolve=google-java-format.

version

--google-java-format-version=<str>
PANTS_GOOGLE_JAVA_FORMAT_VERSION
pants.toml
[google-java-format]
version = <str>
default: 1.13.0

Version string for the tool. This is available for substitution in the [google-java-format].artifacts option by including the string {version}.

Deprecated options

None

None