[MNG-4660] Increase usefulness of logging

Closes #416
diff --git a/maven-core/src/main/java/org/apache/maven/ReactorReader.java b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
index 7799667..42c41ac 100644
--- a/maven-core/src/main/java/org/apache/maven/ReactorReader.java
+++ b/maven-core/src/main/java/org/apache/maven/ReactorReader.java
@@ -178,7 +178,7 @@
         }
         // Check whether an earlier Maven run might have produced an artifact that is still on disk.
         else if ( packagedArtifactFile != null && packagedArtifactFile.exists()
-                && isPackagedArtifactUpToDate( project, packagedArtifactFile ) )
+                && isPackagedArtifactUpToDate( project, packagedArtifactFile, artifact ) )
         {
             return packagedArtifactFile;
         }
@@ -186,33 +186,41 @@
         {
             // fallback to loose class files only if artifacts haven't been packaged yet
             // and only for plain old jars. Not war files, not ear files, not anything else.
+            return determineBuildOutputDirectoryForArtifact( project, artifact );
+        }
 
-            if ( isTestArtifact( artifact ) )
+        // The fall-through indicates that the artifact cannot be found;
+        // for instance if package produced nothing or classifier problems.
+        return null;
+    }
+
+    private File determineBuildOutputDirectoryForArtifact( final MavenProject project, final Artifact artifact )
+    {
+        if ( isTestArtifact( artifact ) )
+        {
+            if ( project.hasLifecyclePhase( "test-compile" ) )
             {
-                if ( project.hasLifecyclePhase( "test-compile" ) )
-                {
-                    return new File( project.getBuild().getTestOutputDirectory() );
-                }
+                return new File( project.getBuild().getTestOutputDirectory() );
             }
-            else
+        }
+        else
+        {
+            String type = artifact.getProperty( "type", "" );
+            File outputDirectory = new File( project.getBuild().getOutputDirectory() );
+
+            // Check if the project is being built during this session, and if we can expect any output.
+            // There is no need to check if the build has created any outputs, see MNG-2222.
+            boolean projectCompiledDuringThisSession
+                    = project.hasLifecyclePhase( "compile" ) && COMPILE_PHASE_TYPES.contains( type );
+
+            // Check if the project is part of the session (not filtered by -pl, -rf, etc). If so, we check
+            // if a possible earlier Maven invocation produced some output for that project which we can use.
+            boolean projectHasOutputFromPreviousSession
+                    = !session.getProjects().contains( project ) && outputDirectory.exists();
+
+            if ( projectHasOutputFromPreviousSession || projectCompiledDuringThisSession )
             {
-                String type = artifact.getProperty( "type", "" );
-                File outputDirectory = new File( project.getBuild().getOutputDirectory() );
-
-                // Check if the project is being built during this session, and if we can expect any output.
-                // There is no need to check if the build has created any outputs, see MNG-2222.
-                boolean projectCompiledDuringThisSession
-                        = project.hasLifecyclePhase( "compile" ) && COMPILE_PHASE_TYPES.contains( type );
-
-                // Check if the project is part of the session (not filtered by -pl, -rf, etc). If so, we check
-                // if a possible earlier Maven invocation produced some output for that project which we can use.
-                boolean projectHasOutputFromPreviousSession
-                        = !session.getProjects().contains( project ) && outputDirectory.exists();
-
-                if ( projectHasOutputFromPreviousSession || projectCompiledDuringThisSession )
-                {
-                    return outputDirectory;
-                }
+                return outputDirectory;
             }
         }
 
@@ -237,7 +245,7 @@
         return projectArtifact != null && projectArtifact.getFile() != null && projectArtifact.getFile().exists();
     }
 
-    private boolean isPackagedArtifactUpToDate( MavenProject project, File packagedArtifactFile )
+    private boolean isPackagedArtifactUpToDate( MavenProject project, File packagedArtifactFile, Artifact artifact )
     {
         Path outputDirectory = Paths.get( project.getBuild().getOutputDirectory() );
         if ( !outputDirectory.toFile().exists() )
@@ -263,15 +271,28 @@
             while ( iterator.hasNext() )
             {
                 Path outputFile = iterator.next();
+
+                if ( Files.isDirectory(  outputFile ) )
+                {
+                    continue;
+                }
+
                 long outputFileLastModified = Files.getLastModifiedTime( outputFile ).toMillis();
                 if ( outputFileLastModified > artifactLastModified )
                 {
-                    LOGGER.warn(
-                            "Packaged artifact for {} is not up-to-date compared to the build output directory; "
-                          + "file {} is more recent than {}.",
-                            project.getArtifactId(),
-                            relativizeOutputFile( outputFile ), relativizeOutputFile( packagedArtifactFile.toPath() )
-                    );
+                    File alternative = determineBuildOutputDirectoryForArtifact( project, artifact );
+                    if ( alternative != null )
+                    {
+                        LOGGER.warn( "File '{}' is more recent than the packaged artifact for '{}'; using '{}' instead",
+                                relativizeOutputFile( outputFile ), project.getArtifactId(),
+                                relativizeOutputFile( alternative.toPath() ) );
+                    }
+                    else
+                    {
+                        LOGGER.warn( "File '{}' is more recent than the packaged artifact for '{}'; "
+                                + "cannot use the build output directory for this type of artifact",
+                                relativizeOutputFile( outputFile ), project.getArtifactId() );
+                    }
                     return false;
                 }
             }