spotless-maven-plugin: <toggleOffOn/> breaks <forbidWildcardImports/>
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- java
- Ambito
- build-system
Direzione di ricerca
Riproduci il problema con la configurazione minima di pom.xml e src/test/java/org/example/ImportMess.java usando mvn spotless:check, confrontando prima il comportamento con e senza . Traccia i passaggi di formattazione Java per toggleOffOn, removeUnusedImports e forbidWildcardImports; l’attività è completata quando entrambi i controlli segnalano le violazioni previste senza che uno sopprima o sostituisca l’altro.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
It seems as though adding <toggleOffOn/> somehow interferes with `
Consider the following minimal configuration:
<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<java>
<toggleOffOn/>
<removeUnusedImports/>
<forbidWildcardImports/>
</java>
</configuration>
</plugin>
</plugins>
</build>
And the following source code:
package org.example;
import java.util.*;
import java.sql.PreparedStatement;
public class ImportMess {
}
With this configuration, running mvn spotless:check will fail on the <removeUnusedInports>:
➜ demo mvn spotless:check
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::staticFieldBase has been called by com.google.inject.internal.aop.HiddenClassDefiner (file:/opt/homebrew/Cellar/maven/3.9.11/libexec/lib/guice-5.1.0-classes.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.inject.internal.aop.HiddenClassDefiner
WARNING: sun.misc.Unsafe::staticFieldBase will be removed in a future release
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.example:spotlessdemo >----------------------
[INFO] Building spotlessdemo 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- spotless:3.1.0:check (default-cli) @ spotlessdemo ---
[INFO] Index file corresponds to a different configuration of the plugin. Either the plugin version or its configuration has changed. Fallback to an empty index
[INFO] Spotless.Java is keeping 1 files clean - 1 needs changes to be clean, 0 were already clean, 0 were skipped because caching determined they were already clean
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.486 s
[INFO] Finished at: 2026-02-22T21:13:20+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:3.1.0:check (default-cli) on project spotlessdemo: The following files had format violations:
[ERROR] src/test/java/org/example/ImportMess.java
[ERROR] @@ -1,7 +1,6 @@
[ERROR] package·org.example;
[ERROR]
[ERROR] import·java.util.*;
[ERROR] -import·java.sql.PreparedStatement;
[ERROR]
[ERROR] public·class·ImportMess·{
[ERROR] }
[ERROR] Run 'mvn spotless:apply' to fix these violations.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
But if you remove <toggleOffOn/>, it will now fail on the <forbidWildcardImports/>:
➜ demo mvn spotless:check
WARNING: A terminally deprecated method in sun.misc.Unsafe has been called
WARNING: sun.misc.Unsafe::staticFieldBase has been called by com.google.inject.internal.aop.HiddenClassDefiner (file:/opt/homebrew/Cellar/maven/3.9.11/libexec/lib/guice-5.1.0-classes.jar)
WARNING: Please consider reporting this to the maintainers of class com.google.inject.internal.aop.HiddenClassDefiner
WARNING: sun.misc.Unsafe::staticFieldBase will be removed in a future release
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< org.example:spotlessdemo >----------------------
[INFO] Building spotlessdemo 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- spotless:3.1.0:check (default-cli) @ spotlessdemo ---
[INFO] Index file corresponds to a different configuration of the plugin. Either the plugin version or its configuration has changed. Fallback to an empty index
[INFO] Spotless.Java is keeping 1 files clean - 1 needs changes to be clean, 0 were already clean, 0 were skipped because caching determined they were already clean
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.398 s
[INFO] Finished at: 2026-02-22T21:14:20+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:3.1.0:check (default-cli) on project spotlessdemo: Unable to format file /Users/allon/Downloads/demo/src/test/java/org/example/ImportMess.java
[ERROR] Step 'forbidWildcardImports' found problem in 'ImportMess.java':
[ERROR] ImportMess.java:L3 forbidWildcardImports(import java.util.*;) Do not use wildcard imports (e.g. java.util.*) - replace with specific class imports (e.g. java.util.List) as 'spotlessApply' cannot auto-fix this
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Note:
The <removeUnusedImports/> isn't really important here, I added it just to demonstrate that the project structure is correct and spotless is actually picking up something from that file.
- Lingua principale
- Java
- Stelle
- 5.7k
- Fork
- 563
- Merge medio
- 1g 8h
- PR unite (30g)
- 52
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di diffplug/spotless
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
diffplug/spotless#3125 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di diffplug/spotless
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
apache/rocketmq-dashboard#5358 ·
I maintainer di solito rispondono entro 3 giorni
-
area:cpan-port area:database bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
fglock/PerlOnJava#1605 ·
I maintainer di solito rispondono entro 1 giorno
-
1.0.0-rc2
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
wso2/dpdp-accelerator#377 ·
I maintainer di solito rispondono entro 1 giorno
-
area/dependencies backport/26.4 kind/cve severity/high source/scan-dependencies status/triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 2 giorni
-
web reader
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
grimmory-tools/grimmory#2839 ·
I maintainer di solito rispondono entro 1 giorno