Skip to content

fix(gradle): use object notation for exclude tasks#35085

Merged
lourw merged 6 commits intomasterfrom
feature/nxc-4148-investigate-failures-when-continuous-task-assignment
Mar 31, 2026
Merged

fix(gradle): use object notation for exclude tasks#35085
lourw merged 6 commits intomasterfrom
feature/nxc-4148-investigate-failures-when-continuous-task-assignment

Conversation

@lourw
Copy link
Copy Markdown
Contributor

@lourw lourw commented Mar 30, 2026

Current Behavior

The Gradle executor's task exclusion logic represents running tasks and dependency relationships using colon-delimited string IDs (e.g. "project:target"). Parsing task identity by splitting on : breaks silently when project or target names contain colons — a common pattern in Gradle (e.g. :sub:project, compile:java).

Expected Behavior

Task identity is represented as a structured ProjectTarget object with explicit project and target fields, eliminating string-splitting ambiguity. The getExcludeTasks, getAllDependsOn, and getGradleTaskName functions now accept and return typed objects, and test fixtures use object-notation dependsOn entries. A new test case verifies correct behavior when names contain colons.

Related Issue(s)

Fixes #

@lourw lourw requested a review from a team as a code owner March 30, 2026 18:23
@lourw lourw requested a review from AgentEnder March 30, 2026 18:23
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 30, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 24b2b5e
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69cb19ca6b32f900087b4989
😎 Deploy Preview https://deploy-preview-35085--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 30, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 24b2b5e
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69cb19ca9257cc000704092b
😎 Deploy Preview https://deploy-preview-35085--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@lourw lourw self-assigned this Mar 30, 2026
@lourw lourw changed the title fix(gradle): use object notation for exlude tasks fix(gradle): use object notation for exclude tasks Mar 30, 2026
@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud bot commented Mar 30, 2026

View your CI Pipeline Execution ↗ for commit 24b2b5e

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 10m 21s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 5s View ↗
nx-cloud record -- pnpm nx conformance:check ✅ Succeeded 7s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-31 01:03:43 UTC

nx-cloud[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud bot left a 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

We updated gradle-batch.impl.spec.ts to use object-notation dependsOn entries (e.g. { target: 'lint' }, { target: 'build', projects: ['app2'] }) to match the ProjectTarget-based implementation introduced by this PR. The old string-format entries like 'app1:lint' were being resolved by the updated resolveDepToProjectTarget as same-project targets with the full string as the target name, producing keys that don't exist in nodes and leaving excludeTasks empty. This mirrors the equivalent fix already applied to get-exclude-task.spec.ts in the PR.

Tip

We verified this fix by re-running gradle:test.

Suggested Fix changes
diff --git a/packages/gradle/src/executors/gradle/gradle-batch.impl.spec.ts b/packages/gradle/src/executors/gradle/gradle-batch.impl.spec.ts
index e4bf69aa65..9a485cd118 100644
--- a/packages/gradle/src/executors/gradle/gradle-batch.impl.spec.ts
+++ b/packages/gradle/src/executors/gradle/gradle-batch.impl.spec.ts
@@ -16,7 +16,10 @@ describe('getGradlewTasksToRun', () => {
           root: 'app1',
           targets: {
             test: {
-              dependsOn: ['app1:lint', 'app2:build'],
+              dependsOn: [
+                { target: 'lint' },
+                { target: 'build', projects: ['app2'] },
+              ],
               options: { taskName: 'testApp1' },
             },
             lint: {
@@ -45,7 +48,7 @@ describe('getGradlewTasksToRun', () => {
           root: 'app3',
           targets: {
             deploy: {
-              dependsOn: ['app1:test'],
+              dependsOn: [{ target: 'test', projects: ['app1'] }],
               options: { taskName: 'deployApp3' },
             },
           },

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.

Revert fix via Nx Cloud  

View interactive diff ↗

➡️ This fix was applied by Louie Weng

🎓 Learn more about Self-Healing CI on nx.dev

@lourw lourw merged commit 8a77a08 into master Mar 31, 2026
23 checks passed
@lourw lourw deleted the feature/nxc-4148-investigate-failures-when-continuous-task-assignment branch March 31, 2026 01:17
vsavkin pushed a commit that referenced this pull request Mar 31, 2026
<!-- 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
                  
The Gradle executor's task exclusion logic represents running tasks and
dependency relationships using colon-delimited string IDs (e.g.
"project:target"). Parsing task identity by splitting on : breaks
silently when project or target names contain colons — a common pattern
in Gradle (e.g. :sub:project, compile:java).
## Expected Behavior     

Task identity is represented as a structured ProjectTarget object with
explicit project and target fields, eliminating string-splitting
ambiguity. The getExcludeTasks, getAllDependsOn, and getGradleTaskName
functions now accept and return typed objects, and test fixtures use
object-notation dependsOn entries. A new test case verifies correct
behavior when names contain colons.

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

Fixes #

---------

Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>
Co-authored-by: lourw <lourw@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 6, 2026

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants