[
https://issues.apache.org/jira/browse/MCLEAN-124?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17896438#comment-17896438
]
ASF GitHub Bot commented on MCLEAN-124:
---------------------------------------
elharo commented on code in PR #60:
URL: https://github.com/apache/maven-clean-plugin/pull/60#discussion_r1833170592
##########
src/test/java/org/apache/maven/plugins/clean/CleanerTest.java:
##########
@@ -45,36 +42,22 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
class CleanerTest {
- private boolean warnEnabled;
-
- /**
- * Use a {@code LinkedHashMap} to preserve the order of the logged
warnings.
- */
- private final Map<CharSequence, Throwable> warnings = new
LinkedHashMap<>();
-
- /**
- * Ideally we should use a mocking framework such as Mockito for this, but
alas, this project has no such dependency.
- */
- private final Log log = new SilentLog() {
-
- @Override
- public boolean isWarnEnabled() {
- return warnEnabled;
- }
-
- @Override
- public void warn(CharSequence content, Throwable error) {
- warnings.put(content, error);
- }
- };
+ private final Log log = mock();
@Test
void deleteSucceedsDeeply(@TempDir Path tempDir) throws Exception {
- final Path basedir = createDirectory(tempDir.resolve("target"));
+ final Path basedir =
createDirectory(tempDir.resolve("target")).toRealPath();
Review Comment:
might want to do this in a separate pr first
##########
src/main/java/org/apache/maven/plugins/clean/Cleaner.java:
##########
@@ -273,7 +273,8 @@ private boolean isSymbolicLink(Path path) throws
IOException {
* @throws IOException If a file/directory could not be deleted and
<code>failOnError</code> is <code>true</code>.
*/
private int delete(File file, boolean failOnError, boolean retryOnError)
throws IOException {
- if (!file.delete()) {
+ IOException error = delete(file);
Review Comment:
this is not a Java error; please rename the variable
> Provide more accurate reason when can not delete a resource
> -----------------------------------------------------------
>
> Key: MCLEAN-124
> URL: https://issues.apache.org/jira/browse/MCLEAN-124
> Project: Maven Clean Plugin
> Issue Type: Improvement
> Reporter: Slawomir Jaranowski
> Priority: Major
>
> Currently we have only in stack trace something like:
> {noformat}
> Caused by: java.io.IOException: Failed to delete
> /Users/runner/work/maven-surefire/maven-surefire/surefire-its/target
> at org.apache.maven.plugins.clean.Cleaner.delete (Cleaner.java:300)
> at org.apache.maven.plugins.clean.Cleaner.delete (Cleaner.java:250)
> at org.apache.maven.plugins.clean.Cleaner.delete (Cleaner.java:124)
> {noformat}
> It will be usable if we have reported a reason ... why can not be deleted
--
This message was sent by Atlassian Jira
(v8.20.10#820010)