@nx/gradle 22.7.0-beta.1 → 22.7.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/batch-runner/build/libs/gradle-batch-runner-all.jar +0 -0
  2. package/batch-runner/build/libs/gradle-batch-runner.jar +0 -0
  3. package/migrations.json +24 -0
  4. package/package.json +9 -8
  5. package/src/executors/gradle/get-exclude-task.d.ts +6 -6
  6. package/src/executors/gradle/get-exclude-task.d.ts.map +1 -1
  7. package/src/executors/gradle/get-exclude-task.js +41 -36
  8. package/src/executors/gradle/gradle-batch.impl.d.ts.map +1 -1
  9. package/src/executors/gradle/gradle-batch.impl.js +55 -32
  10. package/src/executors/gradle/gradle.impl.js +3 -2
  11. package/src/migrations/22-7-0/change-plugin-version-0-1-16.d.ts +3 -0
  12. package/src/migrations/22-7-0/change-plugin-version-0-1-16.d.ts.map +1 -0
  13. package/src/migrations/22-7-0/change-plugin-version-0-1-16.js +23 -0
  14. package/src/migrations/22-7-0/change-plugin-version-0-1-17.d.ts +3 -0
  15. package/src/migrations/22-7-0/change-plugin-version-0-1-17.d.ts.map +1 -0
  16. package/src/migrations/22-7-0/change-plugin-version-0-1-17.js +23 -0
  17. package/src/migrations/22-7-0/change-plugin-version-0-1-18.d.ts +3 -0
  18. package/src/migrations/22-7-0/change-plugin-version-0-1-18.d.ts.map +1 -0
  19. package/src/migrations/22-7-0/change-plugin-version-0-1-18.js +23 -0
  20. package/src/migrations/22-7-0/change-plugin-version-0-1-19.d.ts +3 -0
  21. package/src/migrations/22-7-0/change-plugin-version-0-1-19.d.ts.map +1 -0
  22. package/src/migrations/22-7-0/change-plugin-version-0-1-19.js +23 -0
  23. package/src/plugin/utils/get-project-graph-from-gradle-plugin.d.ts.map +1 -1
  24. package/src/plugin/utils/get-project-graph-from-gradle-plugin.js +19 -8
  25. package/src/plugin/utils/get-project-graph-lines.d.ts +6 -0
  26. package/src/plugin/utils/get-project-graph-lines.d.ts.map +1 -1
  27. package/src/plugin/utils/get-project-graph-lines.js +53 -2
  28. package/src/utils/exec-gradle.d.ts.map +1 -1
  29. package/src/utils/exec-gradle.js +17 -3
  30. package/src/utils/versions.d.ts +1 -1
  31. package/src/utils/versions.js +1 -1
  32. package/batch-runner/build/nx/gradle-batch-runner.json +0 -1
  33. package/batch-runner/project.json +0 -4
  34. package/project-graph/build/nx/gradle-project-graph.json +0 -1
  35. package/project-graph/project.json +0 -28
  36. package/project-graph/publish-maven.d.ts +0 -2
  37. package/project-graph/publish-maven.d.ts.map +0 -1
  38. package/project-graph/publish-maven.js +0 -103
  39. package/src/plugin/utils/__mocks__/gradle_composite.json +0 -39
  40. package/src/plugin/utils/__mocks__/gradle_nx_list.json +0 -590
  41. package/src/plugin/utils/__mocks__/gradle_tutorial.json +0 -345
package/migrations.json CHANGED
@@ -101,6 +101,30 @@
101
101
  "cli": "nx",
102
102
  "description": "Change dev.nx.gradle.project-graph to version 0.1.15 in build file",
103
103
  "factory": "./src/migrations/22-6-0/change-plugin-version-0-1-15"
104
+ },
105
+ "change-plugin-version-0-1-16": {
106
+ "version": "22.7.0-beta.2",
107
+ "cli": "nx",
108
+ "description": "Change dev.nx.gradle.project-graph to version 0.1.16 in build file",
109
+ "factory": "./src/migrations/22-7-0/change-plugin-version-0-1-16"
110
+ },
111
+ "change-plugin-version-0-1-17": {
112
+ "version": "22.7.0-beta.4",
113
+ "cli": "nx",
114
+ "description": "Change dev.nx.gradle.project-graph to version 0.1.17 in build file",
115
+ "factory": "./src/migrations/22-7-0/change-plugin-version-0-1-17"
116
+ },
117
+ "change-plugin-version-0-1-18": {
118
+ "version": "22.7.0-beta.9",
119
+ "cli": "nx",
120
+ "description": "Change dev.nx.gradle.project-graph to version 0.1.18 in build file",
121
+ "factory": "./src/migrations/22-7-0/change-plugin-version-0-1-18"
122
+ },
123
+ "change-plugin-version-0-1-19": {
124
+ "version": "22.7.0-beta.11",
125
+ "cli": "nx",
126
+ "description": "Change dev.nx.gradle.project-graph to version 0.1.19 in build file",
127
+ "factory": "./src/migrations/22-7-0/change-plugin-version-0-1-19"
104
128
  }
