You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spotless-specific: package-info.java with multiple annotations loses "package" statement #910
In the attached test project, which is a barebones Gradle Wrapper setup, using the latest versions of the Spotless Gradle plugin (8.6.0), Prettier (3.8.3), and prettier-java (2.9.6), running ./gradlew spotlessApply results in src/main/java/testpackagebad/package-info.java getting incorrectly reformatted to lose its package and annotation lines.
The very similar src/main/java/testpackagegood/package-info.java file, having the following contents (two annotations instead of one), is not affected:
It's possible this is something to be reported to the Spotless project, but I'm unsure. In playing around with it, it seems to start with version 2.9.1 of prettier-java, although it bears more investigation.
This seems to be caused by this plugin attempting to produce a syntactically invalid Java output by (for some reason) moving the import statements above the package declaration as soon as there's a 2nd annotation added to the package declaration. Spotless is most likely confused by the structure of its output.
I'll look into it further. Thank you for reporting this bug!
Activity
jtkiesel commentedon May 28, 2026
This seems to be caused by this plugin attempting to produce a syntactically invalid Java output by (for some reason) moving the import statements above the package declaration as soon as there's a 2nd annotation added to the package declaration. Spotless is most likely confused by the structure of its output.
I'll look into it further. Thank you for reporting this bug!
jtkiesel commentedon May 28, 2026
@ZachCallear Thank you for using Prettier Java, and for reporting this issue! I've just published version 2.9.7 of this plugin, which contains the fix: https://www.jhipster.tech/prettier-java/playground#N4IgDgTglgdgLgdSgEzgCxALgBwAYA0IcAhgEZKoaYBMhArgM4CmAKmQ1gGbEA2zhxCBAD2AdwAKgpjA6YQvUcQCeHQnAjEoPWAHMAwsIC2h4lnk8eIQkwAeYJtEPSSPAPL2NcYRHHCGUOChhGDNpZCsQCCYARzooKPENHRMuXn4QAGNhZCYzAAEAZSMmAEEYGGESQOCARgAdGELisoqqoJhqBrBiDIBrYh0mAAI4JgY4br6BplJiZABuBoaoQzBvOCHOYWEAOiKnFsriapgaxZgVtYgNrd390vKjk+pzkABfIA
ZachCallear commentedon May 28, 2026
Thank you for your speedy fix of this and for Prettier Java!