desruisseaux commented on code in PR #362:
URL:
https://github.com/apache/maven-clean-plugin/pull/362#discussion_r4158349281
##########
src/main/java/org/apache/maven/plugins/clean/CleanMojo.java:
##########
@@ -276,7 +275,15 @@ public void execute() {
if (fast && session != null) {
Path tmpDir = fastDir;
if (tmpDir == null) {
- tmpDir =
session.getRootDirectory().resolve("target").resolve(".clean");
+ Path rootDir;
+ try {
+ rootDir = session.getRootDirectory();
+ } catch (IllegalStateException e) {
+ rootDir = null;
+ }
+ tmpDir = rootDir != null
+ ? rootDir.resolve("target").resolve(".clean")
+ :
Path.of(System.getProperty("java.io.tmpdir")).resolve(".clean");
Review Comment:
Note: with above replacement, the temporary is created (contrarily to
previous code). We must make sure that the call to `Files.move` uses the
`REPLACE_EXISTING` option. Javadoc said that it is okay if the directory is
empty.
##########
src/main/java/org/apache/maven/plugins/clean/CleanMojo.java:
##########
@@ -276,7 +275,15 @@ public void execute() {
if (fast && session != null) {
Path tmpDir = fastDir;
if (tmpDir == null) {
- tmpDir =
session.getRootDirectory().resolve("target").resolve(".clean");
+ Path rootDir;
+ try {
+ rootDir = session.getRootDirectory();
+ } catch (IllegalStateException e) {
+ rootDir = null;
+ }
+ tmpDir = rootDir != null
+ ? rootDir.resolve("target").resolve(".clean")
+ :
Path.of(System.getProperty("java.io.tmpdir")).resolve(".clean");
Review Comment:
Note: with above replacement, the temporary directory is created (contrarily
to previous code). We must make sure that the call to `Files.move` uses the
`REPLACE_EXISTING` option. Javadoc said that it is okay if the directory is
empty.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]