Skip to main content

Code Formatting

Bleep provides a unified fmt command that formats Scala, Java, and Kotlin source files in your project.

The formatter for a given language is only downloaded if your project actually contains files of that language, so polyglot or single-language builds pay only for what they use.

Basic Usage

# Format all source files
bleep fmt

# Check formatting without making changes (useful for CI)
bleep fmt --check

Scala Formatting

Bleep uses scalafmt for Scala code formatting.

Configuration is done via .scalafmt.conf in your build directory. If no config exists, bleep creates a default one.

For full configuration options, see the scalafmt documentation.

Example .scalafmt.conf:

version = 3.11.1
maxColumn = 120
runner.dialect = scala3

Java Formatting

Bleep uses google-java-format for Java code formatting.

google-java-format itself has no native config file — it is driven entirely by CLI flags. Bleep exposes those flags through an optional .javafmt.conf (HOCON) in the build directory. With no file present, sensible defaults are used.

Configuration Properties

PropertyTypeDefaultDescription
enabledbooleantrueWhether Java formatting is enabled
versionstring1.35.0Version of google-java-format to use
stylestringgoogleFormatting style: google (2-space indent) or aosp (4-space indent)
skipSortingImportsbooleanfalseDon't sort import statements
skipRemovingUnusedImportsbooleanfalseKeep unused import statements
fixImportsOnlybooleanfalseOnly fix imports, don't reformat code
skipReflowingLongStringsbooleanfalseDon't reformat long strings
skipJavadocFormattingbooleanfalseDon't reformat Javadoc comments
excludePathslist[]Glob patterns for files to exclude

Example .javafmt.conf:

version = 1.35.0
style = aosp

# Skip Javadoc formatting
skipJavadocFormatting = true

# Exclude generated files
excludePaths = ["glob:**/generated/**", "glob:**/build/**"]

Notes

  • Line length is fixed at 100 characters (google-java-format design decision)
  • Indentation is fixed per style (2-space for Google, 4-space for AOSP)

Kotlin Formatting

Bleep uses ktfmt for Kotlin code formatting.

Like google-java-format, ktfmt has no native config file. Bleep exposes its (small) flag surface through an optional .kotlinfmt.conf (HOCON) in the build directory. With no file present, sensible defaults are used.

Configuration Properties

PropertyTypeDefaultDescription
enabledbooleantrueWhether Kotlin formatting is enabled
versionstring0.62Version of ktfmt to use
stylestringkotlinlangFormatting style: kotlinlang (official Kotlin coding conventions), google (Android/Google), or meta (Facebook/ktfmt default)
excludePathslist[]Glob patterns for files to exclude

Example .kotlinfmt.conf:

version = 0.62
style = kotlinlang

# Exclude generated files
excludePaths = ["glob:**/generated/**"]

Notes

  • ktfmt is deliberately near-zero-configuration. Only the listed style switches are exposed; line length and indent are fixed per style.