Skip to content

removeUnusedImports() does not parse Markdown Javadoc #3161

Closed

Description

@SquidDev
  • Java version: 25.0.5.0.3
  • Gradle version: 9.7.1
  • Gradle plugin version: 8.11.0

When using removeUnusedImports() with the default settings, the formatter does not parse Markdown Javadoc comments, meaning classes only referenced within them will be stripped. For example, with the following config:

spotless {
  java {
    removeUnusedImports()
  }
}

This file:

import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Predicate;

/// [ArrayList#add] [Collection#removeIf(Predicate)]
class Test {}

Will be reformatted to:

/// [ArrayList#add] [Collection#removeIf(Predicate)]
class Test {}

Google's formatter uses javac to parse the classes, so this in theory should work. However, Markdown parsing is handled in a separate step — javac uses a service loader to load the class responsible for parsing/transforming markdown.

Due to Gradle's funky classloading, the service loader doesn't find the Markdown parser, and so Markdown doc comments are ignored. I'm not really sure there's a good way to fix this, short of running the formatter in a separate forked process.

Activity

  1. added a commit that references this issue on Nov 10, 2026
    600fae0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions