|
18 | 18 | */ |
19 | 19 | package org.apache.maven.buildcache.its; |
20 | 20 |
|
| 21 | +import java.util.Arrays; |
21 | 22 | import java.util.List; |
22 | 23 |
|
23 | 24 | import org.apache.maven.buildcache.its.junit.IntegrationTest; |
@@ -56,6 +57,29 @@ void multipleGoals(Verifier verifier) throws VerificationException { |
56 | 57 | verifyNoTextInLog(verifier, "Build cache is disabled for 'clean' goal."); |
57 | 58 | } |
58 | 59 |
|
| 60 | + /** |
| 61 | + * Verifies that running with -Dmaven.build.cache.enabled=false does not cause |
| 62 | + * IllegalStateException and the build completes successfully. |
| 63 | + * <p> |
| 64 | + * This tests the fix for the regression where stagePreExistingArtifacts() was called |
| 65 | + * without checking if the cache was initialized, causing IllegalStateException when |
| 66 | + * cache is disabled via command line. |
| 67 | + * |
| 68 | + * @see <a href="https://github.com/apache/maven-build-cache-extension/pull/394#issuecomment-3714680789">PR #394 comment</a> |
| 69 | + */ |
| 70 | + @Test |
| 71 | + void cacheDisabledViaCommandLine(Verifier verifier) throws VerificationException { |
| 72 | + verifier.setAutoclean(false); |
| 73 | + verifier.addCliOption("-Dmaven.build.cache.enabled=false"); |
| 74 | + |
| 75 | + verifier.setLogFileName("../log-cache-disabled.txt"); |
| 76 | + verifier.executeGoals(Arrays.asList("clean", "install")); |
| 77 | + verifier.verifyErrorFreeLog(); |
| 78 | + |
| 79 | + // Verify cache was actually disabled |
| 80 | + verifier.verifyTextInLog("Cache disabled by command line flag"); |
| 81 | + } |
| 82 | + |
59 | 83 | private static void verifyNoTextInLog(Verifier verifier, String text) throws VerificationException { |
60 | 84 | Assertions.assertNull(findFirstLineContainingTextsInLogs(verifier, text)); |
61 | 85 | } |
|
0 commit comments