Save the pom.xml file without removing comments or spaces

Good morning!

I was wondering if there’s a polite way to modify the version in a pom.xml file without removing the comments and spaces. I’ve noticed that when using writeMavenPom, these elements disappear, and from what I’ve read, the Maven command, mvn versions:set, also removes them. I truly appreciate any guidance you can provide on this matter. Thank you in advance for your kind attention!

Saludos: M.D.