HomeDocs
DocsCommunityTestimonialsUsersGitHubTwitterBlogJobsTermsPrivacyCookies
TermsPrivacyCookies
Hey! These docs are for version 2.13, which is no longer officially supported. Click here for the latest version, 2.17!


Ktlint, the anti-bikeshedding Kotlin linter with built-in formatter (https://ktlint.github.io/)

Backend: <span style="color: purple"><code>pants.backend.experimental.kotlin.lint.ktlint</code></span> Config section: <span style="color: purple"><code>[ktlint]</code></span>

## Basic options

<div style="color: purple">

### `skip`

<code>--[no-]ktlint-skip</code><br> <code>PANTS_KTLINT_SKIP</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>False</code></span>

<br>

Don't use Ktlint when running `./pants fmt` and `./pants lint`.

</div> <br>

## Advanced options

<div style="color: purple">

### `version`

<code>--ktlint-version=<str></code><br> <code>PANTS_KTLINT_VERSION</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>0.45.2</code></span>

<br>

Version string for the tool. This is available for substitution in the `[ktlint].artifacts` option by including the string `{version}`.

</div> <br>

<div style="color: purple">

### `artifacts`

<code>--ktlint-artifacts="['&lt;str&gt;', '&lt;str&gt;', ...]"</code><br> <code>PANTS_KTLINT_ARTIFACTS</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <pre>[ "com.pinterest:ktlint:{version}" ]</pre></span>

<br>

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 `[ktlint].version` option.

</div> <br>

<div style="color: purple">

### `lockfile`

<code>--ktlint-lockfile=<str></code><br> <code>PANTS_KTLINT_LOCKFILE</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>&lt;default&gt;</code></span>

<br>

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.13.1rc1/src/python/pants/backend/kotlin/lint/ktlint/ktlint.lock 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=ktlint`.

</div> <br>

<div style="color: purple">

### `jvm_options`

<code>--ktlint-jvm-options="['&lt;str&gt;', '&lt;str&gt;', ...]"</code><br> <code>PANTS_KTLINT_JVM_OPTIONS</code><br>

</div> <div style="padding-left: 2em;"> <span style="color: green">default: <code>[]</code></span>

<br>

List of JVM options to pass to `ktlint` 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.

</div> <br>

## Deprecated options

None