Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 180
tab_width = 2
ij_continuation_indent_size = 4
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/spotless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Spotless

on:
pull_request:
branches:
- main
workflow_dispatch:

concurrency:
group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

defaults:
run:
shell: bash

permissions:
contents: read

jobs:
spotless-check:
runs-on: ubuntu-latest
name: spotless-check
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

- name: Reclaim disk space
working-directory: .github/scripts
shell: bash
run: ./ci-reclaim-disk-space.sh

- name: Set up Java 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: 17
distribution: temurin

- name: Setup Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2

- name: Run Spotless check
run: |
if ! ./gradlew --no-daemon -Pjava.version=17 spotlessCheck; then
echo "::error title=Spotless check failed::Formatting violations were found."
echo "Fix options:"
echo " 1) Run: ./gradlew --no-daemon spotlessApply"
echo " 2) Ensure your IDE honors .editorconfig and reformat changed files"
echo "Then commit and push the updated files."
exit 1
fi
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ If you have not done so on this machine, you need to:

The project has a `.editorconfig` file checked into the root. Please make sure the rules in there are adhered to by your IDE.

## Build

To run a full build locally:

```bash
./gradlew --no-daemon build
```

To run code linting locally:

```bash
./gradlew --no-daemon spotlessCheck
```

To automatically apply formatting fixes:

```bash
./gradlew --no-daemon spotlessApply
```

`spotlessCheck` enforces Java formatting plus basic whitespace rules (LF line endings, no trailing whitespace, and final newline). IDE style settings are still driven by `.editorconfig`.

## The small print

This project is an open source project, please act responsibly, be nice, polite and enjoy!
1 change: 1 addition & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repositories {
dependencies {
implementation("org.yaml:snakeyaml:2.5")
implementation(libs.lombok.gradle)
implementation(libs.spotless.gradle)
}

// Read root gradle.properties
Expand Down
14 changes: 14 additions & 0 deletions buildSrc/src/main/kotlin/docling-java-shared.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id("docling-shared")
`java-library`
`jacoco`
id("com.diffplug.spotless")
}

repositories {
Expand Down Expand Up @@ -41,6 +42,19 @@ jacoco {
toolVersion = libs.findVersion("jacoco").get().toString()
}

spotless {
lineEndings = com.diffplug.spotless.LineEnding.UNIX

java {
target("src/*/java/**/*.java")
target("src/*/java/module-info.java")
removeUnusedImports()
formatAnnotations()
trimTrailingWhitespace()
endWithNewline()
}
}
Copy link
Contributor

@edeandrea edeandrea Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't read up on spotless and its configuration - is there a way to specify the configuration outside of the gradle dsl? And is there a way to get it to respect what we have in .editorconfig?

Ideally I'd prefer control over formatting/etc to be defined in a single place, whether thats .editorconfig or somewhere else. It would also be nice if when a user loads the project into an IDE, the formatting rules are respected by the IDE. Anything we can do to make that easier is a win.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we can govern it using .editorconfig

Copy link
Contributor

@edeandrea edeandrea Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it use .editorconfig by default if you don't add any additional config for java?

I see in the documentation it works that way for kotlin (ktlint)


tasks.withType<Test>().configureEach {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ junit = "6.0.3"
lombok = "1.18.42"
lombok-gradle = "9.2.0"
module-info = "1.14"
spotless = "8.2.1"
semver4j = "6.0.0"
slf4j = "2.0.17"
testcontainers = "2.0.3"
Expand All @@ -26,6 +27,7 @@ awaitility = { group = "org.awaitility", name = "awaitility", version.ref = "awa

# lombok-gradle
lombok-gradle = { group = "io.freefair.lombok", name = "io.freefair.lombok.gradle.plugin", version.ref = "lombok-gradle" }
spotless-gradle = { group = "com.diffplug.spotless", name = "spotless-plugin-gradle", version.ref = "spotless" }

# Jackson
jackson-annotations = { group = "com.fasterxml.jackson.core", name = "jackson-annotations" }
Expand Down