Menu

#1802 spotlessApply reformats NetBeans GUI Builder sources and breaks their //GEN-BEGIN markers

Triage
open
nobody
None
5
2026-07-21
2026-07-21
No

The developer documentation (30.CodingStyles.md) states that sources generated by the NetBeans GUI Builder (the .java files accompanied by a .form file) must be edited with the NetBeans Form Editor, and that the guarded //GEN-BEGIN / //GEN-END regions must not be modified.

However, the spotless configuration does not exclude these files. Running spotlessApply (or spotlessChangedApply after touching such a file on a branch) reformats them with the Eclipse formatter: long lines are re-wrapped, including the marker lines such as

// <editor-fold defaultstate="collapsed" desc="Generated code">//GEN-BEGIN:initComponents

After that the Form Editor no longer recognizes the guarded regions, and the file will conflict with the next regeneration from the .form file. For example, src/main/java/org/omegat/gui/search/SearchWindowForm.java receives about 169 reformatted lines.

Steps to reproduce on current master:

git checkout -b probe master
# make any committed edit to src/main/java/org/omegat/gui/search/SearchWindowForm.java
./gradlew spotlessChangedApply --no-configuration-cache
git diff   # whole file reformatted, GEN-BEGIN marker lines re-wrapped

(--no-configuration-cache is needed because of a separate bug in the same task, reported in https://sourceforge.net/p/omegat/bugs/1801/ .)

Suggested fix: exclude .java files that have a sibling .form file from the spotless java target. A pull request will follow.

Discussion


Log in to post a comment.