This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git
The following commit(s) were added to refs/heads/master by this push: new 3cd7c36b Keep files in temporary directory to be deleted after test 3cd7c36b is described below commit 3cd7c36b82a85bb0aab9dbe1a49110aab317705c Author: Piotrek Żygieło <pzygi...@users.noreply.github.com> AuthorDate: Sat Feb 8 14:10:35 2025 +0100 Keep files in temporary directory to be deleted after test --- .../apache/maven/plugins/dependency/tree/TestTreeMojo.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java index ad096f03..b336afd2 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/tree/TestTreeMojo.java @@ -160,7 +160,7 @@ public class TestTreeMojo extends AbstractDependencyMojoTestCase { * Test the JSON format serialization on DependencyNodes with circular dependence */ public void testTreeJsonCircularDependency() throws IOException { - String outputFileName = testDir.getAbsolutePath() + "tree1.json"; + String outputFileName = testDir.getAbsolutePath() + File.separator + "tree1.json"; File outputFile = new File(outputFileName); Files.createDirectories(outputFile.getParentFile().toPath()); outputFile.createNewFile(); @@ -176,10 +176,11 @@ public class TestTreeMojo extends AbstractDependencyMojoTestCase { node1.getChildren().add(node2); node2.getChildren().add(node1); - JsonDependencyNodeVisitor jsonDependencyNodeVisitor = - new JsonDependencyNodeVisitor(new OutputStreamWriter(new FileOutputStream(outputFile))); + try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(outputFile))) { + JsonDependencyNodeVisitor jsonDependencyNodeVisitor = new JsonDependencyNodeVisitor(outputStreamWriter); - jsonDependencyNodeVisitor.visit(node1); + jsonDependencyNodeVisitor.visit(node1); + } } /* @@ -239,7 +240,7 @@ public class TestTreeMojo extends AbstractDependencyMojoTestCase { */ private List<String> runTreeMojo(String outputFile, String format) throws Exception { File testPom = new File(getBasedir(), "target/test-classes/unit/tree-test/plugin-config.xml"); - Path outputFilePath = Paths.get(testDir.getAbsolutePath() + outputFile); + Path outputFilePath = Paths.get(testDir.getAbsolutePath(), outputFile); TreeMojo mojo = (TreeMojo) lookupMojo("tree", testPom); setVariableValueToObject(mojo, "outputEncoding", "UTF-8"); setVariableValueToObject(mojo, "outputType", format);