fix(gradle): use object notation for exclude tasks#35085
Conversation
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ 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 24b2b5e
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
✅ 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.
View interactive diff ↗➡️ This fix was applied by Louie Weng
🎓 Learn more about Self-Healing CI on nx.dev
Co-authored-by: lourw <lourw@users.noreply.github.com>
…-continuous-task-assignment
<!-- 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>
|
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
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 #