Repository navigation
Stop publishing the ANTLR tool as a dependency - #85
Merged
Merged
Conversation
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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
The published POM lists
org.antlr:antlr4, the ANTLR grammar tool, as a compile dependency besideantlr4-runtimeandslf4j-api. An application that depends on this library therefore also gets the tool and everything it needs:org.antlr:antlr4-runtimeorg.antlr:antlr4-runtimeorg.slf4j:slf4j-apiorg.slf4j:slf4j-apiorg.antlr:antlr4(the tool)org.antlr:antlr-runtime3.5.3org.antlr:ST44.3.4org.abego.treelayout:org.abego.treelayout.core1.0.3com.ibm.icu:icu4j72.1Only 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.mdalready say that onlyantlr4-runtimeandslf4j-apiship; this makes that true.Both released versions are affected. A POM generated from the
v1.0.0tag and one from thev1.1.0tag each list the tool.Cause and change
Gradle's
antlrplugin makes theapiconfiguration extend theantlrconfiguration, so whatever is declared for the tool is also published.build.gradlenow removes that link with one line after thedependenciesblock.The
checkRuntimeDependenciestask, part of./gradlew check, now guards against this. Until now it accepted any dependency whose group started withorg.antlrororg.slf4j, so it let the tool through.build.gradlenow holds the exact list of what the library publishes as dependencies (shippedLibraries:antlr4-runtimeandslf4j-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 packagepackageNamealready 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
antlr4entry. The Gradle module metadata loses the same entry from both of its variants and nothing else.runtimeClasspathandcompileClasspathnow hold exactlyantlr4-runtimeandslf4j-api../gradlew clean build --warning-mode failpasses, so the grammar still generates and compiles without the tool on the compile classpath.build.gradlein a separate clone. It fails with the fix line removed, with the tool declared directly, with anotherorg.antlrlibrary (ST4, the ANTLR 3 tool), with an unrelated library asimplementation,compileOnlyApior anapiconstraint, with a library added to the list but not to the Dependabot files, and with a list that names something not published. It passes forcompileOnlyandtestImplementationdependencies.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.org.antlr.v4.runtime,org.slf4jand 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.
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