ebean icon indicating copy to clipboard operation
ebean copied to clipboard

add @formatter:off avoid idea format xml when generate db migration

Open spinachomes opened this issue 4 months ago • 3 comments

add -- @formatter:off in first line and add -- @formatter:on in last line when generate db migration

spinachomes avatar Sep 08 '25 05:09 spinachomes

Is this really an issue? I don't understand what the issue / problem / pain point is here or why ebean generated xml should care about this?

rbygrave avatar Nov 09 '25 04:11 rbygrave

Yes, during development using IDEA, SQL is generated and an migration is performed upon application startup. After development is complete, when committing code using Git, IDEA's reformat code feature is usually enabled. If IDEA isn't specially configured, the SQL format will change, causing errors on the next project startup.

Image

spinachomes avatar Nov 11 '25 08:11 spinachomes

We have/had the same issue

If IDEA isn't specially configured, the SQL format will change, causing errors on the next project startup.

Just configure your IDE correctly here:

Image

This is stored in .idea/codeStyles/Project.xml

IJ supports flexible glob patterns, e.g. {glob1,glob2} (I often use https://globster.xyz/ for debugging)

if you have an exclusion in your .gitignore, you can define an "exclusion of exclusion" like this:

# exclude IDEA folder
.idea/*
# exclude codeStyles folder from exclusions = include
!.idea/codeStyles/

If all of you use IJ, IMHO the codeStyles folder should be part of the repo anyway, so that everyone has the same formatting rules.

(@rbygrave BTW: this may be something, we should think about in future. I often have minor problems when contributing code to ebean, as your import * rule is configured differently and my IDE reorders the imports)

If you have a project where different people use different IDEs you

  • may not care much on formatting
  • use some maven/gradle plugins like spotless to apply a 3rd party formatter
  • use the IntelliJ CLI to apply formatting from time to time.

for the last, I've build a small (Ok, it's ~1GB) docker container (https://github.com/rPraml/intellij-formatter) that spins up IJ and apply the formatting rules (this runs in our CI pipeline)

rPraml avatar Nov 19 '25 07:11 rPraml