mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-28 17:15:55 +00:00
Fix NoSuchFileException when using the compile phase, fixes #564
This commit is contained in:
@@ -17,6 +17,7 @@ package org.mvndaemon.mvnd.cache.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.nio.file.attribute.FileTime;
|
||||
@@ -57,13 +58,17 @@ public class TimestampCacheFactory implements CacheFactory {
|
||||
|
||||
FileState(Path path) {
|
||||
this.path = path;
|
||||
BasicFileAttributes attrs;
|
||||
try {
|
||||
BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
|
||||
this.lastModifiedTime = attrs.lastModifiedTime();
|
||||
this.fileKey = attrs.fileKey();
|
||||
attrs = Files.readAttributes(path, BasicFileAttributes.class);
|
||||
} catch (NoSuchFileException e) {
|
||||
// we allow this exception in case of a missing reactor artifact
|
||||
attrs = null;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.lastModifiedTime = attrs != null ? attrs.lastModifiedTime() : FileTime.fromMillis(0);
|
||||
this.fileKey = attrs != null ? attrs.fileKey() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -17,6 +17,7 @@ package org.mvndaemon.mvnd.cache.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardWatchEventKinds;
|
||||
import java.nio.file.WatchEvent;
|
||||
@@ -102,6 +103,9 @@ public class WatchServiceCacheFactory implements CacheFactory {
|
||||
new WatchEvent.Kind[] { StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY },
|
||||
mods);
|
||||
return new Registration(watchKey);
|
||||
} catch (NoSuchFileException e) {
|
||||
// we allow this exception in case of a missing reactor artifact
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
Reference in New Issue
Block a user