diff --git a/lib/updaters/types/maven.js b/lib/updaters/types/maven.js
index cc0faf6..8c2842e 100644
--- a/lib/updaters/types/maven.js
+++ b/lib/updaters/types/maven.js
@@ -12,6 +12,8 @@ function pomDocument(contents) {
parseTagValue: false,
// Don't coerce attribute values to numbers/booleans (e.g. keep port="8080" as a string)
parseAttributeValue: false,
+ // Preserve comments
+ commentPropName: "#comment",
});
return parser.parse(contents);
}
@@ -45,6 +47,8 @@ module.exports.writeVersion = function (contents, version) {
// Write fork="true" instead of shorthand fork (which is invalid in XML)
suppressBooleanAttributes: false,
format: true,
+ // Preserve comments
+ commentPropName: "#comment",
});
const xml = builder.build(document);
diff --git a/test/mocks/pom-6.3.1-attrs-lf.xml b/test/mocks/pom-6.3.1-attrs-lf.xml
index 863347b..108ea0b 100644
--- a/test/mocks/pom-6.3.1-attrs-lf.xml
+++ b/test/mocks/pom-6.3.1-attrs-lf.xml
@@ -3,6 +3,7 @@
com.mycompany.app
my-module
6.3.1
+
diff --git a/test/mocks/pom-6.4.0-attrs-lf.xml b/test/mocks/pom-6.4.0-attrs-lf.xml
index fa2b906..0253fd0 100644
--- a/test/mocks/pom-6.4.0-attrs-lf.xml
+++ b/test/mocks/pom-6.4.0-attrs-lf.xml
@@ -3,6 +3,7 @@
com.mycompany.app
my-module
6.4.0
+