You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2023/01/30 11:43:26 UTC
[logging-log4j-tools] branch windows-fixes updated: Replace hardcoded newlines with the system defaults
This is an automated email from the ASF dual-hosted git repository.
vy pushed a commit to branch windows-fixes
in repository https://gitbox.apache.org/repos/asf/logging-log4j-tools.git
The following commit(s) were added to refs/heads/windows-fixes by this push:
new 60d7fdf Replace hardcoded newlines with the system defaults
60d7fdf is described below
commit 60d7fdf93b862474b348fb74a8c31474c12ceacc
Author: Volkan Yazıcı <vo...@yazi.ci>
AuthorDate: Mon Jan 30 12:44:44 2023 +0100
Replace hardcoded newlines with the system defaults
---
.../logging/log4j/changelog/util/XmlWriter.java | 45 +++++++++++-----------
.../log4j/changelog/ChangelogReleaserTest.java | 9 +----
2 files changed, 24 insertions(+), 30 deletions(-)
diff --git a/log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/util/XmlWriter.java b/log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/util/XmlWriter.java
index d3f35b7..0450310 100644
--- a/log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/util/XmlWriter.java
+++ b/log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/util/XmlWriter.java
@@ -38,6 +38,8 @@ import org.w3c.dom.Element;
public final class XmlWriter {
+ private static final String LS = System.lineSeparator();
+
private XmlWriter() {}
public static void toFile(
@@ -69,22 +71,21 @@ public final class XmlWriter {
// Append the license comment
final Document document = documentBuilder.newDocument();
document.setXmlStandalone(true);
- final Comment licenseComment = document.createComment("\n" +
- " Licensed to the Apache Software Foundation (ASF) under one or more\n" +
- " contributor license agreements. See the NOTICE file distributed with\n" +
- " this work for additional information regarding copyright ownership.\n" +
- " The ASF licenses this file to You under the Apache License, Version 2.0\n" +
- " (the \"License\"); you may not use this file except in compliance with\n" +
- " the License. You may obtain a copy of the License at\n" +
- "\n" +
- " https://www.apache.org/licenses/LICENSE-2.0\n" +
- "\n" +
- " Unless required by applicable law or agreed to in writing, software\n" +
- " distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
- " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
- " See the License for the specific language governing permissions and\n" +
- " limitations under the License." +
- "\n");
+ final Comment licenseComment = document.createComment(LS +
+ " Licensed to the Apache Software Foundation (ASF) under one or more" + LS +
+ " contributor license agreements. See the NOTICE file distributed with" + LS +
+ " this work for additional information regarding copyright ownership." + LS +
+ " The ASF licenses this file to You under the Apache License, Version 2.0" + LS +
+ " (the \"License\"); you may not use this file except in compliance with" + LS +
+ " the License. You may obtain a copy of the License at" + LS +
+ LS +
+ " https://www.apache.org/licenses/LICENSE-2.0" + LS +
+ LS +
+ " Unless required by applicable law or agreed to in writing, software" + LS +
+ " distributed under the License is distributed on an \"AS IS\" BASIS," + LS +
+ " WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied." + LS +
+ " See the License for the specific language governing permissions and" + LS +
+ " limitations under the License." + LS);
document.appendChild(licenseComment);
// Create the root element
@@ -117,13 +118,13 @@ public final class XmlWriter {
final String xml = result.getWriter().toString();
final String padding = StringUtils.repeat(" ", rootElementName.length() + 2);
return xml
- .replace("?><!--", "?>\n<!--")
- .replace("--><", "-->\n<")
+ .replace("?><!--", "?>" + LS + "<!--")
+ .replace("--><", "-->" + LS + "<")
.replaceFirst(
- '<' + rootElementName + " (.+>\n)",
- ('<' + rootElementName + " xmlns=\"" + XmlUtils.XML_NAMESPACE + "\"\n" +
- padding + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
- padding + "xsi:schemaLocation=\"" + XmlUtils.XML_NAMESPACE + " "+ XmlUtils.XML_SCHEMA_LOCATION + "\"\n" +
+ '<' + rootElementName + " (.+>" + LS + ")",
+ ('<' + rootElementName + " xmlns=\"" + XmlUtils.XML_NAMESPACE + "\"" + LS +
+ padding + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + LS +
+ padding + "xsi:schemaLocation=\"" + XmlUtils.XML_NAMESPACE + " "+ XmlUtils.XML_SCHEMA_LOCATION + "\"" + LS +
padding + "$1"));
}
diff --git a/log4j-changelog/src/test/java/org/apache/logging/log4j/changelog/ChangelogReleaserTest.java b/log4j-changelog/src/test/java/org/apache/logging/log4j/changelog/ChangelogReleaserTest.java
index 7374cc2..1aebe7b 100644
--- a/log4j-changelog/src/test/java/org/apache/logging/log4j/changelog/ChangelogReleaserTest.java
+++ b/log4j-changelog/src/test/java/org/apache/logging/log4j/changelog/ChangelogReleaserTest.java
@@ -20,7 +20,6 @@ import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
import java.time.LocalDate;
import org.apache.logging.log4j.changelog.releaser.ChangelogReleaser;
@@ -41,13 +40,7 @@ class ChangelogReleaserTest {
throws Exception {
// Clone the directory to avoid `move` operations cluttering the reference folder
- copyDirectory(
- new File("src/test/resources/3-enriched"),
- changelogDirectory.toFile(),
- null,
- true,
- // Copying attributes to avoid Windows-specific failures
- StandardCopyOption.COPY_ATTRIBUTES);
+ copyDirectory(new File("src/test/resources/3-enriched"), changelogDirectory.toFile());
// Invoke the releaser
ChangelogReleaserArgs args = new ChangelogReleaserArgs(