GeezerVison is showing github.com — spotless maven eclipse jdt - How to block import star (*) wildcard? · Issue #832 · diffplug/spotless
spotless maven eclipse jdt - How to block import star (*) wildcard? #832
Description
Hi!
Spotless is really cool project!
I am using maven plugin with eclipse jdt.
Is there a way to block import package.*; please?
I think there is no way (currently) to remove package.* and put the correct imports, but I would like to at least it to give an error, so the developer can fix it.
Thank you!! :)
Activity
smoothreggae commented on Apr 6, 2021
Reacted by Ned Twigg and tivrfoa
nedtwigg commented on Apr 6, 2021
tivrfoa commented on Apr 6, 2021
This sounds similar to #649. One of the comments has something you could try as an alternative.
UPDATE! It worked. Sorry the noise!
The correct location is in fact inside <java>
disregard the text below
Thank you!
Where should the code below be placed in pom.xml please?
<replaceRegex>
<name>Remove wildcard imports</name>
<searchRegex>import\s+[^\*\s]+\*;(\r\n|\r|\n)</searchRegex>
<replacement>$1</replacement>
</replaceRegex>
I placed inside <java></java>, but mvn spotless:check didn't spot it :]
I'm using spotless version 2.4.1
<java>
<importOrder>
<order>br,com,java,javax,org,</order>
</importOrder>
<removeUnusedImports />
<replaceRegex>
<name>Remove wildcard imports</name>
<searchRegex>import\s+[^\*\s]+\*;(\r\n|\r|\n)</searchRegex>
<replacement>$1</replacement>
</replaceRegex>
<eclipse>
<version>4.13.0</version>
<file>${basedir}/eclipse-formatter.xml</file>
</eclipse>
</java>tivrfoa commented on Apr 6, 2021
I updated the text. It worked! Thanks again!
nedtwigg commented on Jul 7, 2025
Released in plugin-gradle 7.1.0 and plugin-maven 2.45.0.
Metadata
Metadata
Development
No branches or pull requestsIssue actions