cowwoc commented on code in PR #395:
URL:
https://github.com/apache/maven-build-cache-extension/pull/395#discussion_r2578137767
##########
src/main/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategy.java:
##########
@@ -163,8 +176,16 @@ public void execute(
.isEmpty()) {
LOGGER.info("Cache storing is skipped since there was no
\"clean\" phase.");
} else {
- final Map<String, MojoExecutionEvent> executionEvents =
mojoListener.getProjectExecutions(project);
- cacheController.save(result, mojoExecutions,
executionEvents);
+ // Validation-time events must exist for cache storage
+ // If they don't exist, this indicates a bug in the
capture logic
+ if (result.getValidationTimeEvents() == null
+ || result.getValidationTimeEvents().isEmpty()) {
+ throw new AssertionError(
+ "Validation-time properties not captured for
project " + projectName
+ + ". This is a bug - validation-time
capture should always succeed when saving to cache.");
Review Comment:
Hopefully I understood your comment correctly. See
https://github.com/apache/maven-build-cache-extension/pull/395/commits/6cf3a361c988f9acdf97b291f93e8af9a6a0551f
##########
src/main/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategy.java:
##########
@@ -434,6 +455,63 @@ private static String normalizedPath(Path path, Path
baseDirPath) {
return normalizedPath;
}
+ /**
+ * Captures plugin properties at validation time for all mojo executions.
+ * This ensures properties are read at the same lifecycle point for all
builds,
+ * eliminating timing mismatches caused by Maven 4's auto-injection of
properties
+ * like --module-version during execution.
+ *
+ * @param session Maven session
+ * @param project Current project
+ * @param mojoExecutions List of mojo executions to capture properties for
+ * @return Map of execution key to MojoExecutionEvent captured at
validation time
+ */
+ private Map<String, MojoExecutionEvent> captureValidationTimeProperties(
+ MavenSession session, MavenProject project, List<MojoExecution>
mojoExecutions) {
+ Map<String, MojoExecutionEvent> validationTimeEvents = new
java.util.HashMap<>();
Review Comment:
Fixed in
https://github.com/apache/maven-build-cache-extension/pull/395/commits/6cf3a361c988f9acdf97b291f93e8af9a6a0551f
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]