cowwoc opened a new pull request, #387: URL: https://github.com/apache/maven-build-cache-extension/pull/387
## Problem The Maven Build Cache Extension was not properly preserving file and directory timestamps when restoring `attachedOutputs` from cache. This caused Maven to warn about files being 'more recent than the packaged artifact' even after running `mvnw verify`. ## Root Causes 1. **`CacheUtils.zip()`** did not store directory entries with their timestamps - only files were added to the ZIP 2. **`CacheUtils.unzip()`** set directory timestamps immediately during extraction, but these timestamps were subsequently overwritten when `Files.copy()` created files within those directories ## Changes ### CacheUtils.zip() - Added `preVisitDirectory()` override to store directory entries in the ZIP with their original timestamps - Modified `visitFile()` to explicitly set file entry timestamps from `BasicFileAttributes` ### CacheUtils.unzip() - Introduced `Map<Path, Long> directoryTimestamps` to defer directory timestamp updates - Directory timestamps are now set **after** all files have been extracted, preventing them from being modified by subsequent file operations - Added `HashMap` and `Map` imports to support this functionality ## Testing Created comprehensive test that verifies: - Deep directory structures (a/b/c/) - Directory timestamp preservation - File timestamp preservation - Round-trip zip/unzip consistency ## Impact This fix ensures that cached build outputs maintain their original timestamps, eliminating spurious Maven warnings and improving build cache consistency across multi-module projects. Fixes timestamp-related warnings like: ``` [WARNING] File 'formatter/api/target/classes/...' is more recent than the packaged artifact for 'module', please run a full 'mvn package' build ``` -- 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]
