Gradle and Maven plugins that collect DOCUMENTATION.md artifacts, changelogs, and sources from your project's dependencies and organize them into an AI-navigable file structure — so AI coding assistants can deeply understand every library you use without blowing up their context window.
When an AI agent works on a Java project with many dependencies, it either loads all documentation (too much context), loads nothing (works blind), or asks you every time. None of these scale.
AI Docs introduces a simple convention:
- Library authors publish a
DOCUMENTATION.mdalongside their jar (as a Maven artifact with classifierDOCUMENTATION) - Projects apply this plugin and run
./gradlew collectDocs(ormvn ai-docs:collect-docs) - AI agents navigate the output efficiently: index → overview → specific lines
Three small reads instead of dumping everything into context.
// settings.gradle
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
}// build.gradle
plugins {
id 'java'
id 'one.jpro.aidocs' version '0.1.0-SNAPSHOT'
}./gradlew collectDocsThis collects all dependency docs into build/ai-docs/ and installs a skill file at .claude/skills/docs/SKILL.md so AI agents automatically know the documentation is available.
build/ai-docs/
├── context.md # Combined overview of all libraries
├── index.md # Compact ToC with line ranges into context.md
├── one.jpro.platform/
│ └── jpro-routing-core/
│ ├── overview.md # Chapter titles + line ranges
│ ├── DOCUMENTATION.md # Full documentation
│ ├── CHANGELOG.md # If published, plus changelog-overview.md
│ ├── sources.jar.link # Path of the sources jar in the local cache
│ ├── sources-index.md # All source files by package, with unzip commands
│ ├── javadoc.jar.link # Path of the javadoc jar (when it contains guides)
│ └── javadoc-index.md # Hand-written doc-files guides (e.g. JavaFX CSS reference)
A SKILL.md is also generated at .claude/skills/docs/ so AI agents discover the documentation automatically.
index.md — lightweight entry point with line ranges into context.md:
# AI Documentation Index
## Libraries
- one.jpro.platform:jpro-routing-core:0.5.8 (JPro Routing Core) (lines 91-106) — A framework for building JPro/JavaFX applications...overview.md — chapter structure with line ranges and summaries:
# JPro Routing Core (0.5.8)
Full content: DOCUMENTATION.md
## Chapters
- Overview (lines 1-25) — A framework for building JPro/JavaFX applications.
- Getting Started (lines 26-80) — Add the dependency to your build.
- Filters API (lines 81-150) — Filters transform routes.Add the plugin to your pom.xml:
<plugin>
<groupId>one.jpro.aidocs</groupId>
<artifactId>ai-docs-maven-plugin</artifactId>
<version>0.1.0-SNAPSHOT</version>
</plugin>Then run:
mvn one.jpro.aidocs:ai-docs-maven-plugin:collect-docsThe output is collected into target/ai-docs/ with the same structure.
aiDocs {
includeBuildscript = true // also document buildscript/plugin-classpath dependencies (default: false)
}The generated .claude/skills/docs/SKILL.md contains a marker comment — remove it to take ownership of the file; the plugin will then leave it untouched.
- Read
context.md— combined overview of all libraries (best for small-to-medium projects), orindex.mdto find the right library's line range first - Read
overview.mdfor the relevant library — see chapter structure with line ranges - Read specific lines from
DOCUMENTATION.md— load only the chapter needed - Dig into sources when docs aren't enough —
sources-index.mdlists every source file (javadoc included); read one viaunzip -p "$(cat sources.jar.link)" <path>or extract them all for grepping
DOCUMENTATION.md is not agent-specific — it's simply your library's regular documentation (typically the README or the source of your docs website), cross-published as a Maven artifact so that any consumer can fetch the version that matches the jar. This plugin is one such consumer; documentation websites, IDEs, or other tooling can use the same artifact.
To publish it:
- Classifier:
DOCUMENTATION - Extension:
md
The artifact coordinate looks like: com.example:my-lib:1.0.0:DOCUMENTATION@md
Libraries that don't publish this artifact are silently skipped — no errors, no warnings.
The example/ directory is a project with JPro dependencies. Set it up and let an AI agent build a full app:
./gradlew publishToMavenLocal # from root
cd example
./gradlew collectDocs # collect dependency docsThen open the example/ directory in Claude Code and prompt:
Build an Expense Tracker web application using JavaFX and JPro.
Use jpro-routing for multi-page navigation and jpro-auth-routing for Google login.
Read the documentation in build/ai-docs/ to understand the frameworks.
The agent discovers the available libraries, learns their APIs from the collected docs, and generates the application — without any prior knowledge of these frameworks.
Docs/sources silently missing for some libraries (Gradle): The plugin warns when this likely happened ("resolved from mavenLocal ... provided no documentation artifacts"). If mavenLocal() is in your repositories, remember that Gradle fetches artifacts only from the repository that supplied a module's metadata. A partially populated ~/.m2 — e.g. jar+pom cached by any earlier Maven run — then hides that library's DOCUMENTATION, sources, and javadoc artifacts without any error. Remove mavenLocal(), or restrict it to the artifacts you actually publish locally:
repositories {
mavenLocal {
content {
includeGroupByRegex 'com\\.mycompany.*'
}
}
mavenCentral()
}(Maven is not affected — it treats ~/.m2 as a cache and falls through to remote repositories for missing files.)
Requirements: Java 17+, Gradle 9.2+
# Build and run all tests
./gradlew build
# Publish to local Maven repository
./gradlew publishToMavenLocal
# Try the example project
cd example
./gradlew collectDocs
cat build/ai-docs/index.md| Module | Description |
|---|---|
ai-docs-core |
Reusable library for document collection and index/overview generation |
ai-docs-gradle-plugin |
Gradle plugin providing the collectDocs task |
ai-docs-maven-plugin |
Maven plugin providing the collect-docs goal |
example/ |
Standalone Gradle project demonstrating real-world usage with JPro libraries |
example-maven/ |
Standalone Maven project demonstrating the Maven plugin |