From 2aadbb83f9bcc63c68b786047cb91a752c7e4d8a Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Mon, 14 Sep 2020 18:20:33 +0200 Subject: [PATCH 01/13] #1237 Set next development version --- cobigen/cobigen-propertyplugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cobigen/cobigen-propertyplugin/pom.xml b/cobigen/cobigen-propertyplugin/pom.xml index ef163c65ac..bc69a07e33 100644 --- a/cobigen/cobigen-propertyplugin/pom.xml +++ b/cobigen/cobigen-propertyplugin/pom.xml @@ -2,7 +2,7 @@ 4.0.0 propertyplugin jar - 7.0.0 + 7.0.1-SNAPSHOT CobiGen - Property File Plug-In CobiGen - Property File Plug-In From d6b48f58e676f2576804321ad4debdcea890fb66 Mon Sep 17 00:00:00 2001 From: Malte Brunnlieb Date: Thu, 17 Sep 2020 10:29:19 +0200 Subject: [PATCH 02/13] test improvements + try adapting lineending handling --- .../propertyplugin/PropertyMerger.java | 53 +++++++++---------- .../propertyplugin/PropertyMergerTest.java | 21 ++++---- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java b/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java index a3c95e42b4..ebcff15cb2 100644 --- a/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java +++ b/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java @@ -26,17 +26,10 @@ */ public class PropertyMerger implements Merger { - /** Line separator, e.g. for windows '\r\n' */ - public static final String LINE_SEPARATOR = java.lang.System.getProperty("line.separator"); - - /** - * Merger Type to be registered - */ + /** Merger Type to be registered */ private String type; - /** - * The conflict resolving mode - */ + /** The conflict resolving mode */ private boolean patchOverrides; /** @@ -60,21 +53,26 @@ public String getType() { @Override public String merge(File base, String patch, String targetCharset) throws MergeException { + Properties baseProperties = new Properties(); - try { - baseProperties.load(new InputStreamReader(new FileInputStream(base), targetCharset)); + try (FileInputStream in = new FileInputStream(base); + InputStreamReader reader = new InputStreamReader(in, targetCharset)) { + baseProperties.load(reader); } catch (IOException e) { throw new MergeException(base, "Could not read base file.", e); } + Properties patchProperties = new Properties(); - try { - patchProperties.load(new ByteArrayInputStream(patch.getBytes())); + try (ByteArrayInputStream inStream = new ByteArrayInputStream(patch.getBytes())) { + patchProperties.load(inStream); } catch (IOException e) { throw new MergeException(base, "Could not read generated patch.", e); } + Set conflicts = getConflictingProperties(baseProperties, patchProperties); - try { - BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(base), targetCharset)); + try (FileInputStream in = new FileInputStream(base); + InputStreamReader reader = new InputStreamReader(in, targetCharset); + BufferedReader br = new BufferedReader(reader)) { return concatContents(conflicts, br, patch); } catch (IOException e) { throw new MergeException(base, "Could not read base file.", e); @@ -109,10 +107,10 @@ private String concatContents(Set conflicts, BufferedReader baseFileRead line = line.trim(); // adding key of the respective value to the collection if (line.startsWith("#")) { - collection.put("recordedComments" + count, LINE_SEPARATOR + line); + collection.put("recordedComments" + count, "\r" + line); if (lastLineWasComment) { String lastComment = recordedComments.remove(recordedComments.size() - 1); - recordedComments.add(lastComment + LINE_SEPARATOR + line); + recordedComments.add(lastComment + "\r" + line); } else { lastLineWasComment = true; recordedComments.add(line); @@ -120,39 +118,38 @@ private String concatContents(Set conflicts, BufferedReader baseFileRead } else { lastLineWasComment = false; if (!line.trim().isEmpty()) { - collection.put(line.substring(0, line.indexOf("=")), LINE_SEPARATOR + line); + collection.put(line.substring(0, line.indexOf("=")), "\r" + line); } } count++; } - baseFileReader.close(); Pattern p = Pattern.compile("([^=\\s]+)\\s*=.*"); Matcher m; String lastObservedComment = null; int observedEmptyLines = 0; count = 0; - for (String patchLine : patch.split(LINE_SEPARATOR)) { + for (String patchLine : patch.split("\\r(\\n)?")) { m = p.matcher(patchLine); if (m.matches()) { // no conflicts if (!conflicts.contains(m.group(1))) { - collection.put(m.group(1), LINE_SEPARATOR + patchLine); + collection.put(m.group(1), "\r" + patchLine); observedEmptyLines = 0; } else { if (patchOverrides) { // override the original by patch file // patchLine; - collection.put(m.group(1), LINE_SEPARATOR + patchLine); + collection.put(m.group(1), "\r" + patchLine); observedEmptyLines = 0; } } } else if (patchLine.startsWith("#")) { // record comment over multiple lines if (lastObservedComment != null) { - lastObservedComment += LINE_SEPARATOR + patchLine; - collection.put("lastObservedComment" + count, LINE_SEPARATOR + lastObservedComment); + lastObservedComment += "\r" + patchLine; + collection.put("lastObservedComment" + count, "\r" + lastObservedComment); } else { lastObservedComment = patchLine; - collection.put("lastObservedComment" + count, LINE_SEPARATOR + lastObservedComment); + collection.put("lastObservedComment" + count, "\r" + lastObservedComment); } } else { if (lastObservedComment == null && patchLine.trim().isEmpty()) { @@ -162,16 +159,16 @@ private String concatContents(Set conflicts, BufferedReader baseFileRead // comment if not so if (lastObservedComment != null && !recordedComments.contains(lastObservedComment)) { for (int i = 0; i < observedEmptyLines; i++) { - collection.put("_blank" + count, LINE_SEPARATOR); + collection.put("_blank" + count, "\r"); } - collection.put("lastObservedComment" + count, LINE_SEPARATOR + lastObservedComment); + collection.put("lastObservedComment" + count, "\r" + lastObservedComment); } lastObservedComment = null; observedEmptyLines = 0; if (!patchLine.trim().isEmpty()) { // patchLine; - collection.put("patchLineNotEmpty" + count, LINE_SEPARATOR + patchLine); + collection.put("patchLineNotEmpty" + count, "\r" + patchLine); observedEmptyLines = 0; } } diff --git a/cobigen/cobigen-propertyplugin/src/test/java/com/devonfw/cobigen/propertyplugin/PropertyMergerTest.java b/cobigen/cobigen-propertyplugin/src/test/java/com/devonfw/cobigen/propertyplugin/PropertyMergerTest.java index 7b19ee8482..d332586c41 100644 --- a/cobigen/cobigen-propertyplugin/src/test/java/com/devonfw/cobigen/propertyplugin/PropertyMergerTest.java +++ b/cobigen/cobigen-propertyplugin/src/test/java/com/devonfw/cobigen/propertyplugin/PropertyMergerTest.java @@ -1,14 +1,13 @@ package com.devonfw.cobigen.propertyplugin; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import java.io.FileReader; import org.apache.commons.io.IOUtils; -import org.junit.Assert; import org.junit.Test; -import com.devonfw.cobigen.propertyplugin.PropertyMerger; - import junit.framework.TestCase; /** @@ -32,10 +31,10 @@ public void testPropertyMergeOverride() throws Exception { PropertyMerger pMerger = new PropertyMerger("", true); String mergedPropFile = pMerger.merge(base, IOUtils.toString(new FileReader(new File(testFileRootPath + "Name.ftl"))), "UTF-8"); - Assert.assertTrue("NachNameOverride", mergedPropFile.contains("NachNameOverride")); - Assert.assertFalse("nachNameOriginal", mergedPropFile.contains("nachNameOriginal")); - Assert.assertTrue("FirstName", mergedPropFile.contains("firstName")); - Assert.assertTrue("lastName", mergedPropFile.contains("lastName")); + assertThat(mergedPropFile).contains("NachNameOverride"); + assertThat(mergedPropFile).doesNotContain("nachNameOriginal"); + assertThat(mergedPropFile).contains("firstName"); + assertThat(mergedPropFile).contains("lastName"); } /** @@ -49,10 +48,10 @@ public void testPropertyMergeWithoutOverride() throws Exception { PropertyMerger pMerger = new PropertyMerger("", false); String mergedPropFile = pMerger.merge(base, IOUtils.toString(new FileReader(new File(testFileRootPath + "Name.ftl"))), "UTF-8"); - Assert.assertFalse("NachNameOverride", mergedPropFile.contains("NachNameOverride")); - Assert.assertTrue("nachNameOriginal", mergedPropFile.contains("nachNameOriginal")); - Assert.assertTrue("FirstName", mergedPropFile.contains("firstName")); - Assert.assertTrue("lastName", mergedPropFile.contains("lastName")); + assertThat(mergedPropFile).doesNotContain("NachNameOverride"); + assertThat(mergedPropFile).contains("nachNameOriginal"); + assertThat(mergedPropFile).contains("firstName"); + assertThat(mergedPropFile).contains("lastName"); } } From 478e39f700d5955d07d5c74d4dd9c82d12b81d26 Mon Sep 17 00:00:00 2001 From: Lars Reinken Date: Thu, 24 Sep 2020 08:28:14 +0200 Subject: [PATCH 03/13] #1245 use the api function to determine the line ending of the file --- cobigen/cobigen-propertyplugin/pom.xml | 4 +- .../propertyplugin/PropertyMerger.java | 62 ++++++++++--------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/cobigen/cobigen-propertyplugin/pom.xml b/cobigen/cobigen-propertyplugin/pom.xml index bc69a07e33..d296f795cb 100644 --- a/cobigen/cobigen-propertyplugin/pom.xml +++ b/cobigen/cobigen-propertyplugin/pom.xml @@ -20,14 +20,14 @@ com.devonfw.cobigen core-api - [7.0.0,) + 7.1.0-Snapshot com.devonfw.cobigen core-test - [7.0.0,) + 7.1.0-Snapshot test diff --git a/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java b/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java index ebcff15cb2..3281f00c2c 100644 --- a/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java +++ b/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java @@ -1,5 +1,6 @@ package com.devonfw.cobigen.propertyplugin; +import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; @@ -17,6 +18,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import com.devonfw.cobigen.api.util.SystemUtil; import com.devonfw.cobigen.api.exception.MergeException; import com.devonfw.cobigen.api.extension.Merger; @@ -26,10 +28,15 @@ */ public class PropertyMerger implements Merger { - /** Merger Type to be registered */ + + /** + * Merger Type to be registered + */ private String type; - /** The conflict resolving mode */ + /** + * The conflict resolving mode + */ private boolean patchOverrides; /** @@ -53,27 +60,25 @@ public String getType() { @Override public String merge(File base, String patch, String targetCharset) throws MergeException { - Properties baseProperties = new Properties(); - try (FileInputStream in = new FileInputStream(base); - InputStreamReader reader = new InputStreamReader(in, targetCharset)) { - baseProperties.load(reader); + try { + baseProperties.load(new InputStreamReader(new FileInputStream(base), targetCharset)); } catch (IOException e) { throw new MergeException(base, "Could not read base file.", e); } - Properties patchProperties = new Properties(); - try (ByteArrayInputStream inStream = new ByteArrayInputStream(patch.getBytes())) { - patchProperties.load(inStream); + try { + patchProperties.load(new ByteArrayInputStream(patch.getBytes())); } catch (IOException e) { throw new MergeException(base, "Could not read generated patch.", e); } - Set conflicts = getConflictingProperties(baseProperties, patchProperties); - try (FileInputStream in = new FileInputStream(base); - InputStreamReader reader = new InputStreamReader(in, targetCharset); - BufferedReader br = new BufferedReader(reader)) { - return concatContents(conflicts, br, patch); + try (FileInputStream stream = new FileInputStream(base); + BufferedInputStream bis = new BufferedInputStream(stream); + InputStreamReader reader = new InputStreamReader(bis, targetCharset)){ + BufferedReader br = new BufferedReader(reader); + String lineDelimiter = SystemUtil.determineLineDelimiter(bis, reader); + return concatContents(conflicts, br, patch, lineDelimiter); } catch (IOException e) { throw new MergeException(base, "Could not read base file.", e); } @@ -94,9 +99,9 @@ public String merge(File base, String patch, String targetCharset) throws MergeE * if the base file could not be read oder accessed * @author mbrunnli (11.03.2013) */ - private String concatContents(Set conflicts, BufferedReader baseFileReader, String patch) + private String concatContents(Set conflicts, BufferedReader baseFileReader, String patch, String lineSeparator) throws IOException { - + List recordedComments = new LinkedList<>(); Map collection = new HashMap<>(); String line; @@ -107,10 +112,10 @@ private String concatContents(Set conflicts, BufferedReader baseFileRead line = line.trim(); // adding key of the respective value to the collection if (line.startsWith("#")) { - collection.put("recordedComments" + count, "\r" + line); + collection.put("recordedComments" + count, lineSeparator + line); if (lastLineWasComment) { String lastComment = recordedComments.remove(recordedComments.size() - 1); - recordedComments.add(lastComment + "\r" + line); + recordedComments.add(lastComment + lineSeparator + line); } else { lastLineWasComment = true; recordedComments.add(line); @@ -118,38 +123,39 @@ private String concatContents(Set conflicts, BufferedReader baseFileRead } else { lastLineWasComment = false; if (!line.trim().isEmpty()) { - collection.put(line.substring(0, line.indexOf("=")), "\r" + line); + collection.put(line.substring(0, line.indexOf("=")), lineSeparator + line); } } count++; } + baseFileReader.close(); Pattern p = Pattern.compile("([^=\\s]+)\\s*=.*"); Matcher m; String lastObservedComment = null; int observedEmptyLines = 0; count = 0; - for (String patchLine : patch.split("\\r(\\n)?")) { + for (String patchLine : patch.split(lineSeparator)) { m = p.matcher(patchLine); if (m.matches()) { // no conflicts if (!conflicts.contains(m.group(1))) { - collection.put(m.group(1), "\r" + patchLine); + collection.put(m.group(1), lineSeparator + patchLine); observedEmptyLines = 0; } else { if (patchOverrides) { // override the original by patch file // patchLine; - collection.put(m.group(1), "\r" + patchLine); + collection.put(m.group(1), lineSeparator + patchLine); observedEmptyLines = 0; } } } else if (patchLine.startsWith("#")) { // record comment over multiple lines if (lastObservedComment != null) { - lastObservedComment += "\r" + patchLine; - collection.put("lastObservedComment" + count, "\r" + lastObservedComment); + lastObservedComment += lineSeparator + patchLine; + collection.put("lastObservedComment" + count, lineSeparator + lastObservedComment); } else { lastObservedComment = patchLine; - collection.put("lastObservedComment" + count, "\r" + lastObservedComment); + collection.put("lastObservedComment" + count, lineSeparator + lastObservedComment); } } else { if (lastObservedComment == null && patchLine.trim().isEmpty()) { @@ -159,16 +165,16 @@ private String concatContents(Set conflicts, BufferedReader baseFileRead // comment if not so if (lastObservedComment != null && !recordedComments.contains(lastObservedComment)) { for (int i = 0; i < observedEmptyLines; i++) { - collection.put("_blank" + count, "\r"); + collection.put("_blank" + count, lineSeparator); } - collection.put("lastObservedComment" + count, "\r" + lastObservedComment); + collection.put("lastObservedComment" + count, lineSeparator + lastObservedComment); } lastObservedComment = null; observedEmptyLines = 0; if (!patchLine.trim().isEmpty()) { // patchLine; - collection.put("patchLineNotEmpty" + count, "\r" + patchLine); + collection.put("patchLineNotEmpty" + count, lineSeparator + patchLine); observedEmptyLines = 0; } } From fa19cb7150cb0ef5f3587d891ee552a5a932f59e Mon Sep 17 00:00:00 2001 From: Lars Reinken Date: Thu, 24 Sep 2020 08:59:25 +0200 Subject: [PATCH 04/13] #1246 make sure to keep the order of lines --- .../com/devonfw/cobigen/propertyplugin/PropertyMerger.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java b/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java index 3281f00c2c..7bf140d279 100644 --- a/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java +++ b/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java @@ -10,6 +10,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -103,7 +104,7 @@ private String concatContents(Set conflicts, BufferedReader baseFileRead throws IOException { List recordedComments = new LinkedList<>(); - Map collection = new HashMap<>(); + Map collection = new LinkedHashMap<>(); String line; boolean lastLineWasComment = false; int count = 0; // count is used below to maintain uniqueness in the hash From 442e12ff73be50a960bafef90e13bf30f5e48455 Mon Sep 17 00:00:00 2001 From: Lars Reinken Date: Thu, 24 Sep 2020 12:25:14 +0200 Subject: [PATCH 05/13] remove unused import --- .../com/devonfw/cobigen/propertyplugin/PropertyMerger.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java b/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java index 7bf140d279..8b8509a785 100644 --- a/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java +++ b/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java @@ -8,7 +8,6 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedList; @@ -19,9 +18,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.devonfw.cobigen.api.util.SystemUtil; import com.devonfw.cobigen.api.exception.MergeException; import com.devonfw.cobigen.api.extension.Merger; +import com.devonfw.cobigen.api.util.SystemUtil; /** * The {@link PropertyMerger} merges two property files. One being provided as the base file and the second From 6c6aff6e7ba14c12a361aba2f2cb797e26971681 Mon Sep 17 00:00:00 2001 From: Lars Reinken Date: Thu, 24 Sep 2020 12:34:57 +0200 Subject: [PATCH 06/13] adapt dependecy --- cobigen/cobigen-propertyplugin/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cobigen/cobigen-propertyplugin/pom.xml b/cobigen/cobigen-propertyplugin/pom.xml index d296f795cb..bc69a07e33 100644 --- a/cobigen/cobigen-propertyplugin/pom.xml +++ b/cobigen/cobigen-propertyplugin/pom.xml @@ -20,14 +20,14 @@ com.devonfw.cobigen core-api - 7.1.0-Snapshot + [7.0.0,) com.devonfw.cobigen core-test - 7.1.0-Snapshot + [7.0.0,) test From ee07e99f3438f48a5ee572d16f1bd6163ac35540 Mon Sep 17 00:00:00 2001 From: Lars Reinken Date: Thu, 1 Oct 2020 08:32:28 +0200 Subject: [PATCH 07/13] update travis.yml to run the tests on windows, too --- .travis.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 674b09ef28..2c5e5fa363 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ dist: bionic +os: linux language: java cache: directories: @@ -33,6 +34,23 @@ jobs: script: ./scripts/travis-build-test.sh if: (branch != gh-pages) AND (branch != dev_oomph_setup) AND (tag IS blank) jdk: openjdk11 + - name: Build & Test (openjdk11Windows) + language: bash + os: windows + cache: + directories: + - /c/ProgramData/chocolatey/lib/maven/apache-maven-3.6.3 + before_install: + - choco install openjdk11 --version 11.0.8.10 -y + - choco install maven --version 3.6.3 -y + - powershell refreshenv + - export PATH=${PATH}:"/c/ProgramData/chocolatey/lib/maven/apache-maven-3.6.3/bin" + - export PATH=${PATH}:"/c/Program Files/OpenJDK/openjdk-11.0.8_10/bin" + - export JAVA_HOME="/c/Program Files/OpenJDK/openjdk-11.0.8_10/" + install: [] + script: + - ./scripts/travis-build-test.sh + if: (branch != gh-pages) AND (branch != dev_oomph_setup) AND (tag IS blank) - name: Build docs as PDF install: [] script: ./scripts/travis-build-docs.sh @@ -53,4 +71,4 @@ jobs: install: [] script: ./scripts/travis-sync-docs.sh if: (branch = master) AND (type != pull_request) AND (fork = false) AND (tag IS blank) - jdk: openjdk11 + jdk: openjdk11 \ No newline at end of file From 761fa387df73f8b6cb5352b0d228d8ee463f0351 Mon Sep 17 00:00:00 2001 From: Lars Reinken Date: Thu, 1 Oct 2020 08:55:26 +0200 Subject: [PATCH 08/13] add openJDK to cache --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2c5e5fa363..382fa489ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,6 +40,7 @@ jobs: cache: directories: - /c/ProgramData/chocolatey/lib/maven/apache-maven-3.6.3 + - /c/Program Files/OpenJDK/openjdk-11.0.8_10 before_install: - choco install openjdk11 --version 11.0.8.10 -y - choco install maven --version 3.6.3 -y From d58b0766f532860b603a3448b5215fbc1e6041c7 Mon Sep 17 00:00:00 2001 From: LarsReinken Date: Tue, 17 Nov 2020 00:40:23 +0100 Subject: [PATCH 09/13] adapt PropertyMerger to changed API function --- .../cobigen/propertyplugin/PropertyMerger.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java b/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java index 8b8509a785..e0e962b4a1 100644 --- a/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java +++ b/cobigen/cobigen-propertyplugin/src/main/java/com/devonfw/cobigen/propertyplugin/PropertyMerger.java @@ -1,6 +1,5 @@ package com.devonfw.cobigen.propertyplugin; -import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; @@ -28,7 +27,6 @@ */ public class PropertyMerger implements Merger { - /** * Merger Type to be registered */ @@ -73,11 +71,10 @@ public String merge(File base, String patch, String targetCharset) throws MergeE throw new MergeException(base, "Could not read generated patch.", e); } Set conflicts = getConflictingProperties(baseProperties, patchProperties); - try (FileInputStream stream = new FileInputStream(base); - BufferedInputStream bis = new BufferedInputStream(stream); - InputStreamReader reader = new InputStreamReader(bis, targetCharset)){ + try (FileInputStream in = new FileInputStream(base); + InputStreamReader reader = new InputStreamReader(in, targetCharset)) { BufferedReader br = new BufferedReader(reader); - String lineDelimiter = SystemUtil.determineLineDelimiter(bis, reader); + String lineDelimiter = SystemUtil.determineLineDelimiter(base.toPath(), targetCharset); return concatContents(conflicts, br, patch, lineDelimiter); } catch (IOException e) { throw new MergeException(base, "Could not read base file.", e); @@ -94,14 +91,16 @@ public String merge(File base, String patch, String targetCharset) throws MergeE * {@link BufferedReader} reading the base file * @param patch * which should be applied + * @param lineSeparator + * the line Separator to use for the file * @return merged file contents * @throws IOException * if the base file could not be read oder accessed * @author mbrunnli (11.03.2013) */ - private String concatContents(Set conflicts, BufferedReader baseFileReader, String patch, String lineSeparator) - throws IOException { - + private String concatContents(Set conflicts, BufferedReader baseFileReader, String patch, + String lineSeparator) throws IOException { + List recordedComments = new LinkedList<>(); Map collection = new LinkedHashMap<>(); String line; From 38f48458f0e0f2d2a1cdbf17bd34065601daa9fd Mon Sep 17 00:00:00 2001 From: MikeSchumacher Date: Thu, 3 Dec 2020 15:57:16 +0100 Subject: [PATCH 10/13] dummy commit to start travis build --- .../com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cobigen-templates/templates-devon4j/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java b/cobigen-templates/templates-devon4j/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java index 0693d80d78..d3339b6d0f 100644 --- a/cobigen-templates/templates-devon4j/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java +++ b/cobigen-templates/templates-devon4j/src/main/java/com/devonfw/cobigen/templates/devon4j/utils/JavaUtil.java @@ -30,7 +30,7 @@ public JavaUtil() { /** * Returns the Object version of a Java primitive or the input if the input isn't a java primitive - * + * * @param simpleType * String * @return the corresponding object wrapper type simple name of the input if the input is the name of a From 9bcd6ad3bc84b4bd5906f69d9fc49342c877574c Mon Sep 17 00:00:00 2001 From: MikeSchumacher Date: Fri, 4 Dec 2020 15:29:53 +0100 Subject: [PATCH 11/13] #1289 set release snapshot version --- cobigen/cobigen-propertyplugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cobigen/cobigen-propertyplugin/pom.xml b/cobigen/cobigen-propertyplugin/pom.xml index bc69a07e33..be6b3427e2 100644 --- a/cobigen/cobigen-propertyplugin/pom.xml +++ b/cobigen/cobigen-propertyplugin/pom.xml @@ -2,7 +2,7 @@ 4.0.0 propertyplugin jar - 7.0.1-SNAPSHOT + 7.1.0-SNAPSHOT CobiGen - Property File Plug-In CobiGen - Property File Plug-In From 45a2c3098273394d554ff6d699d9f1854af2eefe Mon Sep 17 00:00:00 2001 From: MikeSchumacher Date: Fri, 4 Dec 2020 15:30:36 +0100 Subject: [PATCH 12/13] #1289 update wiki docs --- documentation/master-cobigen.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/master-cobigen.asciidoc b/documentation/master-cobigen.asciidoc index 8ef5dc8cad..5b81436ea3 100644 --- a/documentation/master-cobigen.asciidoc +++ b/documentation/master-cobigen.asciidoc @@ -21,7 +21,7 @@ DISCLAIMER: All Cobigen plugins are compatible with the latest release of Devonf * CobiGen - Java Plug-in v2.2.3 * CobiGen - XML Plug-in v4.2.0 * CobiGen - TypeScript Plug-in v2.4.4 -* CobiGen - Property Plug-in v7.0.0 +* CobiGen - Property Plug-in v7.1.0 * CobiGen - Text Merger v2.1.0 * CobiGen - JSON Plug-in v2.1.0 * CobiGen - HTML Plug-in v2.1.0 From 59105cc2a98b359ed67754df884098df69c5033d Mon Sep 17 00:00:00 2001 From: MikeSchumacher Date: Fri, 4 Dec 2020 15:30:39 +0100 Subject: [PATCH 13/13] #1289 Set release version --- cobigen/cobigen-propertyplugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cobigen/cobigen-propertyplugin/pom.xml b/cobigen/cobigen-propertyplugin/pom.xml index be6b3427e2..611eec3b69 100644 --- a/cobigen/cobigen-propertyplugin/pom.xml +++ b/cobigen/cobigen-propertyplugin/pom.xml @@ -2,7 +2,7 @@ 4.0.0 propertyplugin jar - 7.1.0-SNAPSHOT + 7.1.0 CobiGen - Property File Plug-In CobiGen - Property File Plug-In