Skip to content

versionCatalog step produces multi-line inline tables that Gradle cannot parse #2948

@mkutz

Description

@mkutz

Problem

The versionCatalog step's maxLineLength feature splits long inline tables across multiple lines when they exceed the configured limit.
This produces TOML 1.1 multi-line inline table syntax, which Gradle's version catalog parser (TOML 1.0) cannot read.

After running spotlessApply, the next Gradle build fails with parse errors like:

Unexpected end of line, expected a-z, A-Z, 0-9, }, ', or "

Steps to Reproduce

  1. Add a versionCatalog step with maxLineLength (default is 120):

    spotless {
      toml {
        target("gradle/libs.versions.toml")
        versionCatalog()
      }
    }
  2. Have an entry in libs.versions.toml that exceeds 120 characters:

    [libraries]
    asciidoctor-block-switch = { module = "io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch", version = "0.6.3" }
  3. Run ./gradlew spotlessApply. The entry is split to:

    asciidoctor-block-switch = {
      module = "io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch",
      version = "0.6.3",
    }
  4. The next ./gradlew invocation fails because Gradle's TOML parser does not support multi-line inline tables.

The formatter itself is idempotent — it can parse its own multi-line output back. But Gradle cannot, making the file unusable after formatting.

Expected Behavior

The versionCatalog step should not produce output that Gradle's version catalog parser cannot read. Long lines should be left as-is, since Gradle requires inline tables on a single line.

Workaround

Disable line splitting by setting maxLineLength to 0:

spotless {
  toml {
    target("gradle/libs.versions.toml")
    versionCatalog().maxLineLength(0)
  }
}

Environment

  • Spotless: 8.5.1
  • Gradle: 9.5.1
  • JDK: 21

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions