cowwoc commented on PR #394:
URL:
https://github.com/apache/maven-build-cache-extension/pull/394#issuecomment-3393910722
## Addressing Performance Concerns
Thank you for raising the important question about performance overhead
during active development. You're absolutely right that caching compile outputs
on every `mvn compile` has costs:
- **IO overhead**: Zipping classes directories
- **CPU overhead**: Computing hashes
- **Network overhead**: Potentially uploading to remote cache
### Solution: Configurable Compile Caching
I've added a new property `maven.build.cache.cacheCompile` (default: `true`)
to give users control:
```bash
# Disable compile caching during active development:
mvn clean compile -Dmaven.build.cache.cacheCompile=false
# Enable for CI/multi-module scenarios (default):
mvn clean compile
```
### Design Rationale
**Default: true** - Maintains the fix for issue #393 without breaking
changes. Users experiencing compile-only cache restoration issues get the fix
automatically.
**Opt-out available** - Developers actively editing code can disable compile
caching to avoid overhead, while still benefiting from package-phase caching.
### Use Cases
**When to keep enabled (default):**
- Large multi-module projects (editing 1 of 50 modules)
- CI/CD pipelines for quick feedback
- Branch switching scenarios
- Working on test code only
**When to disable:**
- Actively editing a single module
- Rapid edit-compile-test cycles
- Development environments where package phase is always run anyway
### Implementation
The property gates the calls to `attachGeneratedSources()` and
`attachOutputs()` in `CacheControllerImpl.save()`:
```java
if (cacheConfig.isCacheCompile()) {
attachGeneratedSources(project, state, buildStartTime);
attachOutputs(project, state, buildStartTime);
}
```
This means:
- When `false`: `mvn compile` creates NO cache entry (no zipping, no IO)
- When `true` (default): Full caching as implemented for issue #393
### Testing
Added `CacheCompileDisabledTest` to verify:
- ✅ With property disabled: No cache entries created, no restoration on
second compile
- ✅ With property enabled: Cache entries created, restoration works on
second compile
Ready for your review!
--
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]