docling-java
Copilot instructions141 starsChanged 11 months agoMITView on GitHub
docling-java is a multi-module Java library providing a Java API for Docling, an IBM Research project for AI-based document processing (PDF, DOCX, PPTX, images, audio, etc.). The project is published to Maven Central under the ai.docling group ID. Note: Tests in docling-serve-client that use WireMock also start a DoclingServeContainer via Testcontainers and therefore require a running Docker daemon. Tests in docling-testcontainers that use Testcontainers likewise require Docker, while tests in docling-serve-api do not use WireMock and can run without Docker.
We split this copilot-instructions.md into the rules it gives an agent
14 rules. About 0 are common, 6 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 51
All dependency versions live in gradle/libs.versions.toml (version catalog).
- Distinctive: line 86
All model/value types use Lombok annotations.
- Very specific: line 100
Use @lombok.Singular on collection fields for builder singular-adder methods.
- Distinctive: line 105
Use JSpecify annotations for nullability:
- Very specific: line 119
Use com.fasterxml.jackson.annotation.* for Jackson 2/3-compatible annotations (@JsonProperty, @JsonInclude, @JsonSetter, etc.).
- Very specific: line 120
Use @tools.jackson.databind.annotation.JsonDeserialize for Jackson 3-specific deserializer wiring.
- Distinctive: line 134
Follow Conventional Commits for all commit messages and PR titles.
- Distinctive: line 176
Avoid adding new testing frameworks.
- Very specific: line 178
Test class naming convention: *Tests.java (e.g., DoclingServeClientTests.java).
- Distinctive: line 180
Run a single test class:
- Distinctive: line 189
Check for security advisories before adding new libraries.
- Very specific: line 190
Keep Jackson as compileOnly where it is already compileOnly — it must not become a transitive API dependency.
- Very specific: line 222
Default image constant pattern: DoclingServeContainerConfig.DOCLING_IMAGE → ghcr.io/docling-project/docling-serve:<DOCLING_IMAGE_VERSION> …
- Very specific: line 247
When adding a new public API or module, add or update the corresponding .md file.
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Docling Java – Copilot Instructions
Project Overview
docling-java is a multi-module Java library providing a Java API for Docling, an IBM Research project for AI-based document processing (PDF, DOCX, PPTX, images, audio, etc.).
The project is published to Maven Central under the ai.docling group ID.
Repository Structure
docling-java/
├── buildSrc/ # Convention plugins (Gradle Kotlin DSL)
│ └── src/main/kotlin/
│ ├── docling-shared.gradle.kts # group/version resolution
│ ├── docling-java-shared.gradle.kts # java-library + jacoco + JUnit 5 test config
│ ├── docling-lombok.gradle.kts # Lombok setup
│ └── docling-release.gradle.kts # maven-publish setup
├── gradle/libs.versions.toml # Version catalog (single source of truth for deps)
├── gradle.properties # Gradle settings (java.version=17, parallel, caching)
├── settings.gradle.kts # Module declarations
├── docling-core/ # Core DoclingDocument model (no runtime deps)
├── docling-serve/
│ ├── docling-serve-api/ # Framework-agnostic API interfaces + request/response types
│ └── docling-serve-client/ # Reference HTTP client (Java HttpClient + Jackson)
├── docling-testcontainers/ # Testcontainers module for Docling Serve
├── docling-testing/
│ └── docling-version-tests/ # Quarkus/Picocli CLI for version-compatibility testing
├── docs/ # MkDocs documentation site
├── test-report-aggregation/ # Aggregated JaCoCo + JUnit reports
└── .github/
├── project.yml # release.current-version (source of truth for version)
└── workflows/ # CI: build.yml, release.yml, docs.yml, version-tests.ymlModule ↔ Gradle project name mapping
| Directory path | Gradle project name |
docling-core | :docling-core |
docling-serve/docling-serve-api | :docling-serve-api |
docling-serve/docling-serve-client | :docling-serve-client |
docling-testcontainers | :docling-testcontainers |
docling-testing/docling-version-tests | :docling-version-tests |
Build System
- Gradle with Kotlin DSL (
build.gradle.kts,settings.gradle.kts). - Java 17 is the baseline; CI also tests Java 21 and 25.
- Convention plugins in
buildSrc/keep modulebuild.gradle.ktsfiles minimal. - All dependency versions live in
gradle/libs.versions.toml(version catalog). - Project version is read from
.github/project.yml(release.current-version) bydocling-shared.gradle.kts.
Common Build Commands
# Build and test a single module (recommended during development)
./gradlew :docling-serve-api:clean :docling-serve-api:build
./gradlew :docling-serve-client:clean :docling-serve-client:build
./gradlew :docling-testcontainers:clean :docling-testcontainers:build
./gradlew :docling-core:clean :docling-core:build
# Run tests for a specific module
./gradlew :docling-serve-api:test
./gradlew :docling-serve-client:test
# Specify a different Java version
./gradlew -Pjava.version=21 :docling-serve-client:build
# Generate aggregated test report
./gradlew :test-report-aggregation:check
# Build the documentation site
./gradlew :docs:build
# Run the version-compatibility CLI (dev mode, requires Docker)
./gradlew :docling-version-tests:quarkusDevNote: Tests in
docling-serve-clientthat use WireMock also start aDoclingServeContainervia Testcontainers and therefore require a running Docker daemon. Tests indocling-testcontainersthat use Testcontainers likewise require Docker, while tests indocling-serve-apido not use WireMock and can run without Docker.
Java Code Conventions
Lombok
All model/value types use Lombok annotations. The standard pattern for immutable value objects is:
@lombok.Builder(toBuilder = true)
@lombok.Getter
@lombok.ToString
@lombok.extern.jackson.Jacksonized // for Jackson deserialization via builder
public class MyType {
@Nullable
private String optionalField;
private String requiredField;
}- Use
@lombok.Singularon collection fields for builder singular-adder methods. - A
lombok.configfile exists in module source roots; do not remove it.
Nullability
Use JSpecify annotations for nullability:
import org.jspecify.annotations.Nullable;
@Nullable
private String mayBeNull; // field/param/return that may be null
// no annotation = non-null by defaultJackson (dual Jackson 2 & 3 support)
The project supports both Jackson 2 (com.fasterxml.jackson) and Jackson 3 (tools.jackson). When annotating models:
- Use
com.fasterxml.jackson.annotation.*for Jackson 2/3-compatible annotations (@JsonProperty,@JsonInclude,@JsonSetter, etc.). - Use
@tools.jackson.databind.annotation.JsonDeserializefor Jackson 3-specific deserializer wiring. - Jackson is a
compileOnly/testImplementationdependency in most modules — it must not leak as a transitiveapidependency.
Module System (JPMS)
Most library modules have a module-info.java (some non-library/test modules, such as docling-version-tests, do not). When adding new packages to a library module, export them in its module-info.java. Jackson and Lombok are requires static (optional at runtime).
Javadoc
All public types and methods require Javadoc. The build runs Javadoc with -Xdoclint:syntax,html, but the Javadoc task is configured with isFailOnError = false, so Javadoc issues do not currently fail the build. Treat Javadoc warnings and errors as if they were fatal when contributing and keep Javadoc accurate and complete.
Code Style
.editorconfigat the repository root defines formatting rules. Follow it.- Follow Conventional Commits for all commit messages and PR titles.
- Commits should be atomic and squashed before merging.
Conventional Commits format
<type>[optional scope]: <short description>
[optional body]
[optional footer(s)]Common types used in this project:
| Type | When to use |
feat | A new feature or capability |
fix | A bug fix |
docs | Documentation-only changes (including copilot-instructions.md) |
chore | Build scripts, CI config, dependency bumps, tooling |
refactor | Code restructuring with no behaviour change |
test | Adding or updating tests |
style | Formatting / code style (no logic change) |
Examples:
docs: add copilot-instructions.md for coding agent onboarding
feat(serve-client): add retry support to DoclingServeClient
fix(core): handle null RefItem in DoclingDocument resolution
chore: bump jackson to 2.18.3Important: Every commit pushed to this repository — including automated commits made by coding agents — must follow this format. PRs with non-conforming commit messages will be asked to reword or squash before merging.
Testing Conventions
- JUnit 5 (
org.junit.jupiter) is the test framework for all modules. - AssertJ is used for assertions (
assertThat(...),assertThatThrownBy(...)). - WireMock is used to mock HTTP servers in
docling-serve-clienttests. - Testcontainers is used for integration tests that need a real Docling Serve container (requires Docker).
- Avoid adding new testing frameworks; use the ones already present.
Test class naming convention: *Tests.java (e.g., DoclingServeClientTests.java).
Run a single test class:
./gradlew :docling-serve-client:test --tests "ai.docling.serve.client.DoclingServeJackson3ClientTests"Dependency Management
- Never hardcode dependency versions in
build.gradle.kts; add versions togradle/libs.versions.toml(or use the BOM) and reference dependencies via thelibs.*version catalog. - Check for security advisories before adding new libraries.
- Keep Jackson as
compileOnlywhere it is alreadycompileOnly— it must not become a transitive API dependency.
Key APIs
DoclingServeApi (docling-serve-api)
The main entry point for consumers. Uses SPI (ServiceLoader) to discover the client implementation at runtime:
DoclingServeApi api = DoclingServeApi.builder() // discovers docling-serve-client on classpath
.baseUrl("http://localhost:5001")
.build();
ConvertDocumentResponse response = api.convertSource(request);DoclingServeContainer (docling-testcontainers)
Wraps a Testcontainers GenericContainer for ghcr.io/docling-project/docling-serve:
DoclingServeContainer container = new DoclingServeContainer(
DoclingServeContainerConfig.builder()
.image(DoclingServeContainerConfig.DOCLING_IMAGE) // default image
.enableUi(false)
.startupTimeout(Duration.ofMinutes(2))
.build()
);
// Default port: 5001 (automatically mapped)
// container.getApiUrl() → "http://localhost:<mapped_port>"Default image constant pattern: DoclingServeContainerConfig.DOCLING_IMAGE → ghcr.io/docling-project/docling-serve:<DOCLING_IMAGE_VERSION> (where <DOCLING_IMAGE_VERSION> is a concrete tag such as v1.13.0).
CI/CD
GitHub Actions workflows in .github/workflows/:
| Workflow | Trigger | What it does |
build.yml | push/PR to main | Builds and tests all modules on Java 17, 21, 25 |
release.yml | manual/tag | Publishes to Maven Central via JReleaser |
docs.yml | push to main | Publishes MkDocs site to GitHub Pages |
version-tests.yml | scheduled / manual | Runs docling-version-tests CLI against GHCR image tags |
dependabot-automerge.yml | Dependabot PRs | Auto-merges minor/patch dependency updates |
The build.yml matrix runs each module independently (docling-serve-api, docling-serve-client, docling-testcontainers, docling-version-tests) across Java versions.
Versioning and Release
- Current version is in
.github/project.ymlunderrelease.current-version. - Releases follow semantic versioning and are managed by JReleaser (
jreleaser.yml). - Do not bump version manually in build files; the version is read dynamically from
.github/project.yml.
Documentation
- Docs live in
docs/src/doc/docs/as Markdown files, built with MkDocs Material. - When adding a new public API or module, add or update the corresponding
.mdfile. - Template variables like
{{ gradle.project_version }}are substituted during the Gradle docs build.
Known Errors and Workarounds
delombokandmodule-info.java: The Lombok Gradle plugin cannot processmodule-info.java. Thedocling-lombok.gradle.ktsconvention plugin temporarily renamesmodule-info.javatomodule-info.java.bakduring delombok and restores it afterward. Do not remove this workaround.- Docker not available in CI for Testcontainers tests: The
docling-serve-clientanddocling-testcontainersmodules include Testcontainers-based integration tests. These require Docker and may be skipped in environments without a Docker daemon. Thebuild.ymlCI workflow runs onubuntu-latestwhich has Docker available. - Jackson 2 vs Jackson 3: The project supports both Jackson 2 and Jackson 3. Some annotations (
@JsonProperty,@JsonInclude) work with both; others are version-specific. Usecom.fasterxml.jackson.annotationfor shared annotations andtools.jackson.*for Jackson 3-specific ones.
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