105
129
  },
106
130
  "packageJsonUpdates": {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/gradle",
3
- "version": "22.7.0-beta.1",
3
+ "version": "22.7.0-beta.11",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Gradle allows Gradle tasks to be run through Nx",
6
6
  "repository": {
@@ -16,7 +16,8 @@
16
16
  "Backend"
17
17
  ],
18
18
  "main": "./index.js",
19
- "typings": "./index.d.ts",
19
+ "type": "commonjs",
20
+ "types": "./index.d.ts",
20
21
  "author": "Victor Savkin",
21
22
  "license": "MIT",
22
23
  "bugs": {
@@ -39,16 +40,16 @@
39
40
  "migrations": "./migrations.json"
40
41
  },
41
42
  "dependencies": {
42
- "@nx/devkit": "22.7.0-beta.1",
43
- "toml-eslint-parser": "^0.10.0"
43
+ "@nx/devkit": "22.7.0-beta.11",
44
+ "toml-eslint-parser": "^0.10.0",
45
+ "tree-kill": "^1.2.2",
46
+ "tslib": "^2.3.0"
44
47
  },
45
48
  "devDependencies": {
46
- "nx": "22.7.0-beta.1"
49
+ "nx": "22.7.0-beta.11"
47
50
  },
48
51
  "publishConfig": {
49
52
  "access": "public"
50
53
  },
51
- "executors": "./executors.json",
52
- "types": "./index.d.ts",
53
- "type": "commonjs"
54
+ "executors": "./executors.json"
54
55
  }
@@ -1,4 +1,4 @@
1
- import { ProjectGraphProjectNode } from 'nx/src/config/project-graph';
1
+ import { ProjectGraphProjectNode, Target } from '@nx/devkit';
2
2
  /**
3
3
  * Returns Gradle CLI arguments to exclude dependent tasks
4
4
  * that are not part of the current execution set.
@@ -6,13 +6,13 @@ import { ProjectGraphProjectNode } from 'nx/src/config/project-graph';
6
6
  * For example, if a project defines `dependsOn: ['lint']` for the `test` target,
7
7
  * and only `test` is running, this will return: ['lint']
8
8
  *
9
- * @param taskIds - Set of Nx task IDs to process
9
+ * @param tasks - Set of Target to process
10
10
  * @param nodes - Project graph nodes
11
- * @param runningTaskIds - Set of task IDs that are currently running (won't be excluded)
11
+ * @param runningTasks - Set of Target that are currently running (won't be excluded)
12
12
  * @param includeDependsOnTasks - Set of Gradle task names that should be included (not excluded)
13
13
  * (typically provider-based dependencies that Gradle must resolve)
14
14
  */
15
- export declare function getExcludeTasks(taskIds: Set<string>, nodes: Record<string, ProjectGraphProjectNode>, runningTaskIds?: Set<string>, includeDependsOnTasks?: Set<string>): Set<string>;
16
- export declare function getGradleTaskNameWithNxTaskId(nxTaskId: string, nodes: Record<string, ProjectGraphProjectNode>): string | null;
17
- export declare function getAllDependsOn(nodes: Record<string, ProjectGraphProjectNode>, projectName: string, targetName: string): Set<string>;
15
+ export declare function getExcludeTasks(tasks: Set<Target>, nodes: Record<string, ProjectGraphProjectNode>, runningTasks?: Set<Target>, includeDependsOnTasks?: Set<string>): Set<string>;
16
+ export declare function getGradleTaskName(pt: Target, nodes: Record<string, ProjectGraphProjectNode>): string | null;
17
+ export declare function getAllDependsOn(nodes: Record<string, ProjectGraphProjectNode>, projectName: string, targetName: string): Set<Target>;
18
18
  //# sourceMappingURL=get-exclude-task.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-exclude-task.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/executors/gradle/get-exclude-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EACxB,MAAM,6BAA6B,CAAC;AAgCrC;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,EAC9C,cAAc,GAAE,GAAG,CAAC,MAAM,CAAa,EACvC,qBAAqB,GAAE,GAAG,CAAC,MAAM,CAAa,GAC7C,GAAG,CAAC,MAAM,CAAC,CAmBb;AAED,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,GAC7C,MAAM,GAAG,IAAI,CAKf;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,EAC9C,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,GAAG,CAAC,MAAM,CAAC,CAyBb"}
