Skip to content

Java Configuration

moznion edited this page Apr 22, 2020 · 8 revisions

Java formatter configuration.

Example

import net.moznion.sbt.spotless.config._

lazy val root = (project in file("."))
  .settings(
    name := "Example",
    spotlessJava := JavaConfig(
      googleJavaFormat = GoogleJavaFormatConfig(version = "1.7"),
      removeUnusedImports = true,
      importOrder = Seq("java", "javax", "org", "com"),
    ),
  )

Setting Key

spotlessJava: JavaConfig

Description

This configuration accepts to embed Formatter Common Configuration.

Default target

*.java files that are under the project source directory.

Items

googleJavaFormat: GoogleJavaFormatConfig

Default Value: no value

The formatter configuration for google-java-format.

Example

googleJavaFormat = GoogleJavaFormatConfig(
  version = null,
  style = null,
)

Items

version: String

default value: depends on dependent Spotless version

The version of google-java-format.

style: String

default value: depends on dependent Spotless version

A style name for google-java-format. Please refer to the following code: https://github.com/google/google-java-format/blob/master/core/src/main/java/com/google/googlejavaformat/java/JavaFormatterOptions.java

eclipseJava: EclipseJavaConfig

Default Value: no value

The formatter configuration for Eclipse jdt Formatter.

Example

eclipseJava = GoogleJavaFormatConfig(
  version = null,
  configFiles = null,
)

Items

version: String

default value: depends on dependent Spotless version

The version of Eclipse jdt Formetter.

Supported versions are on the following: https://github.com/diffplug/spotless/tree/master/lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter

configFiles: Seq[File]

default value: empty list

Configuration files for Eclipse jdt Formatter.

importOrder: Seq[String]

Default Value: no value

A seq of import order for java files.

importOrderFile: File

Default Value: no value

A file that contains import order for java files.

removeUnusedImports: Boolean

Default Value: false

A specifier of whether to remove unused imports or not.

licenseHeader: JavaLicenseStringHeaderConfig

default value: null

License header string to prefix a that before the package statement.

licenseHeaderFile: JavaLicenseFileHeaderConfig

default value: null

License header file to prefix a that before the package statement.