Skip to content

Configuration parameter for deleting read-only files#250

Merged
desruisseaux merged 3 commits intoapache:masterfrom
Geomatys:feat/force
Jun 21, 2025
Merged

Configuration parameter for deleting read-only files#250
desruisseaux merged 3 commits intoapache:masterfrom
Geomatys:feat/force

Conversation

@desruisseaux
Copy link
Contributor

Add a force configuration option for deleting read-only files and directories. This is required because java.nio.file.Files.delete does not remove the read-only attribute, contrarily to java.io.File.delete. Note: the 3.4.0 version of the clean plugin, which was using java.io.File, may also not work anymore with read-only files starting with Java 25 if JDK-8355954 is fixed. Therefore, some action other than reverting commits is necessary.

An open question is whether the plugin should delete read-only files by default, or only if the user requested it. The latter is more conservative and is the standard behaviour of Unix commands such as rm. Furthermore, JDK-8355954 suggests that silent deletion of read-only files was an unintended bug rather than a feature.

…arameter.

* Replace <code>...</code> by {@code ...}.
* Replace </br> by <p>...</p>

Also remove the sentence in `followSymlink` saying that "Not following symlinks requires more IO operations and heap memory,
regardless whether symlinks are actually present. So projects with a huge output directory that knowingly does not contain
symlinks can improve  performance by setting this parameter to true." This implementation details may not be true anymore,
especially after migration to `FileVisitor` which handles symlinks itself.
@desruisseaux
Copy link
Contributor Author

Fix #109 and #246.

@desruisseaux desruisseaux added the enhancement New feature or request label May 3, 2025
@slawekjaranowski
Copy link
Member

Fix #109 and #246.

I'm afraid that issues will not be fixed as issues are reported for version 3.x ...

This is for 4.x

@desruisseaux
Copy link
Contributor Author

Right, #246 is filled against 3.x and indeed would be a separated PR.

Comment on lines +22 to +25
if (new File(basedir, "target").exists()) {
System.out.println("target should have been deleted.");
return false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With groovy it can be simplified as:

assert !new File(basedir, "target").exists() : 'target should have been deleted.'

@slawekjaranowski
Copy link
Member

It will be more difficult to beckport it to 3.x ...

@desruisseaux can you try it ...

@desruisseaux
Copy link
Contributor Author

I will try to port to 3.x tomorrow. It will be partially a different development because 4.0 is based on java.nio.file.FileVisitor, while 3.x has not done this migration.

@desruisseaux
Copy link
Contributor Author

Ported this pull request to the 3.x branch in #252.

…stead of considering the delete operation as a failure.

This is relevant only if some process is running in same time as `maven-clean-plugin` and that process is also deleting files.
@desruisseaux
Copy link
Contributor Author

The port of this pull request has been merged on the 3.x branch one month ago and seems to work. Therefore, I presume that we can merge on master as well.

@desruisseaux desruisseaux merged commit 1ae6f51 into apache:master Jun 21, 2025
8 checks passed
@github-actions github-actions bot added this to the 4.0.0-beta-3 milestone Jun 21, 2025
@desruisseaux desruisseaux deleted the feat/force branch June 21, 2025 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants