fix: support import module in removeUnusedImports (GJF 1.30.0) - #3008
Merged
nedtwigg merged 6 commits intoAug 16, 2026
Conversation
Bump default google-java-format 1.28.0 -> 1.30.0 (first release that handles JCModuleImport) and require at least 1.30.0 on JVM 25+. Fixes diffplug#2890
…t-remove-unused # Conflicts: # CHANGES.md # plugin-gradle/CHANGES.md # plugin-maven/CHANGES.md
…t-remove-unused # Conflicts: # plugin-gradle/CHANGES.md # plugin-maven/CHANGES.md
Member
|
Seems like we're good on Java 21+ but this introduces a problem for Java 17. Not sure if it's a code problem or a tests problem. |
google-java-format 1.30.0 references JCAnyPattern (JDK 21+ javac only), so it must not be the default on JVM 17. Restore 1.28.0 for JDK 17 while keeping 1.30.0 default on JVM 21+ and addMin(25, 1.30.0) for import module.
arimu1
force-pushed
the
fix/2890-module-import-remove-unused
branch
from
August 16, 2026 09:24
6abba06 to
7bd31e1
Compare
Contributor
Author
|
@nedtwigg This was a code problem, not a test problem. The JDK 17 CI failures ( Fixed in 7bd31e1 by restoring the JVM-split defaults:
Verified locally on JBR 17 and Temurin 21 — |
…t-remove-unused # Conflicts: # CHANGES.md # plugin-gradle/CHANGES.md # plugin-maven/CHANGES.md
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.
Problem
java { removeUnusedImports() }/<removeUnusedImports/>fails on sources that use Java'simport module(JEP 511), e.g.:with:
Root cause: default google-java-format was still
1.28.0. Module-import support landed in google-java-format 1.30.0 (google/google-java-format#1213 / #1297), which skipsJCModuleImportinRemoveUnusedImportsinstead of casting every import tree toJCImport.Fixes #2890
Solution
JCAnyPattern, which only exists in JDK 21+ javac)Jvm.Support.addMin) forimport modulesupportgradle/libs.versions.tomlcompile coordinate with 1.30.0 (compile-only adapter)Users who pin an older GJF version on JVM 25 get a clear lint instead of a ClassCastException mid-format.
Testing
Platform: macOS aarch64, JBR 17.0.14 + Temurin 21.0.12 + Temurin 25.0.4
Checklist
[Unreleased]inCHANGES.md,plugin-gradle/CHANGES.md, andplugin-maven/CHANGES.md