daekene opened a new pull request, #547:
URL: https://github.com/apache/maven-build-cache-extension/pull/547

   Fixes #546
   
   Records each project's build cache outcome as `MavenProject` context values, 
so other extensions and plugins can tell whether a module was restored without 
parsing logs or depending on this extension's classes.
   
   **What**
   - New `ProjectCacheStatus` enum: `HIT`, `PARTIAL_HIT`, `MISS`, 
`RESTORE_FAILED`, `SKIPPED`, `DISABLED`. It holds the public key constants 
`maven.build.cache.status` and `maven.build.cache.source`. Values are stored as 
`String`s.
   - `BuildCacheMojosExecutionStrategy` publishes the outcome:
     - **On a hit:** inside `restoreProject()`, once artifacts are restored and 
before `runAlways` mojos or the mojos after the cached segment run, so those 
mojos can see it.
     - **Otherwise:** in `execute()`, after the restore decision and before the 
build mojos run.
   - A how-to section documents the keys.
   
   **Semantics**
   - `RESTORE_FAILED` means a cache entry was found but the project was 
rebuilt: either the entry didn't match the request (missing executions, cache 
rules), or restoring it failed.
   - Nothing is published when the cache doesn't consider the execution: 
non-cacheable command-line goals, or lifecycles forked inside a normal build. A 
forked project shares its context map with the original project 
(`MavenProject.clone()` is shallow), so publishing from those forks would 
overwrite the real outcome.
   - A later cacheable run of the same project in the session replaces both 
values, so no stale `source` is left behind.
   
   **Tests**
   - Unit tests in `BuildCacheMojosExecutionStrategyTest` drive `execute()` for 
each status. They also check that a fork doesn't overwrite the outcome, that 
`runAlways` mojos see `HIT`, and that no stale source remains.
   - New IT `ProjectCacheStatusTest`: a Groovy probe runs on every build and 
logs the values. It expects `MISS` and then `HIT/LOCAL`.
   - `mvn verify -Prun-its-smoke` passes locally on JDK 21 / Maven 3.9.
   
   ---
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [ ] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [ ] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   This PR was generated with AI, and has been reviewed by a human. If this is 
an issue, I am happy to address that.


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

Reply via email to