Skip to content

Commit

Permalink
Fix message when building because of a clean state
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed May 16, 2024
1 parent d79caa0 commit 4a50804
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ public void execute() throws MojoExecutionException, CompilationFailureException
incrementalBuildHelperRequest = new IncrementalBuildHelperRequest().inputFiles(sources);

// Strategies used to detect modifications.
String cleanState = isCleanState(incrementalBuildHelper) ? "clean state" : null;
String immutableOutputFile = (compiler.getCompilerOutputStyle()
.equals(CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES)
&& !canUpdateTarget)
Expand All @@ -945,7 +946,8 @@ public void execute() throws MojoExecutionException, CompilationFailureException
: null;

// Get the first cause for the rebuild compilation detection.
String cause = Stream.of(immutableOutputFile, dependencyChanged, sourceChanged, inputFileTreeChanged)
String cause = Stream.of(
cleanState, immutableOutputFile, dependencyChanged, sourceChanged, inputFileTreeChanged)
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
Expand Down Expand Up @@ -1591,6 +1593,22 @@ private static List<String> removeEmptyCompileSourceRoots(List<String> compileSo
return newCompileSourceRootsList;
}

/**
*
*/
protected boolean isCleanState(IncrementalBuildHelper ibh) {
Path mojoConfigBase;
try {
mojoConfigBase = ibh.getMojoStatusDirectory().toPath();
} catch (MojoExecutionException e) {
// we cannot get the mojo status dir, so don't do anything beside logging
getLog().warn("Error reading mojo status directory.");
return false;
}
Path mojoConfigFile = mojoConfigBase.resolve(INPUT_FILES_LST_FILENAME);
return !Files.exists(mojoConfigFile);
}

/**
* We just compare the timestamps of all local dependency files (inter-module dependency classpath) and the own
* generated classes and if we got a file which is &gt;= the build-started timestamp, then we caught a file which
Expand Down

0 comments on commit 4a50804

Please sign in to comment.