olamy commented on code in PR #522:
URL:
https://github.com/apache/maven-build-cache-extension/pull/522#discussion_r3754501600
##########
src/main/java/org/apache/maven/buildcache/BuildCacheMojosExecutionStrategy.java:
##########
@@ -116,8 +116,23 @@ public void execute(
// so forks should rerun too
boolean forkedExecution =
lifecyclePhasesHelper.isForkedProject(project);
String projectName = getVersionlessProjectKey(project);
+ // Full caching (look up, restore and save) applies to a normal
lifecycle build, or to goals typed
+ // on the command line when they all map to a real phase after
clean (e.g. mvn compiler:compile).
+ boolean cacheEligible = !forkedExecution
+ && (source == Source.LIFECYCLE
+ || (source == Source.CLI
+ && cacheConfig.isCacheSingleGoal()
+ &&
isCacheableCliInvocation(mojoExecutions)));
+ // When a command-line goal forks a lifecycle (e.g. jetty:run
forks test-compile via
+ // @Execute(phase=...)), let that fork restore from cache but
never save. We skip forks that happen
+ // inside a normal build: that build already handles caching, and
joining in would just cause an
+ // extra, pointless cache lookup (see ForkedExecutionsTest /
ForkedExecutionCoreExtensionTest).
+ boolean forkedRestoreEligible = forkedExecution
+ && cacheConfig.isRestoreForkedExecutions()
+ && source == Source.LIFECYCLE
+ && isCliOriginatedFork(project);
Review Comment:
good catch. But the fix is not as easy as this single change
--
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]