Skip to content

Conversation

Copy link

Copilot AI commented Jan 24, 2026

ExpandWildcardImportsStep was already implemented in lib and Gradle plugin but not available in Maven plugin. The step requires a Collection<File> typeSolverClasspath containing project sources and dependencies for type resolution.

Changes

Configuration chain extended to pass MavenProject:

  • Added MavenProject field to FormatterConfig and FormatterStepConfig
  • Updated FormatterFactory and AbstractSpotlessMojo to propagate project reference

Created ExpandWildcardImports FormatterStepFactory:

  • Collects all compile and test source roots via getCompileSourceRoots() and getTestCompileSourceRoots()
  • Gathers project artifacts for dependency resolution
  • Constructs typeSolverClasspath and delegates to existing ExpandWildcardImportsStep.create()

Integration:

  • Added addExpandWildcardImports() method to Java formatter
  • Documented usage in Maven plugin README
  • Created integration test reusing existing test resources

Usage

<configuration>
  <java>
    <expandWildcardImports/>
  </java>
</configuration>

Transforms:

import java.util.*;
import foo.bar.baz.*;

Into:

import java.util.List;
import java.util.Map;
import foo.bar.baz.AnotherImportedClass;

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • archive.eclipse.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=1024m -Xmx4g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)
  • java.sun.com
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.23.9/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.23.9/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.23.9/x64/codeql/xml/tools/xml-extractor.jar --fileList=/home/REDACTED/work/spotless/.codeql-scratch/dbs/java/working/files-to-index2995331916609997450.list --sourceArchiveDir=/home/REDACTED/work/spotless/.codeql-scratch/dbs/java/src --outputDir=/home/REDACTED/work/spotless/.codeql-scratch/dbs/java/trap/java (dns block)
  • scans-in.gradle.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=1024m -Xmx4g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Fix diffplug#2829

  • ExpandWildcardImportsStep is already implemented in lib/src/main/java/com/diffplug/spotless/java/ExpandWildcardImportsStep.java and integrated with gradle plugin
  • we want to implement maven plugin integration for the same
  • the main challenge is that ExpandWildcardImportsStep needs a Collection typeSolverClasspath to pass to java parser, so we need to create that using information from maven project and pass it to the the step

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits January 24, 2026 04:00
Co-authored-by: shitikanth <544054+shitikanth@users.noreply.github.com>
Co-authored-by: shitikanth <544054+shitikanth@users.noreply.github.com>
…le directories

Co-authored-by: shitikanth <544054+shitikanth@users.noreply.github.com>
Co-authored-by: shitikanth <544054+shitikanth@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Maven plugin integration for ExpandWildcardImportsStep Add Maven plugin integration for ExpandWildcardImportsStep Jan 24, 2026
Copilot AI requested a review from shitikanth January 24, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add expandWildcardImports feature to the Maven Plugin

2 participants