Skip to content

Commit 628c333

Browse files
authored
[MCOMPILER-549] Improve log message in case of recompilation (#201)
* idk refactored to immutableOutputFile * rephrased log output * reformatted code * improved log message * updated test case
1 parent d138bd4 commit 628c333

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/it/MCOMPILER-500-package-info-incr/verify.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def logFile = new File( basedir, 'build.log' )
2020
assert logFile.exists()
2121
content = logFile.text
2222

23-
assert 1 == content.count( 'Changes detected - recompiling the module!' )
24-
assert 1 == content.count( 'Nothing to compile - all classes are up to date' )
23+
assert 1 == content.count( "Recompiling the module because of ")
24+
assert 1 == content.count( 'Nothing to compile - all classes are up to date.' )
2525

2626

src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -878,20 +878,22 @@ public void execute() throws MojoExecutionException, CompilationFailureException
878878

879879
DirectoryScanResult dsr = computeInputFileTreeChanges(incrementalBuildHelper, sources);
880880

881-
boolean idk = compiler.getCompilerOutputStyle()
881+
boolean immutableOutputFile = compiler.getCompilerOutputStyle()
882882
.equals(CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES)
883883
&& !canUpdateTarget;
884884
boolean dependencyChanged = isDependencyChanged();
885885
boolean sourceChanged = isSourceChanged(compilerConfiguration, compiler);
886886
boolean inputFileTreeChanged = hasInputFileTreeChanged(dsr);
887887
// CHECKSTYLE_OFF: LineLength
888-
if (idk || dependencyChanged || sourceChanged || inputFileTreeChanged)
888+
if (immutableOutputFile || dependencyChanged || sourceChanged || inputFileTreeChanged)
889889
// CHECKSTYLE_ON: LineLength
890890
{
891-
String cause = idk
892-
? "idk"
893-
: (dependencyChanged ? "dependency" : (sourceChanged ? "source" : "input tree"));
894-
getLog().info("Changes detected - recompiling the module! :" + cause);
891+
String cause = immutableOutputFile
892+
? "immutable single output file"
893+
: (dependencyChanged
894+
? "changed dependency"
895+
: (sourceChanged ? "changed source code" : "added or removed source files"));
896+
getLog().info("Recompiling the module because of " + cause + ".");
895897
if (showCompilationChanges) {
896898
for (String fileAdded : dsr.getFilesAdded()) {
897899
getLog().info("\t+ " + fileAdded);
@@ -903,7 +905,7 @@ public void execute() throws MojoExecutionException, CompilationFailureException
903905

904906
compilerConfiguration.setSourceFiles(sources);
905907
} else {
906-
getLog().info("Nothing to compile - all classes are up to date");
908+
getLog().info("Nothing to compile - all classes are up to date.");
907909

908910
return;
909911
}

0 commit comments

Comments
 (0)