Move the xml document rewrite code into ci.common.
@@ -21,8 +21,6 @@ import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -41,6 +39,7 @@ import org.apache.maven.project.MavenProject;
import org.xml.sax.SAXException;
import io.openliberty.tools.common.plugins.config.ServerConfigXmlDocument;
+import io.openliberty.tools.common.plugins.config.XmlDocument;
import io.openliberty.tools.common.plugins.util.InstallFeatureUtil;
import io.openliberty.tools.common.plugins.util.PluginExecutionException;
import io.openliberty.tools.maven.BasicSupport;
@@ -277,11 +276,7 @@ public class GenerateFeaturesMojo extends InstallFeatureSupport {
try {
if (doc.createFMComment(FEATURES_FILE_MESSAGE)) {
doc.writeXMLDocument(serverXml);
- // look for "<?xml version="1.0" ... ?><server .../>" and add a newline
- byte[] contents = Files.readAllBytes(serverXml.toPath());
- String xmlContents = new String(contents, StandardCharsets.UTF_8);
- xmlContents = xmlContents.replace("?><", "?>"+System.getProperty("line.separator")+"<");
- Files.write(serverXml.toPath(), xmlContents.getBytes());
+ XmlDocument.addNewlineBeforeFirstElement(serverXml);
}
} catch (IOException | TransformerException e) {
log.debug("Exception adding comment to server.xml", e);
