Skip to content

Stop publishing the ANTLR tool as a dependency - #85

Merged
ryansmith4 merged 3 commits into
mainfrom
fix/antlr-tool-not-published
Nov 22, 2026
Merged

ryansmith4 merged 3 commits into
mainfrom
fix/antlr-tool-not-published

Conversation

@ryansmith4

@ryansmith4 ryansmith4 commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

What this fixes

The published POM lists org.antlr:antlr4, the ANTLR grammar tool, as a compile dependency beside antlr4-runtime and slf4j-api. An application that depends on this library therefore also gets the tool and everything it needs:

Before After
org.antlr:antlr4-runtime org.antlr:antlr4-runtime
org.slf4j:slf4j-api org.slf4j:slf4j-api
org.antlr:antlr4 (the tool)
org.antlr:antlr-runtime 3.5.3
org.antlr:ST4 4.3.4
org.abego.treelayout:org.abego.treelayout.core 1.0.3
com.ibm.icu:icu4j 72.1

Only the runtime is used at run time. The tool is needed once, at build time, to generate the parser from the grammar. The README and CLAUDE.md already say that only antlr4-runtime and slf4j-api ship; this makes that true.

Both released versions are affected. A POM generated from the v1.0.0 tag and one from the v1.1.0 tag each list the tool.

Cause and change

Gradle's antlr plugin makes the api configuration extend the antlr configuration, so whatever is declared for the tool is also published. build.gradle now removes that link with one line after the dependencies block.

The checkRuntimeDependencies task, part of ./gradlew check, now guards against this. Until now it accepted any dependency whose group started with org.antlr or org.slf4j, so it let the tool through. build.gradle now holds the exact list of what the library publishes as dependencies (shippedLibraries: antlr4-runtime and slf4j-api), and the check fails when anything else would be published or when a listed library is not. The groups that the two Dependabot files must mention are taken from that list.

Also fixed: generated sources were in the sources jar twice

The generated parser sources landed in a folder nested inside itself (.../com/guidedbyte/address/parser/com/guidedbyte/address/parser/), because the build set an output directory that repeated the package packageName already adds. Each generated file was therefore in the sources jar twice, once at a wrong path. The output directory is now the plugin's default. The library jar is unchanged.

What was tested

  • The generated POM before and after differs only by the removed antlr4 entry. The Gradle module metadata loses the same entry from both of its variants and nothing else.
  • runtimeClasspath and compileClasspath now hold exactly antlr4-runtime and slf4j-api.
  • ./gradlew clean build --warning-mode fail passes, so the grammar still generates and compiles without the tool on the compile classpath.
  • All 366 tests pass when re-run without the build cache.
  • The check, against twelve edited copies of build.gradle in a separate clone. It fails with the fix line removed, with the tool declared directly, with another org.antlr library (ST4, the ANTLR 3 tool), with an unrelated library as implementation, compileOnlyApi or an api constraint, with a library added to the list but not to the Dependabot files, and with a list that names something not published. It passes for compileOnly and testImplementation dependencies.
  • The library jar is byte-for-byte identical on main, after the first commit and after the second. The sources jar loses exactly the ten duplicated files and nothing else changes in it. The javadoc jar is identical.
  • Pulling the change into a checkout that was already built, without cleaning first, leaves no stale files and produces the same jars.
  • An independent reviewer confirmed the above in a separate clone, found that the compiled classes refer only to org.antlr.v4.runtime, org.slf4j and the JDK, and built a separate project against the published library that parsed addresses with none of the removed libraries present.

For the release notes

This changes what applications receive, in two ways. Both are unlikely to matter, but they are why this should be named in the notes of the next release.

  • An application that used the ANTLR tool, the ANTLR 3 runtime, ST4, ICU4J or treelayout only because this library brought them in must now declare them itself.
  • An application that gets ICU4J, ST4 or the ANTLR 3 runtime from somewhere else at an older version was being raised to the versions in the table by this library. After upgrading it gets its own version back.

The library's jar is byte-for-byte the same before and after; only the list of dependencies changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_018ffDfV5858ERd3MkYFRJUN

The published POM listed org.antlr:antlr4, the grammar tool, beside
antlr4-runtime. Applications using this library therefore also received
the tool and what it needs: ANTLR 3, ST4, ICU4J and treelayout. Only
the runtime is used at run time.

Gradle's antlr plugin causes this by making the `api` configuration
extend `antlr`. build.gradle now removes that link. The tool still
generates the parser at build time.

checkRuntimeDependencies now fails if the tool is published again. The
tool shares the org.antlr group with the runtime, so the existing group
test could not catch it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ffDfV5858ERd3MkYFRJUN
@ryansmith4 ryansmith4 added the bug Something isn't working label Nov 22, 2026
ryansmith4 and others added 2 commits November 22, 2026 09:08
Review of the previous commit found that its new check named the ANTLR
tool only, so another org.antlr library added to a published
configuration would still pass.

- build.gradle: shippedLibraries is now the exact list of what this
  library publishes as dependencies (antlr4-runtime and slf4j-api).
  checkRuntimeDependencies fails when anything else would be published
  or when a listed library is not. The groups the Dependabot files
  must mention are taken from that list. When the unexpected
  dependency is the ANTLR tool, the message names both ways it can get
  there.
- build.gradle: the generated parser sources no longer land in a
  folder nested inside itself. The output directory repeated the
  package that packageName already adds, which also put every
  generated file in the sources jar twice. The library jar is
  unchanged.
- CLAUDE.md: describe the exact list.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ffDfV5858ERd3MkYFRJUN
Text only; no logic changes.

- build.gradle: the message for a listed library that is no longer
  published now gives both remedies, removing it from the list or
  restoring the dependency. The comment above the check names a third
  limit: it does not see a dependency on another project of this
  build.
- CLAUDE.md: the sentence about the check now includes that case.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ffDfV5858ERd3MkYFRJUN
@ryansmith4
ryansmith4 merged commit cc86f11 into main Nov 22, 2026
9 checks passed
@ryansmith4
ryansmith4 deleted the fix/antlr-tool-not-published branch November 22, 2026 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant