|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Build Commands |
| 6 | + |
| 7 | +```bash |
| 8 | +# Full build |
| 9 | +./gradlew --no-daemon build |
| 10 | + |
| 11 | +# Run tests for a specific subproject |
| 12 | +./gradlew --no-daemon :docling-serve-client:test |
| 13 | + |
| 14 | +# Run a specific test class |
| 15 | +./gradlew --no-daemon :docling-serve-client:test --tests "ai.docling.serve.client.SomeTestClass" |
| 16 | + |
| 17 | +# Lint check (enforces import order + whitespace rules) |
| 18 | +./gradlew --no-daemon spotlessCheck |
| 19 | + |
| 20 | +# Auto-apply formatting fixes |
| 21 | +./gradlew --no-daemon spotlessApply |
| 22 | +``` |
| 23 | + |
| 24 | +## Project Architecture |
| 25 | + |
| 26 | +This is a multi-module Gradle project (Kotlin DSL) with group `ai.docling`. Version is managed in `.github/project.yml` under `release.current-version`. |
| 27 | + |
| 28 | +### Modules |
| 29 | + |
| 30 | +- **`docling-core`**: Java types mirroring the [docling-core](https://github.com/docling-project/docling-core) Python library's document representation model. Uses Lombok and JSpecify. Jackson is a `compileOnly` dependency — consumers must bring their own. |
| 31 | +- **`docling-serve-api`** (`docling-serve/docling-serve-api`): Framework-agnostic API interfaces for interacting with a [Docling Serve](https://github.com/docling-project/docling-serve) backend. Defines `DoclingServeApi` (extends `DoclingServeHealthApi`, `DoclingServeConvertApi`, `DoclingServeChunkApi`, `DoclingServeClearApi`, `DoclingServeTaskApi`) and the SPI interface `DoclingServeApiBuilderFactory` used for discovery via `java.util.ServiceLoader`. |
| 32 | +- **`docling-serve-client`** (`docling-serve/docling-serve-client`): Reference implementation using Java's `HttpClient`. Provides `DoclingServeJackson2Client` and `DoclingServeJackson3Client` — concrete implementations for Jackson 2.x and 3.x respectively. `DoclingServeClient` (abstract) contains all HTTP logic. |
| 33 | +- **`docling-testcontainers`**: Testcontainers module exposing `DoclingServeContainer` for spinning up a Docling Serve Docker container in tests. |
| 34 | +- **`docling-testing/docling-version-tests`**: Internal tooling for running compatibility tests across Docling Serve container versions. |
| 35 | + |
| 36 | +### Key Design Patterns |
| 37 | + |
| 38 | +**SPI for client discovery**: `DoclingServeApi.builder()` uses `ServiceLoader` to discover a `DoclingServeApiBuilderFactory`. Exactly one implementation must be on the classpath — having zero or more than one throws `IllegalStateException`. The `docling-serve-client` module registers itself as the factory. |
| 39 | + |
| 40 | +**Dual Jackson support**: All Jackson dependencies are `compileOnly` in production code. Jackson 2.x and 3.x are both supported through parallel implementations. Consumers must include one Jackson version on their classpath. |
| 41 | + |
| 42 | +**Java modules**: All publishable modules include `module-info.java`. The `docling-lombok.gradle.kts` convention plugin temporarily renames `module-info.java` during the Lombok `delombok` task to avoid module processing issues. |
| 43 | + |
| 44 | +### Convention Plugins (in `buildSrc/`) |
| 45 | + |
| 46 | +- `docling-shared`: Sets group/version from `.github/project.yml` |
| 47 | +- `docling-java-shared`: Applies `docling-shared`, `java-library`, `jacoco`, `spotless`; configures JUnit Jupiter, AssertJ, parallel test execution, and test logging |
| 48 | +- `docling-lombok`: Applies `io.freefair.lombok` with `module-info.java` workaround |
| 49 | +- `docling-release`: Configures `maven-publish` for publishing to Maven Central |
| 50 | + |
| 51 | +### Technology Stack |
| 52 | + |
| 53 | +- Java 17 (minimum), tested against 17, 21, 25 (all LTS) |
| 54 | +- Lombok for boilerplate reduction |
| 55 | +- JSpecify for nullability annotations (`@Nullable`) |
| 56 | +- JUnit Jupiter + AssertJ for testing |
| 57 | +- WireMock for HTTP mocking in tests |
| 58 | +- SLF4J for logging |
| 59 | +- Spotless enforces import order (see `.spotless/import-order.txt`) |
| 60 | + |
| 61 | +## Conventions |
| 62 | + |
| 63 | +- Commits must follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) |
| 64 | +- `spotless` uses `ratchetFrom("origin/main")` — only files changed relative to `origin/main` are checked |
| 65 | +- Line endings: LF; no trailing whitespace; files must end with a newline (`.editorconfig`) |
0 commit comments