From 54c12682954e95bbe9a496efe11fd7fa0e311051 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Wed, 4 Dec 2024 07:51:13 -0500 Subject: [PATCH] outputFile --- .../projects/mdep-839-list/invoker.properties | 2 +- src/it/projects/mdep-839-list/test.properties | 19 +++++++++++++++++++ src/it/projects/mdep-839-list/verify.groovy | 4 ++-- .../dependency/utils/DependencyUtil.java | 4 +++- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 src/it/projects/mdep-839-list/test.properties diff --git a/src/it/projects/mdep-839-list/invoker.properties b/src/it/projects/mdep-839-list/invoker.properties index 3e781b202..55afe77c1 100644 --- a/src/it/projects/mdep-839-list/invoker.properties +++ b/src/it/projects/mdep-839-list/invoker.properties @@ -15,4 +15,4 @@ # specific language governing permissions and limitations # under the License. -invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:list --Doutput-file="/tmp/temp.txt" +invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:list diff --git a/src/it/projects/mdep-839-list/test.properties b/src/it/projects/mdep-839-list/test.properties new file mode 100644 index 000000000..406dd9aba --- /dev/null +++ b/src/it/projects/mdep-839-list/test.properties @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +outputFile = classpath.txt + diff --git a/src/it/projects/mdep-839-list/verify.groovy b/src/it/projects/mdep-839-list/verify.groovy index fe45f1b01..f20821cec 100644 --- a/src/it/projects/mdep-839-list/verify.groovy +++ b/src/it/projects/mdep-839-list/verify.groovy @@ -17,8 +17,8 @@ * under the License. */ -File file = new File( basedir, "/tmp/temp.txt" ) -assert file.exists() +File file = new File( basedir, "classpath.txt" ) +assert file.exists() : "output file $file does not exist" String output = file.getText( "UTF-8" ) assert output.contains( 'The following files have been resolved:') diff --git a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java index 5ec05ccd6..bca7279de 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java +++ b/src/main/java/org/apache/maven/plugins/dependency/utils/DependencyUtil.java @@ -26,6 +26,7 @@ import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.OpenOption; +import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.Objects; @@ -229,7 +230,8 @@ public static synchronized void write(String string, File file, boolean append, */ public static synchronized void write(String string, File file, boolean append, String encoding) throws IOException { - Files.createDirectories(file.getParentFile().toPath()); + Path parent = Files.createDirectories(file.getParentFile().toPath()); + System.err.println(parent.toAbsolutePath()); OpenOption appendOption = append ? StandardOpenOption.APPEND : StandardOpenOption.TRUNCATE_EXISTING;