diff --git a/configurator/src/main/java/com/devonfw/tools/ide/configurator/merge/JsonMerger.java b/configurator/src/main/java/com/devonfw/tools/ide/configurator/merge/JsonMerger.java index 68a93c0d2..f2c06162e 100644 --- a/configurator/src/main/java/com/devonfw/tools/ide/configurator/merge/JsonMerger.java +++ b/configurator/src/main/java/com/devonfw/tools/ide/configurator/merge/JsonMerger.java @@ -29,7 +29,7 @@ import com.devonfw.tools.ide.logging.Log; /** - * TODO hohwille This type ... + * Implementation of {@link FileTypeMerger} for JSON. * * @since 3.0.0 */ @@ -125,6 +125,9 @@ private JsonValue mergeAndResolve(JsonValue json, JsonValue mergeJson, VariableR return mergeAndResolve(mergeJson, null, resolver, status); } } else { + if (mergeJson == null) { + status.updated = true; // JSON to merge does not exist and needs to be created + } switch (json.getValueType()) { case OBJECT: return mergeAndResolveObject((JsonObject) json, (JsonObject) mergeJson, resolver, status); diff --git a/configurator/src/test/java/com/devonfw/tools/ide/configurator/ConfiguratorTest.java b/configurator/src/test/java/com/devonfw/tools/ide/configurator/ConfiguratorTest.java index 7f8ddb532..136895e2c 100644 --- a/configurator/src/test/java/com/devonfw/tools/ide/configurator/ConfiguratorTest.java +++ b/configurator/src/test/java/com/devonfw/tools/ide/configurator/ConfiguratorTest.java @@ -77,6 +77,10 @@ public void testConfigurator() throws Exception { + " \"foo\": \"" + DEVON_IDE_HOME + "/foo\"\n" // + " }\n" // + "}"); + assertThat(new File(jsonFolder, "update.json")).hasContent("\n" // this newline is rather a bug of JSON-P impl + + "{\n" // + + " \"key\": \"value\"\n" // + + "}"); File configFolder = new File(workspaceDir, "config"); assertThat(configFolder).isDirectory(); diff --git a/configurator/src/test/resources/templates/update/json/update.json b/configurator/src/test/resources/templates/update/json/update.json new file mode 100644 index 000000000..d5df76e7e --- /dev/null +++ b/configurator/src/test/resources/templates/update/json/update.json @@ -0,0 +1,3 @@ +{ + "key": "value" +} \ No newline at end of file