1
+ {"version":3,"file":"get-exclude-task.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/executors/gradle/get-exclude-task.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,MAAM,EAEP,MAAM,YAAY,CAAC;AA+BpB;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,EAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,EAC9C,YAAY,GAAE,GAAG,CAAC,MAAM,CAAa,EACrC,qBAAqB,GAAE,GAAG,CAAC,MAAM,CAAa,GAC7C,GAAG,CAAC,MAAM,CAAC,CAsBb;AAED,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,GAC7C,MAAM,GAAG,IAAI,CAEf;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,EAC9C,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,GAAG,CAAC,MAAM,CAAC,CAgCb"}
@@ -1,17 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getExcludeTasks = getExcludeTasks;
4
- exports.getGradleTaskNameWithNxTaskId = getGradleTaskNameWithNxTaskId;
4
+ exports.getGradleTaskName = getGradleTaskName;
5
5
  exports.getAllDependsOn = getAllDependsOn;
6
+ const devkit_1 = require("@nx/devkit");
6
7
  /**
7
- * Resolves a dependsOn entry to an Nx task ID (project:target format).
8
- * Handles both string format ("project:target") and object format
8
+ * Resolves a dependsOn entry to a Target.
9
+ * Handles both string format ("target") and object format
9
10
  * ({ target: "name", projects?: ["proj1"] }).
10
11
  * For same-project object deps (no projects field), uses the owning project name.
11
12
  */
