-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat(gradle): excludeDependsOn based on provider relationships #33923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit 192e188
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ The fix from Nx Cloud was applied
These changes fix the ktfmt formatting check failure in the gradle-project-graph:build task. The formatter corrected minor formatting issues including removing an extra blank line and adjusting comment line wrapping in TaskUtils.kt to comply with ktfmt standards.
We had verified this fix by re-running gradle-project-graph:build.
Suggested Fix changes
diff --git a/packages/gradle/project-graph/src/main/kotlin/dev/nx/gradle/utils/TaskUtils.kt b/packages/gradle/project-graph/src/main/kotlin/dev/nx/gradle/utils/TaskUtils.kt
index 0db9cb153f..d252303e6f 100644
--- a/packages/gradle/project-graph/src/main/kotlin/dev/nx/gradle/utils/TaskUtils.kt
+++ b/packages/gradle/project-graph/src/main/kotlin/dev/nx/gradle/utils/TaskUtils.kt
@@ -96,7 +96,6 @@ fun processTask(
}
}
-
return target
}
@@ -485,8 +484,8 @@ fun isCacheable(task: Task): Boolean {
* resolution. Uses Gradle internal APIs to access raw dependency values and check for providers
* with known producer tasks.
*
- * These are the dependencies that will cause "Querying the mapped value of flatmap(...) before
- * task has completed" errors when the provider value is queried before the producing task completes.
+ * These are the dependencies that will cause "Querying the mapped value of flatmap(...) before task
+ * has completed" errors when the provider value is queried before the producing task completes.
*
* @param task the task to analyze
* @param project the project containing the task (unused but kept for API compatibility)
diff --git a/packages/gradle/project-graph/src/test/kotlin/dev/nx/gradle/utils/ProcessTaskUtilsTest.kt b/packages/gradle/project-graph/src/test/kotlin/dev/nx/gradle/utils/ProcessTaskUtilsTest.kt
index 4825d074f1..3e36a9a2c6 100644
--- a/packages/gradle/project-graph/src/test/kotlin/dev/nx/gradle/utils/ProcessTaskUtilsTest.kt
+++ b/packages/gradle/project-graph/src/test/kotlin/dev/nx/gradle/utils/ProcessTaskUtilsTest.kt
@@ -547,9 +547,11 @@ class ProcessTaskUtilsTest {
@Test
fun `identifies ProviderInternal from task output files`() {
- val producerProvider = project.tasks.register("producer") { task ->
- task.outputs.file(java.io.File(project.layout.buildDirectory.asFile.get(), "output.jar"))
- }
+ val producerProvider =
+ project.tasks.register("producer") { task ->
+ task.outputs.file(
+ java.io.File(project.layout.buildDirectory.asFile.get(), "output.jar"))
+ }
val consumerProvider = project.tasks.register("consumer")
consumerProvider.configure { it.dependsOn(producerProvider.map { p -> p.outputs.files }) }
@@ -560,9 +562,10 @@ class ProcessTaskUtilsTest {
@Test
fun `identifies ProviderInternal from task output directory`() {
- val compileProvider = project.tasks.register("compile") { task ->
- task.outputs.dir(java.io.File(project.layout.buildDirectory.asFile.get(), "classes"))
- }
+ val compileProvider =
+ project.tasks.register("compile") { task ->
+ task.outputs.dir(java.io.File(project.layout.buildDirectory.asFile.get(), "classes"))
+ }
val jarProvider = project.tasks.register("jar")
jarProvider.configure { it.dependsOn(compileProvider.map { p -> p.outputs.files }) }
🎓 Learn more about Self-Healing CI on nx.dev
| * has completed" errors when the provider value is queried before the producing task completes. | ||
| * | ||
| * @param task the task to analyze | ||
| * @param project the project containing the task (unused but kept for API compatibility) | ||
| * @return set of task paths that are provider-based dependencies with known producers | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation Bug: References non-existent parameter
The documentation mentions @param project the project containing the task (unused but kept for API compatibility) but the function signature findProviderBasedDependencies(task: Task): Set<String> has no project parameter. This will confuse developers and the comment is misleading.
Fix: Remove the incorrect parameter documentation or add the project parameter if it's actually needed.
| * has completed" errors when the provider value is queried before the producing task completes. | |
| * | |
| * @param task the task to analyze | |
| * @param project the project containing the task (unused but kept for API compatibility) | |
| * @return set of task paths that are provider-based dependencies with known producers | |
| */ | |
| * has completed" errors when the provider value is queried before the producing task completes. | |
| * | |
| * @param task the task to analyze | |
| * @return set of task paths that are provider-based dependencies with known producers | |
| */ | |
Spotted by Graphite Agent
Is this helpful? React 👍 or 👎 to let us know.
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
We have a hard coded list of task targets to not exclude depends on.
Expected Behavior
We resolve a gradle task such that we can identify if there are provider dependency relationships involved. If there are, then do not exclude depends on since Gradle needs the dependsOn tasks to fulfill providers.
Related Issue(s)
Fixes #