Spaces in self-closing tags
See original GitHub issueI notice that sortpom will insert spaces in self-closing empty tags, <likeThis />
. Self-closing tags are are not common in Maven but we have a few in some plugin configurations, like <requireUpperBoundDeps />
.
While I don’t feel strongly either way about this format, it’s different than IntelliJ’s default and I was curious if this was a conscious choice. It causes some noise for us when developers use IntelliJ’s auto-format and then our build system reverts it with sortpom, potentially complaining about unexpected working tree changes. We have lots of non-pom XML files already formatted <withNoSpace/>
so I am reluctant to change the IntelliJ XML format settings.
I didn’t see a way to configure this behavior in sortpom. Would you consider adding the ability to configure this behavior to use no space instead? (Or did I miss it and it’s already supported?)
Another alternative, if you don’t want to add a new parameter, would be for sortpom to allow either one or zero spaces to remain unchanged. Then at least it wouldn’t fight with IntelliJ, even if the pom might end up with a mixed format.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
Thanks again. I’ve already updated to this version in my company’s parent pom and set the flag 😃
Thanks for the suggestion. We have bound sortpom:sort to the validate phase with createBackupFile=false, which doesn’t guarantee that the pom will always be sorted, but developers are running
mvn validate
often enough that the sorted pom gets committed pretty soon if anyone introduces some incorrect formatting. This doesn’t leave room for special cases but we haven’t found that to be a problem.I find that this mostly achieves the goal of “all our poms look the same” without causing any headaches for developers who already have to deal with picky build failures from the checkstyle and enforcer plugins.
If I decided that the poms were still not being sorted often enough, rather than push it back on the devs with a build failure, I’d probably add a step to our build system to automatically commit the sortpom changes to the side branch! How’s that for an opinionated linter 😃 “Oh I see you did it wrong, here let me change that for you, you’re welcome!”