12
- function resolveDepToTaskId(dep, owningProject) {
13
+ function resolveDepToTarget(dep, owningProject) {
13
14
  if (typeof dep === 'string') {
14
- return dep;
15
+ return { project: owningProject, target: dep };
15
16
  }
16
17
  const target = dep?.target;
17
18
  if (!target) {
@@ -21,13 +22,12 @@ function resolveDepToTaskId(dep, owningProject) {
21
22
  const projectList = Array.isArray(dep.projects)
22
23
  ? dep.projects
23
24
  : [dep.projects];
24
- // For cross-project deps, use the first project
25
- return projectList[0] !== 'self'
26
- ? `${projectList[0]}:${target}`
27
- : `${owningProject}:${target}`;
25
+ return {
26
+ project: projectList[0] !== 'self' ? projectList[0] : owningProject,
27
+ target,
28
+ };
28
29
  }
29
- // Same-project dep (no projects field)
30
- return `${owningProject}:${target}`;
30
+ return { project: owningProject, target };
31
31
  }
32
32
  /**
33
33
  * Returns Gradle CLI arguments to exclude dependent tasks
@@ -36,21 +36,21 @@ function resolveDepToTaskId(dep, owningProject) {
36
36
  * For example, if a project defines `dependsOn: ['lint']` for the `test` target,
37
37
  * and only `test` is running, this will return: ['lint']
38
38
  *
39
- * @param taskIds - Set of Nx task IDs to process
39
+ * @param tasks - Set of Target to process
40
40
  * @param nodes - Project graph nodes
41
- * @param runningTaskIds - Set of task IDs that are currently running (won't be excluded)
41
+ * @param runningTasks - Set of Target that are currently running (won't be excluded)
42
42
  * @param includeDependsOnTasks - Set of Gradle task names that should be included (not excluded)
43
43
  * (typically provider-based dependencies that Gradle must resolve)
44
44
  */
45
- function getExcludeTasks(taskIds, nodes, runningTaskIds = new Set(), includeDependsOnTasks = new Set()) {
45
+ function getExcludeTasks(tasks, nodes, runningTasks = new Set(), includeDependsOnTasks = new Set()) {
46
46
  const excludes = new Set();
47
- for (const taskId of taskIds) {
48
- const [project, target] = taskId.split(':');
49
- const taskDeps = nodes[project]?.data?.targets?.[target]?.dependsOn ?? [];
47
+ const runningKeys = new Set(Array.from(runningTasks).map(devkit_1.targetToTargetString));
48
+ for (const task of tasks) {
49
+ const taskDeps = nodes[task.project]?.data?.targets?.[task.target]?.dependsOn ?? [];
50
50
  for (const dep of taskDeps) {
51
- const depTaskId = resolveDepToTaskId(dep, project);
52
- if (depTaskId && !runningTaskIds.has(depTaskId)) {
53
- const gradleTaskName = getGradleTaskNameWithNxTaskId(depTaskId, nodes);
51
+ const depPt = resolveDepToTarget(dep, task.project);
52
+ if (depPt && !runningKeys.has((0, devkit_1.targetToTargetString)(depPt))) {
53
+ const gradleTaskName = getGradleTaskName(depPt, nodes);
54
54
  if (gradleTaskName && !includeDependsOnTasks.has(gradleTaskName)) {
55
55
  excludes.add(gradleTaskName);
56
56
  }
@@ -59,29 +59,34 @@ function getExcludeTasks(taskIds, nodes, runningTaskIds = new Set(), includeDepe
59
59
  }
60
60
  return excludes;
61
61
  }
62
- function getGradleTaskNameWithNxTaskId(nxTaskId, nodes) {
63
- const [projectName, targetName] = nxTaskId.split(':');
64
- const gradleTaskName = nodes[projectName]?.data?.targets?.[targetName]?.options?.taskName;
65
- return gradleTaskName;
62
+ function getGradleTaskName(pt, nodes) {
63
+ return nodes[pt.project]?.data?.targets?.[pt.target]?.options?.taskName;
66
64
  }
67
65
  function getAllDependsOn(nodes, projectName, targetName) {
68
66
  const allDependsOn = new Set();
69
- const stack = [`${projectName}:${targetName}`];
67
+ const result = new Set();
68
+ const startKey = (0, devkit_1.targetToTargetString)({
69
+ project: projectName,
70
+ target: targetName,
71
+ });
72
+ const stack = [{ project: projectName, target: targetName }];
70
73
  while (stack.length > 0) {
71
- const currentTaskId = stack.pop();
72
- if (currentTaskId && !allDependsOn.has(currentTaskId)) {
73
- allDependsOn.add(currentTaskId);
74
- const [currentProjectName, currentTargetName] = currentTaskId.split(':');
75
- const directDependencies = nodes[currentProjectName]?.data?.targets?.[currentTargetName]
76
- ?.dependsOn ?? [];
74
+ const current = stack.pop();
75
+ const key = (0, devkit_1.targetToTargetString)(current);
76
+ if (!allDependsOn.has(key)) {
77
+ allDependsOn.add(key);
78
+ if (key !== startKey) {
79
+ result.add(current);
80
+ }
81
+ const directDependencies = nodes[current.project]?.data?.targets?.[current.target]?.dependsOn ??
82
+ [];
77
83
  for (const dep of directDependencies) {
78
- const depTaskId = resolveDepToTaskId(dep, currentProjectName);
79
- if (depTaskId && !allDependsOn.has(depTaskId)) {
80
- stack.push(depTaskId);
84
+ const depPt = resolveDepToTarget(dep, current.project);
85
+ if (depPt && !allDependsOn.has((0, devkit_1.targetToTargetString)(depPt))) {
86
+ stack.push(depPt);
81
87
  }
82
88
  }
83
89
  }
84
90
  }
85
- allDependsOn.delete(`${projectName}:${targetName}`); // Exclude the starting task itself
86
- return allDependsOn;
91
+ return result;
87
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gradle-batch.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/executors/gradle/gradle-batch.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,uBAAuB,EACvB,SAAS,EAEV,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,kBAAkB,EACnB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAchD,eAAO,MAAM,eAAe,QAG3B,CAAC;AAEF,wBAA8B,WAAW,CACvC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC5C,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC,CAkEvB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC5C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC;;;;EAiE/C"}
1
+ {"version":3,"file":"gradle-batch.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/executors/gradle/gradle-batch.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,uBAAuB,EAEvB,SAAS,EAEV,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,kBAAkB,EACnB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAchD,eAAO,MAAM,eAAe,QAG3B,CAAC;AAEF,wBAA8B,WAAW,CACvC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC5C,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC,CAkEvB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC5C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC;;;;EAuE/C"}
@@ -4,7 +4,6 @@ exports.batchRunnerPath = void 0;
4
4
  exports.default = gradleBatch;
5
5
  exports.getGradlewTasksToRun = getGradlewTasksToRun;
6
6
  const devkit_1 = require("@nx/devkit");
7
- const run_commands_impl_1 = require("nx/src/executors/run-commands/run-commands.impl");
8
7
  const exec_gradle_1 = require("../../utils/exec-gradle");
9
8
  const path_1 = require("path");
10
9
  const child_process_1 = require("child_process");
@@ -56,49 +55,53 @@ async function gradleBatch(taskGraph, inputs, overrides, context) {
56
55
  * Get the gradlew task ids to run
57
56
  */
58
57
  function getGradlewTasksToRun(taskIds, taskGraph, inputs, nodes) {
59
- const taskIdsWithExclude = new Set([]);
60
- const testTaskIdsWithExclude = new Set([]);
61
- const taskIdsWithoutExclude = new Set([]);
58
+ const tasksWithExclude = new Set();
59
+ const testTasksWithExclude = new Set();
60
+ const tasksWithoutExclude = new Set();
62
61
  const gradlewTasksToRun = {};
63
62
  const includeDependsOnTasks = new Set();
64
63
  for (const taskId of taskIds) {
65
64
  const task = taskGraph.tasks[taskId];
66
65
  const input = inputs[task.id];
66
+ const taskTarget = {
67
+ project: task.target.project,
68
+ target: task.target.target,
69
+ };
67
70
  gradlewTasksToRun[taskId] = input;
68
- // Collect tasks that should be included (not excluded) - typically provider-based dependencies
69
71
  if (input.includeDependsOnTasks) {
70
- for (const task of input.includeDependsOnTasks) {
71
- includeDependsOnTasks.add(task);
72
+ for (const t of input.includeDependsOnTasks) {
73
+ includeDependsOnTasks.add(t);
72
74
  }
73
75
  }
74
76
  if (input.excludeDependsOn) {
75
77
  if (input.testClassName) {
76
- testTaskIdsWithExclude.add(taskId);
78
+ testTasksWithExclude.add(taskTarget);
77
79
  }
78
80
  else {
79
- taskIdsWithExclude.add(taskId);
81
+ tasksWithExclude.add(taskTarget);
80
82
  }
81
83
  }
82
84
  else {
83
- taskIdsWithoutExclude.add(taskId);
85
+ tasksWithoutExclude.add(taskTarget);
84
86
  }
85
87
  }
86
- const allDependsOn = new Set(taskIds);
87
- for (const taskId of taskIdsWithoutExclude) {
88
- const [projectName, targetName] = taskId.split(':');
89
- const dependencies = (0, get_exclude_task_1.getAllDependsOn)(nodes, projectName, targetName);
90
- dependencies.forEach((dep) => allDependsOn.add(dep));
88
+ const allRunning = new Set(taskIds.map((id) => ({
89
+ project: taskGraph.tasks[id].target.project,
90
+ target: taskGraph.tasks[id].target.target,
91
+ })));
92
+ for (const task of tasksWithoutExclude) {
93
+ const dependencies = (0, get_exclude_task_1.getAllDependsOn)(nodes, task.project, task.target);
94
+ dependencies.forEach((dep) => allRunning.add(dep));
91
95
  }
92
- const excludeTasks = (0, get_exclude_task_1.getExcludeTasks)(taskIdsWithExclude, nodes, allDependsOn, includeDependsOnTasks);
96
+ const excludeTasks = (0, get_exclude_task_1.getExcludeTasks)(tasksWithExclude, nodes, allRunning, includeDependsOnTasks);
93
97
  const allTestsDependsOn = new Set();
94
- for (const taskId of testTaskIdsWithExclude) {
95
- const [projectName, targetName] = taskId.split(':');
96
- const taskDependsOn = (0, get_exclude_task_1.getAllDependsOn)(nodes, projectName, targetName);
98
+ for (const task of testTasksWithExclude) {
99
+ const taskDependsOn = (0, get_exclude_task_1.getAllDependsOn)(nodes, task.project, task.target);
97
100
  taskDependsOn.forEach((dep) => allTestsDependsOn.add(dep));
98
101
  }
99
102
  const excludeTestTasks = new Set();
100
- for (let taskId of allTestsDependsOn) {
101
- const gradleTaskName = (0, get_exclude_task_1.getGradleTaskNameWithNxTaskId)(taskId, nodes);
103
+ for (const task of allTestsDependsOn) {
104
+ const gradleTaskName = (0, get_exclude_task_1.getGradleTaskName)(task, nodes);
102
105
  if (gradleTaskName) {
103
106
  excludeTestTasks.add(gradleTaskName);
104
107
  }
@@ -111,20 +114,40 @@ function getGradlewTasksToRun(taskIds, taskGraph, inputs, nodes) {
111
114
  }
112
115
  async function runTasksInBatch(gradlewTasksToRun, excludeTasks, excludeTestTasks, args, root) {
113
116
  const gradlewBatchStart = performance.mark(`gradlew-batch:start`);
114
- const debugOptions = ' ' + (process.env.NX_GRADLE_BATCH_DEBUG ?? '');
115
- const command = `java${debugOptions} -jar ${exports.batchRunnerPath} --tasks='${JSON.stringify(gradlewTasksToRun)}' --workspaceRoot=${root} --args='${args
116
- .join(' ')
117
- .replaceAll("'", '"')}' --excludeTasks='${Array.from(excludeTasks).join(',')}' --excludeTestTasks='${Array.from(excludeTestTasks).join(',')}' ${process.env.NX_VERBOSE_LOGGING === 'true' ? '' : '--quiet'}`;
117
+ const debugOptions = (process.env.NX_GRADLE_BATCH_DEBUG ?? '').trim();
118
+ const spawnArgs = [
119
+ ...(debugOptions ? debugOptions.split(/\s+/) : []),
120
+ '-jar',
121
+ exports.batchRunnerPath,
122
+ `--tasks=${JSON.stringify(gradlewTasksToRun)}`,
123
+ `--workspaceRoot=${root}`,
124
+ `--args=${args.join(' ').replaceAll("'", '"')}`,
125
+ `--excludeTasks=${Array.from(excludeTasks).join(',')}`,
126
+ `--excludeTestTasks=${Array.from(excludeTestTasks).join(',')}`,
127
+ ...(process.env.NX_VERBOSE_LOGGING === 'true' ? [] : ['--quiet']),
128
+ ];
118
129
  // Use 'inherit' for stderr so Gradle output (tee'd to System.err
119
130
  // by TeeOutputStream) flows to the terminal in real-time.
120
131
  // stdout is piped to capture the JSON batch results.
121
- const batchResults = (0, child_process_1.execSync)(command, {
122
- cwd: devkit_1.workspaceRoot,
123
- windowsHide: true,
124
- env: process.env,
125
- stdio: ['pipe', 'pipe', 'inherit'],
126
- maxBuffer: run_commands_impl_1.LARGE_BUFFER,
127
- }).toString();
132
+ const batchResults = await new Promise((resolve, reject) => {
133
+ const cp = (0, child_process_1.spawn)('java', spawnArgs, {
134
+ cwd: devkit_1.workspaceRoot,
135
+ windowsHide: true,
136
+ env: process.env,
137
+ stdio: ['pipe', 'pipe', 'inherit'],
138
+ });
139
+ const chunks = [];
140
+ cp.stdout.on('data', (chunk) => chunks.push(chunk));
141
+ cp.on('error', reject);
142
+ cp.on('close', (code) => {
143
+ if (code !== 0) {
144
+ reject(new Error(`Gradle batch runner exited with code ${code}`));
145
+ }
146
+ else {
147
+ resolve(Buffer.concat(chunks).toString());
148
+ }
149
+ });
150
+ });
128
151
  const gradlewBatchEnd = performance.mark(`gradlew-batch:end`);
129
152
  performance.measure(`gradlew-batch`, gradlewBatchStart.name, gradlewBatchEnd.name);
130
153
  const gradlewBatchResults = JSON.parse(batchResults);
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = gradleExecutor;
4
+ const tslib_1 = require("tslib");
4
5
  const devkit_1 = require("@nx/devkit");
5
6
  const exec_gradle_1 = require("../../utils/exec-gradle");
6
7
  const node_path_1 = require("node:path");
7
- const run_commands_impl_1 = require("nx/src/executors/run-commands/run-commands.impl");
8
+ const run_commands_impl_1 = tslib_1.__importDefault(require("nx/src/executors/run-commands/run-commands.impl"));
8
9
  const get_exclude_task_1 = require("./get-exclude-task");
9
10
  async function gradleExecutor(options, context) {
10
11
  let projectRoot = context.projectGraph.nodes[context.projectName]?.data?.root ?? context.root;
@@ -45,7 +46,7 @@ async function gradleExecutor(options, context) {
45
46
  });
46
47
  if (options.excludeDependsOn) {
47
48
  const includeDependsOnTasks = new Set(options.includeDependsOnTasks ?? []);
48
- (0, get_exclude_task_1.getExcludeTasks)(new Set([`${context.projectName}:${context.targetName}`]), context.projectGraph.nodes, new Set(), includeDependsOnTasks).forEach((task) => {
49
+ (0, get_exclude_task_1.getExcludeTasks)(new Set([{ project: context.projectName, target: context.targetName }]), context.projectGraph.nodes, new Set(), includeDependsOnTasks).forEach((task) => {
49
50
  if (task) {
50
51
  args.push('--exclude-task', task);
51
52
  }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function update(tree: Tree): Promise<void>;
3
+ //# sourceMappingURL=change-plugin-version-0-1-16.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-plugin-version-0-1-16.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/migrations/22-7-0/change-plugin-version-0-1-16.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAO9C,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,iBAgB9C"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = update;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const has_gradle_plugin_1 = require("../../utils/has-gradle-plugin");
6
+ const gradle_project_graph_plugin_utils_1 = require("../../generators/init/gradle-project-graph-plugin-utils");
7
+ const version_catalog_ast_utils_1 = require("../../utils/version-catalog-ast-utils");
8
+ /* Change the plugin version to 0.1.16
9
+ */
10
+ async function update(tree) {
11
+ const nxJson = (0, devkit_1.readNxJson)(tree);
12
+ if (!nxJson) {
13
+ return;
14
+ }
15
+ if (!(0, has_gradle_plugin_1.hasGradlePlugin)(tree)) {
16
+ return;
17
+ }
18
+ const gradlePluginVersionToUpdate = '0.1.16';
19
+ // Update version in version catalogs using AST-based approach to preserve formatting
20
+ await (0, version_catalog_ast_utils_1.updateNxPluginVersionInCatalogsAst)(tree, gradlePluginVersionToUpdate);
21
+ // Then update in build.gradle(.kts) files
22
+ await (0, gradle_project_graph_plugin_utils_1.addNxProjectGraphPlugin)(tree, gradlePluginVersionToUpdate);
23
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function update(tree: Tree): Promise<void>;
3
+ //# sourceMappingURL=change-plugin-version-0-1-17.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-plugin-version-0-1-17.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/migrations/22-7-0/change-plugin-version-0-1-17.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAO9C,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,iBAgB9C"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = update;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const has_gradle_plugin_1 = require("../../utils/has-gradle-plugin");
6
+ const gradle_project_graph_plugin_utils_1 = require("../../generators/init/gradle-project-graph-plugin-utils");
7
+ const version_catalog_ast_utils_1 = require("../../utils/version-catalog-ast-utils");
8
+ /* Change the plugin version to 0.1.17
9
+ */
10
+ async function update(tree) {
11
+ const nxJson = (0, devkit_1.readNxJson)(tree);
12
+ if (!nxJson) {
13
+ return;
14
+ }
15
+ if (!(0, has_gradle_plugin_1.hasGradlePlugin)(tree)) {
16
+ return;
17
+ }
18
+ const gradlePluginVersionToUpdate = '0.1.17';
19
+ // Update version in version catalogs using AST-based approach to preserve formatting
20
+ await (0, version_catalog_ast_utils_1.updateNxPluginVersionInCatalogsAst)(tree, gradlePluginVersionToUpdate);
21
+ // Then update in build.gradle(.kts) files
22
+ await (0, gradle_project_graph_plugin_utils_1.addNxProjectGraphPlugin)(tree, gradlePluginVersionToUpdate);
23
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function update(tree: Tree): Promise<void>;
3
+ //# sourceMappingURL=change-plugin-version-0-1-18.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-plugin-version-0-1-18.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/migrations/22-7-0/change-plugin-version-0-1-18.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAO9C,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,iBAgB9C"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = update;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const has_gradle_plugin_1 = require("../../utils/has-gradle-plugin");
6
+ const gradle_project_graph_plugin_utils_1 = require("../../generators/init/gradle-project-graph-plugin-utils");
7
+ const version_catalog_ast_utils_1 = require("../../utils/version-catalog-ast-utils");
8
+ /* Change the plugin version to 0.1.18
9
+ */
10
+ async function update(tree) {
11
+ const nxJson = (0, devkit_1.readNxJson)(tree);
12
+ if (!nxJson) {
13
+ return;
14
+ }
15
+ if (!(0, has_gradle_plugin_1.hasGradlePlugin)(tree)) {
16
+ return;
17
+ }
18
+ const gradlePluginVersionToUpdate = '0.1.18';
19
+ // Update version in version catalogs using AST-based approach to preserve formatting
20
+ await (0, version_catalog_ast_utils_1.updateNxPluginVersionInCatalogsAst)(tree, gradlePluginVersionToUpdate);
21
+ // Then update in build.gradle(.kts) files
22
+ await (0, gradle_project_graph_plugin_utils_1.addNxProjectGraphPlugin)(tree, gradlePluginVersionToUpdate);
23
+ }
@@ -0,0 +1,3 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function update(tree: Tree): Promise<void>;
3
+ //# sourceMappingURL=change-plugin-version-0-1-19.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-plugin-version-0-1-19.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/migrations/22-7-0/change-plugin-version-0-1-19.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAc,MAAM,YAAY,CAAC;AAO9C,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,iBAgB9C"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = update;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const has_gradle_plugin_1 = require("../../utils/has-gradle-plugin");
6
+ const gradle_project_graph_plugin_utils_1 = require("../../generators/init/gradle-project-graph-plugin-utils");
7
+ const version_catalog_ast_utils_1 = require("../../utils/version-catalog-ast-utils");
8
+ /* Change the plugin version to 0.1.19
9
+ */
10
+ async function update(tree) {
11
+ const nxJson = (0, devkit_1.readNxJson)(tree);
12
+ if (!nxJson) {
13
+ return;
14
+ }
15
+ if (!(0, has_gradle_plugin_1.hasGradlePlugin)(tree)) {
16
+ return;
17
+ }
18
+ const gradlePluginVersionToUpdate = '0.1.19';
19
+ // Update version in version catalogs using AST-based approach to preserve formatting
20
+ await (0, version_catalog_ast_utils_1.updateNxPluginVersionInCatalogsAst)(tree, gradlePluginVersionToUpdate);
21
+ // Then update in build.gradle(.kts) files
22
+ await (0, gradle_project_graph_plugin_utils_1.addNxProjectGraphPlugin)(tree, gradlePluginVersionToUpdate);
23
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"get-project-graph-from-gradle-plugin.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/plugin/utils/get-project-graph-from-gradle-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,oBAAoB,EACpB,wBAAwB,EAExB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,mBAAmB,EAAoB,MAAM,yBAAyB,CAAC;AAIhF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE;QACL,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;KAClD,CAAC;IACF,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IACzD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,IAAI,EAAE,MAAM,CAAC;CACd;AAiBD,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,QAgBb;AAQD,wBAAgB,4BAA4B,IAAI,kBAAkB,CAejE;AAED,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAG/C;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EAAE,EACtB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CA6Df;AAED,wBAAgB,qBAAqB,CACnC,iBAAiB,EAAE,MAAM,EAAE,GAC1B,kBAAkB,CAkDpB"}
1
+ {"version":3,"file":"get-project-graph-from-gradle-plugin.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/plugin/utils/get-project-graph-from-gradle-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,oBAAoB,EACpB,wBAAwB,EAExB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,mBAAmB,EAAoB,MAAM,yBAAyB,CAAC;AAIhF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE;QACL,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;KAClD,CAAC;IACF,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IACzD,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,IAAI,EAAE,MAAM,CAAC;CACd;AAiBD,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,QAgBb;AAOD,wBAAgB,4BAA4B,IAAI,kBAAkB,CAejE;AAED,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAG/C;AAED;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EAAE,EACtB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAyEf;AAED,wBAAgB,qBAAqB,CACnC,iBAAiB,EAAE,MAAM,EAAE,GAC1B,kBAAkB,CAkDpB"}
@@ -75,14 +75,25 @@ async function populateProjectGraph(workspaceRoot, gradlewFiles, options) {
75
75
  return;
76
76
  }
77
77
  const gradleProjectGraphReportStart = performance.mark('gradleProjectGraphReport:start');
78
- const projectGraphLines = await gradlewFiles.reduce(async (projectGraphLines, gradlewFile) => {
79
- const getNxProjectGraphLinesStart = performance.mark(`${gradlewFile}GetNxProjectGraphLines:start`);
80
- const allLines = await projectGraphLines;
81
- const currentLines = await (0, get_project_graph_lines_1.getNxProjectGraphLines)(gradlewFile, gradleConfigHash, normalizedOptions);
82
- const getNxProjectGraphLinesEnd = performance.mark(`${gradlewFile}GetNxProjectGraphLines:end`);
83
- performance.measure(`${gradlewFile}GetNxProjectGraphLines`, getNxProjectGraphLinesStart.name, getNxProjectGraphLinesEnd.name);
84
- return [...allLines, ...currentLines];
85
- }, Promise.resolve([]));
78
+ let projectGraphLines;
79
+ try {
80
+ projectGraphLines = await gradlewFiles.reduce(async (projectGraphLines, gradlewFile) => {
81
+ const getNxProjectGraphLinesStart = performance.mark(`${gradlewFile}GetNxProjectGraphLines:start`);
82
+ const allLines = await projectGraphLines;
83
+ const currentLines = await (0, get_project_graph_lines_1.getNxProjectGraphLines)(gradlewFile, gradleConfigHash, normalizedOptions);
84
+ const getNxProjectGraphLinesEnd = performance.mark(`${gradlewFile}GetNxProjectGraphLines:end`);
85
+ performance.measure(`${gradlewFile}GetNxProjectGraphLines`, getNxProjectGraphLinesStart.name, getNxProjectGraphLinesEnd.name);
86
+ return [...allLines, ...currentLines];
87
+ }, Promise.resolve([]));
88
+ }
89
+ catch (e) {
90
+ if (e instanceof Error &&
91
+ e.message === 'Gradle project graph generation was cancelled') {
92
+ // Cancelled by a newer populateProjectGraph call — silently return
93
+ return;
94
+ }
95
+ throw e;
96
+ }
86
97
  const gradleProjectGraphReportEnd = performance.mark('gradleProjectGraphReport:end');
87
98
  performance.measure('gradleProjectGraphReport', gradleProjectGraphReportStart.name, gradleProjectGraphReportEnd.name);
88
99
  projectGraphReportCache = processNxProjectGraph(projectGraphLines);
@@ -1,3 +1,9 @@
1
1
  import { GradlePluginOptions } from './gradle-plugin-options';
2
+ /**
3
+ * Cancel any in-flight Gradle project graph process.
4
+ * Safe to call even if nothing is running.
5
+ */
6
+ export declare function cancelPendingProjectGraphRequest(): void;
7
+ export declare function getGraphTimeoutMs(): number;
2
8
  export declare function getNxProjectGraphLines(gradlewFile: string, gradleConfigHash: string, gradlePluginOptions: GradlePluginOptions): Promise<string[]>;
3
9
  //# sourceMappingURL=get-project-graph-lines.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-project-graph-lines.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/plugin/utils/get-project-graph-lines.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,mBAAmB,EAAE,mBAAmB,GACvC,OAAO,CAAC,MAAM,EAAE,CAAC,CA0EnB"}
1
+ {"version":3,"file":"get-project-graph-lines.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/plugin/utils/get-project-graph-lines.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAM9D;;;GAGG;AACH,wBAAgB,gCAAgC,IAAI,IAAI,CAKvD;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAS1C;AAED,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,mBAAmB,EAAE,mBAAmB,GACvC,OAAO,CAAC,MAAM,EAAE,CAAC,CA6GnB"}