Commit 70ee53b
committed
Add project-model-based defaults with opt-in/opt-out for attachedOutputs
Implemented reviewer suggestions to use project model for default attached
outputs instead of hardcoded paths, with optional disable via property.
Changes:
- Modified CacheConfig.getAttachedOutputs() to accept MavenProject parameter
- Updated CacheConfigImpl to compute defaults from project.getBuild():
* getOutputDirectory() for main classes
* getTestOutputDirectory() for test classes
* Compute relative paths from build directory
- Added getRelativePath() helper method
- Updated CacheControllerImpl.attachOutputs() to pass project
- Added maven.build.cache.attachedOutputs.enabled property (default: true)
to allow disabling automatic restoration for performance-sensitive scenarios
- Updated tests to create mock MavenProject with Build configuration
- Removed getAttachedOutputs from assertDefaults() helper (now requires parameter)
Tests added:
- testDefaultAttachedOutputsWhenNotConfigured() - verifies project-based defaults
- testExplicitAttachedOutputsOverridesDefaults() - verifies XML config overrides
- testDefaultAttachedOutputsDisabledViaProperty() - verifies opt-out functionality
- testDefaultAttachedOutputsWithCustomDirectories() - verifies custom paths work
This addresses reviewer concerns:
✓ Project-model-based approach respects custom output directory configurations
✓ Safe defaults matching cache-disabled behavior
✓ Opt-in/opt-out for performance-sensitive CI environments
Usage:
# Disable automatic restoration (CI optimization)
mvn clean install -Dmaven.build.cache.attachedOutputs.enabled=false
# Enable (default)
mvn clean install -Dmaven.build.cache.attachedOutputs.enabled=true1 parent e0819ce commit 70ee53b
File tree
4 files changed
+146
-8
lines changed- src
- main/java/org/apache/maven/buildcache
- xml
- test/java/org/apache/maven/buildcache/xml
4 files changed
+146
-8
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
930 | 930 | | |
931 | 931 | | |
932 | 932 | | |
933 | | - | |
| 933 | + | |
934 | 934 | | |
935 | 935 | | |
936 | 936 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
109 | | - | |
| 110 | + | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| |||
Lines changed: 30 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| 99 | + | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| |||
572 | 574 | | |
573 | 575 | | |
574 | 576 | | |
575 | | - | |
| 577 | + | |
576 | 578 | | |
577 | 579 | | |
578 | 580 | | |
579 | | - | |
| 581 | + | |
580 | 582 | | |
581 | 583 | | |
582 | 584 | | |
583 | 585 | | |
584 | | - | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
585 | 593 | | |
586 | 594 | | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
587 | 604 | | |
588 | | - | |
| 605 | + | |
589 | 606 | | |
590 | 607 | | |
591 | 608 | | |
592 | | - | |
| 609 | + | |
593 | 610 | | |
594 | 611 | | |
595 | 612 | | |
596 | 613 | | |
597 | 614 | | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
598 | 623 | | |
599 | 624 | | |
600 | 625 | | |
| |||
Lines changed: 113 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
42 | 44 | | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| 49 | + | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
| |||
169 | 174 | | |
170 | 175 | | |
171 | 176 | | |
172 | | - | |
| 177 | + | |
173 | 178 | | |
174 | 179 | | |
175 | 180 | | |
| |||
482 | 487 | | |
483 | 488 | | |
484 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
485 | 597 | | |
0 commit comments