cowwoc opened a new pull request, #388:
URL: https://github.com/apache/maven-build-cache-extension/pull/388
## Problem
When `attachedOutputs` is not specified in `maven-build-cache-config.xml`,
the build cache returns an empty list, meaning **no directories are cached by
default**. This causes issues where compiled classes are not restored from
cache, leading to:
- Build failures when running `mvn test` after cache restoration
- Inconsistent behavior between cached and non-cached builds
- Users needing to manually configure attachedOutputs in every project
As reported in #259 and #340, users encounter errors like:
```
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-surefire-plugin:test
(default-test) on project: There are test failures.
```
This occurs because test-classes are restored but the main classes directory
is empty.
## Solution
Change the default value of `attachedOutputs` to cache the most commonly
needed directories:
```xml
<attachedOutputs>
<dirNames>
<dirName>classes</dirName>
<dirName>test-classes</dirName>
</dirNames>
</attachedOutputs>
```
## Changes
### Code Changes
- **CacheConfigImpl.java**: Modified `getAttachedOutputs()` to return
default directories when configuration is null
- Added `getDefaultAttachedOutputs()` helper method to create DirName
instances for `classes` and `test-classes`
### Documentation Updates
- **usage.md**: Updated IDE support section to reflect that classes and
test-classes are now restored by default
- **build-cache-config.mdo**: Added documentation explaining the new default
behavior
## Related Issues & PRs
This change addresses multiple user requests:
- Fixes #259: Compiled classes are not copied/restored to target, causing
higher phase builds to fail
- Fixes #340: mvn test fails on missing classes after mvn compile
- Related to #177: PR discussion where contributors requested this exact
default configuration
## Backward Compatibility
This change is **backward compatible**:
- Projects that explicitly configure `attachedOutputs` will continue to work
exactly as before
- Projects without configuration now get sensible defaults instead of an
empty list
- No breaking changes to existing functionality
## Testing
- ✅ Build completes successfully with changes
- ✅ Default configuration creates proper DirName objects
- ✅ Existing explicit configurations remain unaffected
--
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]