olamy commented on code in PR #181:
URL: 
https://github.com/apache/maven-compiler-plugin/pull/181#discussion_r1404865372


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -1577,31 +1589,35 @@ protected boolean isDependencyChanged() {
     }
 
     /**
-     * @param classPathEntry entry to check
+     * @param file entry to check
      * @param buildStartTime time build start
      * @return if any changes occurred
      */
-    private boolean hasNewFile(File classPathEntry, Date buildStartTime) {
-        if (!classPathEntry.exists()) {
-            return false;
-        }
-
-        if (classPathEntry.isFile()) {
-            return classPathEntry.lastModified() >= buildStartTime.getTime()
-                    && 
fileExtensions.contains(FileUtils.getExtension(classPathEntry.getName()));
-        }
-
-        File[] children = classPathEntry.listFiles();
-
-        for (File child : children) {
-            if (hasNewFile(child, buildStartTime)) {
-                return true;
+    private boolean hasNewFile(Path file, Instant buildStartTime) {
+        if (Files.isRegularFile(file) && 
fileExtensions.contains(getFileExtension(file))) {
+            try {
+                Instant lastModifiedTime =
+                        
Files.getLastModifiedTime(file).toInstant().truncatedTo(ChronoUnit.MILLIS);
+                boolean isChanged = lastModifiedTime.isAfter(buildStartTime);
+                if (isChanged && (getLog().isDebugEnabled() || 
showCompilationChanges)) {
+                    getLog().info("\tNew dependency detected: " + 
file.toAbsolutePath());
+                }
+                return isChanged;
+            } catch (IOException ex) {
+                // we just cannot determine it, so don't do anything beside 
logging
+                getLog().warn("I/O error reading the lastModifiedTime: " + 
ex.getMessage());
             }
         }
 
         return false;
     }
 
+    private static String getFileExtension(Path path) {

Review Comment:
   Don't we have already some plexus utils for that? Or the dependency have 
been removed?



-- 
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: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to