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


##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -876,37 +874,33 @@ public void execute() throws MojoExecutionException, 
CompilationFailureException
 
                 incrementalBuildHelperRequest = new 
IncrementalBuildHelperRequest().inputFiles(sources);
 
-                DirectoryScanResult dsr = 
computeInputFileTreeChanges(incrementalBuildHelper, sources);
-
-                boolean immutableOutputFile = compiler.getCompilerOutputStyle()
-                                
.equals(CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES)
-                        && !canUpdateTarget;
-                boolean dependencyChanged = isDependencyChanged();
-                boolean sourceChanged = isSourceChanged(compilerConfiguration, 
compiler);
-                boolean inputFileTreeChanged = hasInputFileTreeChanged(dsr);
-                // CHECKSTYLE_OFF: LineLength
-                if (immutableOutputFile || dependencyChanged || sourceChanged 
|| inputFileTreeChanged)
-                // CHECKSTYLE_ON: LineLength
-                {
-                    String cause = immutableOutputFile
-                            ? "immutable single output file"
-                            : (dependencyChanged
-                                    ? "changed dependency"
-                                    : (sourceChanged ? "changed source code" : 
"added or removed source files"));
-                    getLog().info("Recompiling the module because of " + cause 
+ ".");
-                    if (showCompilationChanges) {
-                        for (String fileAdded : dsr.getFilesAdded()) {
-                            getLog().info("\t+ " + fileAdded);
-                        }
-                        for (String fileRemoved : dsr.getFilesRemoved()) {
-                            getLog().info("\t- " + fileRemoved);
-                        }
-                    }
-
+                // Strategies used to detect modifications.
+                Supplier<String> immutableOutputFile = () -> 
(compiler.getCompilerOutputStyle()
+                                        
.equals(CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES)
+                                && !canUpdateTarget)
+                        ? "immutable single output file"
+                        : null;
+                Supplier<String> dependencyChanged = () -> 
isDependencyChanged() ? "changed dependency" : null;
+                Supplier<String> sourceChanged =
+                        () -> isSourceChanged(compilerConfiguration, compiler) 
? "changed source code" : null;
+                Supplier<String> inputFileTreeChanged =
+                        () -> 
hasInputFileTreeChanged(computeInputFileTreeChanges(incrementalBuildHelper, 
sources))
+                                ? "added or removed source files"
+                                : null;
+
+                // Lazy evaluation of the incremental compilation detection.
+                String cause = Stream.of(immutableOutputFile, 
dependencyChanged, sourceChanged, inputFileTreeChanged)

Review Comment:
   Will need to undo the lazy evaluation, I plan to make more changes to the 
dependency detection and I need to store the status of the detection, if I 
lazily run this it will not execute and store the file and that means that the 
next execution could be recompiled again. 😞 



##########
src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java:
##########
@@ -876,37 +874,33 @@ public void execute() throws MojoExecutionException, 
CompilationFailureException
 
                 incrementalBuildHelperRequest = new 
IncrementalBuildHelperRequest().inputFiles(sources);
 
-                DirectoryScanResult dsr = 
computeInputFileTreeChanges(incrementalBuildHelper, sources);
-
-                boolean immutableOutputFile = compiler.getCompilerOutputStyle()
-                                
.equals(CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES)
-                        && !canUpdateTarget;
-                boolean dependencyChanged = isDependencyChanged();
-                boolean sourceChanged = isSourceChanged(compilerConfiguration, 
compiler);
-                boolean inputFileTreeChanged = hasInputFileTreeChanged(dsr);
-                // CHECKSTYLE_OFF: LineLength
-                if (immutableOutputFile || dependencyChanged || sourceChanged 
|| inputFileTreeChanged)
-                // CHECKSTYLE_ON: LineLength
-                {
-                    String cause = immutableOutputFile
-                            ? "immutable single output file"
-                            : (dependencyChanged
-                                    ? "changed dependency"
-                                    : (sourceChanged ? "changed source code" : 
"added or removed source files"));
-                    getLog().info("Recompiling the module because of " + cause 
+ ".");
-                    if (showCompilationChanges) {
-                        for (String fileAdded : dsr.getFilesAdded()) {
-                            getLog().info("\t+ " + fileAdded);
-                        }
-                        for (String fileRemoved : dsr.getFilesRemoved()) {
-                            getLog().info("\t- " + fileRemoved);
-                        }
-                    }
-
+                // Strategies used to detect modifications.
+                Supplier<String> immutableOutputFile = () -> 
(compiler.getCompilerOutputStyle()
+                                        
.equals(CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES)
+                                && !canUpdateTarget)
+                        ? "immutable single output file"
+                        : null;
+                Supplier<String> dependencyChanged = () -> 
isDependencyChanged() ? "changed dependency" : null;
+                Supplier<String> sourceChanged =
+                        () -> isSourceChanged(compilerConfiguration, compiler) 
? "changed source code" : null;
+                Supplier<String> inputFileTreeChanged =
+                        () -> 
hasInputFileTreeChanged(computeInputFileTreeChanges(incrementalBuildHelper, 
sources))
+                                ? "added or removed source files"
+                                : null;
+
+                // Lazy evaluation of the incremental compilation detection.
+                String cause = Stream.of(immutableOutputFile, 
dependencyChanged, sourceChanged, inputFileTreeChanged)

Review Comment:
   Will need to undo the lazy evaluation, I plan to make more changes to the 
dependency detection and I need to store the status of the detection, if I 
lazily run this it will not execute and store the file and that means that the 
next execution could be recompiled again. 😞 



-- 
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