fix(gradle): change run and bootRun to cacheable false (#31287)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
currently, all tasks are cacheable

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
run and bootRun should not be cacheable

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Emily Xiong 2025-05-23 17:25:02 -04:00 committed by GitHub
parent 1e30f3d148
commit e01a18dee9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -25,7 +25,7 @@ fun processTask(
val logger = task.logger
logger.info("NxProjectReportTask: process $task for $projectRoot")
val target = mutableMapOf<String, Any?>()
target["cache"] = true // set cache to be always true
target["cache"] = isCacheable(task) // set cache based on whether the task is cacheable
val continuous = isContinuous(task)
if (continuous) {
@ -307,6 +307,14 @@ fun replaceRootInPath(p: String, projectRoot: String, workspaceRoot: String): St
return null
}
val continuousTasks = setOf("bootRun")
fun isContinuous(task: Task): Boolean {
return task.name == "bootRun"
return continuousTasks.contains(task.name)
}
val nonCacheableTasks = setOf("bootRun", "run")
fun isCacheable(task: Task): Boolean {
return !nonCacheableTasks.contains(task.name)
}