@nx/gradle 23.0.0-beta.2 → 23.0.0-beta.20

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.
package/migrations.json CHANGED
@@ -131,6 +131,12 @@
131
131
  "cli": "nx",
132
132
  "description": "Change dev.nx.gradle.project-graph to version 0.1.20 in build file",
133
133
  "factory": "./src/migrations/22-7-0/change-plugin-version-0-1-20"
134
+ },
135
+ "change-plugin-version-0-1-21": {
136
+ "version": "23.0.0-beta.11",
137
+ "cli": "nx",
138
+ "description": "Change dev.nx.gradle.project-graph to version 0.1.21 in build file",
139
+ "factory": "./src/migrations/23-0-0/change-plugin-version-0-1-21"
134
140
  }
135
141
  },
136
142
  "packageJsonUpdates": {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/gradle",
3
- "version": "23.0.0-beta.2",
3
+ "version": "23.0.0-beta.20",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Gradle allows Gradle tasks to be run through Nx",
6
6
  "repository": {
@@ -40,13 +40,13 @@
40
40
  "migrations": "./migrations.json"
41
41
  },
42
42
  "dependencies": {
43
- "@nx/devkit": "23.0.0-beta.2",
43
+ "@nx/devkit": "23.0.0-beta.20",
44
44
  "toml-eslint-parser": "^0.10.0",
45
45
  "tree-kill": "^1.2.2",
46
46
  "tslib": "^2.3.0"
47
47
  },
48
48
  "devDependencies": {
49
- "nx": "23.0.0-beta.2"
49
+ "nx": "23.0.0-beta.20"
50
50
  },
51
51
  "publishConfig": {
52
52
  "access": "public"
package/plugin-v1.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /** @deprecated Use `@nx/gradle` instead. This entry will be removed in Nx 24. */
1
2
  export { createDependencies } from './src/plugin-v1/dependencies';
3
+ /** @deprecated Use `@nx/gradle` instead. This entry will be removed in Nx 24. */
2
4
  export { createNodes, createNodesV2 } from './src/plugin-v1/nodes';
3
5
  //# sourceMappingURL=plugin-v1.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-v1.d.ts","sourceRoot":"","sources":["../../../packages/gradle/plugin-v1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"plugin-v1.d.ts","sourceRoot":"","sources":["../../../packages/gradle/plugin-v1.ts"],"names":[],"mappings":"AAoBA,iFAAiF;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,iFAAiF;AACjF,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
package/plugin-v1.js CHANGED
@@ -1,8 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNodesV2 = exports.createNodes = exports.createDependencies = void 0;
4
+ const internal_1 = require("@nx/devkit/internal");
5
+ // TODO(v24): remove `@nx/gradle/plugin-v1` entirely. Users should be migrated
6
+ // to `@nx/gradle` (the atomized v2 plugin) via the removal migration shipped
7
+ // alongside the deletion.
8
+ //
9
+ // Use emitPluginWorkerLog so the warning surfaces to the user even when the
10
+ // daemon is enabled — `logger.warn` would route to the daemon log file and
11
+ // be silently swallowed. Guard against older nx versions (< 22.7) where this
12
+ // helper may not exist; @nx/devkit supports nx at +/-1 major.
13
+ if (typeof internal_1.emitPluginWorkerLog === 'function') {
14
+ (0, internal_1.emitPluginWorkerLog)('warn', '`@nx/gradle/plugin-v1` is deprecated and will be removed in Nx 24. ' +
15
+ 'Switch your `nx.json` plugins entry from `@nx/gradle/plugin-v1` to `@nx/gradle`. ' +
16
+ 'Note that the default `@nx/gradle` plugin generates atomized targets — ' +
17
+ 'see https://nx.dev/nx-api/gradle for configuration options.');
18
+ }
19
+ /** @deprecated Use `@nx/gradle` instead. This entry will be removed in Nx 24. */
4
20
  var dependencies_1 = require("./src/plugin-v1/dependencies");
5
21
  Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return dependencies_1.createDependencies; } });
22
+ /** @deprecated Use `@nx/gradle` instead. This entry will be removed in Nx 24. */
6
23
  var nodes_1 = require("./src/plugin-v1/nodes");
7
24
  Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return nodes_1.createNodes; } });
8
25
  Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return nodes_1.createNodesV2; } });
package/plugin.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export declare const name: string;
2
- export declare const createNodesV2: import("packages/devkit").CreateNodesV2<import("./src/plugin/utils/gradle-plugin-options").GradlePluginOptions>;
3
- export declare const createNodes: import("packages/devkit").CreateNodesV2<import("./src/plugin/utils/gradle-plugin-options").GradlePluginOptions>;
4
- export declare const createDependencies: import("packages/devkit").CreateDependencies<import("./src/plugin/utils/gradle-plugin-options").GradlePluginOptions>;
2
+ export declare const createNodesV2: import("packages/devkit/dist").CreateNodesV2<import("./src/plugin/utils/gradle-plugin-options").GradlePluginOptions>;
3
+ export declare const createNodes: import("packages/devkit/dist").CreateNodesV2<import("./src/plugin/utils/gradle-plugin-options").GradlePluginOptions>;
4
+ export declare const createDependencies: import("packages/devkit/dist").CreateDependencies<import("./src/plugin/utils/gradle-plugin-options").GradlePluginOptions>;
5
5
  //# sourceMappingURL=plugin.d.ts.map
package/plugin.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../packages/gradle/plugin.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,IAAI,QAAsD,CAAC;AACxE,eAAO,MAAM,aAAa,iHAA0C,CAAC;AACrE,eAAO,MAAM,WAAW,iHAAgB,CAAC;AACzC,eAAO,MAAM,kBAAkB,sHAA+C,CAAC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../packages/gradle/plugin.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,IAAI,QAAsD,CAAC;AACxE,eAAO,MAAM,aAAa,sHAA0C,CAAC;AACrE,eAAO,MAAM,WAAW,sHAAgB,CAAC;AACzC,eAAO,MAAM,kBAAkB,2HAA+C,CAAC"}
@@ -1,9 +1,12 @@
1
1
  import { ExecutorContext, ProjectGraphProjectNode, TaskGraph } from '@nx/devkit';
2
2
  import { RunCommandsOptions } from 'nx/src/executors/run-commands/run-commands.impl';
3
- import { BatchResults } from 'nx/src/tasks-runner/batch/batch-messages';
3
+ import { TaskResult } from 'nx/src/config/misc-interfaces';
4
4
  import { GradleExecutorSchema } from './schema';
5
5
  export declare const batchRunnerPath: string;
6
- export default function gradleBatch(taskGraph: TaskGraph, inputs: Record<string, GradleExecutorSchema>, overrides: RunCommandsOptions, context: ExecutorContext): Promise<BatchResults>;
6
+ export default function gradleBatch(taskGraph: TaskGraph, inputs: Record<string, GradleExecutorSchema>, overrides: RunCommandsOptions, context: ExecutorContext): AsyncGenerator<{
7
+ task: string;
8
+ result: TaskResult;
9
+ }>;
7
10
  export declare function getGradlewTasksToRun(taskIds: string[], taskGraph: TaskGraph, inputs: Record<string, GradleExecutorSchema>, nodes: Record<string, ProjectGraphProjectNode>, fullTaskGraph?: TaskGraph): {
8
11
  gradlewTasksToRun: Record<string, GradleExecutorSchema>;
9
12
  excludeTasks: Set<string>;
@@ -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;AAahD,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,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,EAC9C,aAAa,GAAE,SAAqB;;;;EA0DrC"}
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,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAahD,eAAO,MAAM,eAAe,QAG3B,CAAC;AAEF,wBAA+B,WAAW,CACxC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,EAC5C,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,eAAe,GACvB,cAAc,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,CAkEtD;AAED,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,EAC9C,aAAa,GAAE,SAAqB;;;;EA0DrC"}
@@ -7,47 +7,49 @@ const devkit_1 = require("@nx/devkit");
7
7
  const exec_gradle_1 = require("../../utils/exec-gradle");
8
8
  const path_1 = require("path");
9
9
  const child_process_1 = require("child_process");
10
+ const readline_1 = require("readline");
10
11
  const get_exclude_task_1 = require("./get-exclude-task");
11
12
  exports.batchRunnerPath = (0, path_1.join)(__dirname, '../../../batch-runner/build/libs/gradle-batch-runner-all.jar');
12
- async function gradleBatch(taskGraph, inputs, overrides, context) {
13
+ async function* gradleBatch(taskGraph, inputs, overrides, context) {
14
+ const projectName = taskGraph.tasks[taskGraph.roots[0]]?.target?.project;
15
+ const projectRoot = context.projectGraph.nodes[projectName]?.data?.root ?? '';
16
+ const customGradleExecutableDirectory = (0, exec_gradle_1.getCustomGradleExecutableDirectoryFromPlugin)(context.nxJsonConfiguration);
17
+ let gradlewPath = (0, exec_gradle_1.findGradlewFile)((0, path_1.join)(projectRoot, 'project.json'), devkit_1.workspaceRoot, customGradleExecutableDirectory);
18
+ gradlewPath = (0, path_1.join)(context.root, gradlewPath);
19
+ const root = (0, path_1.dirname)(gradlewPath);
20
+ // set args with passed in args and overrides in command line
21
+ const input = inputs[taskGraph.roots[0]];
22
+ const args = typeof input.args === 'string'
23
+ ? input.args.trim().split(' ')
24
+ : Array.isArray(input.args)
25
+ ? input.args
26
+ : [];
27
+ if (overrides.__overrides_unparsed__.length) {
28
+ args.push(...overrides.__overrides_unparsed__);
29
+ }
30
+ const taskIds = Object.keys(taskGraph.tasks);
31
+ const { gradlewTasksToRun, excludeTasks, excludeTestTasks } = getGradlewTasksToRun(taskIds, taskGraph, inputs, context.projectGraph.nodes, context.taskGraph ?? taskGraph);
32
+ const yielded = new Set();
13
33
  try {
14
- const projectName = taskGraph.tasks[taskGraph.roots[0]]?.target?.project;
15
- let projectRoot = context.projectGraph.nodes[projectName]?.data?.root ?? '';
16
- const customGradleExecutableDirectory = (0, exec_gradle_1.getCustomGradleExecutableDirectoryFromPlugin)(context.nxJsonConfiguration);
17
- let gradlewPath = (0, exec_gradle_1.findGradlewFile)((0, path_1.join)(projectRoot, 'project.json'), devkit_1.workspaceRoot, customGradleExecutableDirectory);
18
- gradlewPath = (0, path_1.join)(context.root, gradlewPath);
19
- const root = (0, path_1.dirname)(gradlewPath);
20
- const input = inputs[taskGraph.roots[0]];
21
- let args = typeof input.args === 'string'
22
- ? input.args.trim().split(' ')
23
- : Array.isArray(input.args)
24
- ? input.args
25
- : [];
26
- if (overrides.__overrides_unparsed__.length) {
27
- args.push(...overrides.__overrides_unparsed__);
34
+ for await (const event of streamTasksInBatch(gradlewTasksToRun, excludeTasks, excludeTestTasks, args, root)) {
35
+ yielded.add(event.task);
36
+ yield event;
28
37
  }
29
- const taskIds = Object.keys(taskGraph.tasks);
30
- const { gradlewTasksToRun, excludeTasks, excludeTestTasks } = getGradlewTasksToRun(taskIds, taskGraph, inputs, context.projectGraph.nodes, context.taskGraph ?? taskGraph);
31
- const batchResults = await runTasksInBatch(gradlewTasksToRun, excludeTasks, excludeTestTasks, args, root);
32
- taskIds.forEach((taskId) => {
33
- if (!batchResults[taskId]) {
34
- batchResults[taskId] = {
35
- success: false,
36
- terminalOutput: `Gradlew batch failed`,
37
- };
38
- }
39
- });
40
- return batchResults;
41
38
  }
42
39
  catch (e) {
43
40
  devkit_1.output.error({
44
41
  title: `Gradlew batch failed`,
45
42
  bodyLines: [e.toString()],
46
43
  });
47
- return taskGraph.roots.reduce((acc, key) => {
48
- acc[key] = { success: false, terminalOutput: e.toString() };
49
- return acc;
50
- }, {});
44
+ for (const taskId of taskIds) {
45
+ if (!yielded.has(taskId)) {
46
+ yielded.add(taskId);
47
+ yield {
48
+ task: taskId,
49
+ result: { success: false, terminalOutput: e.toString() },
50
+ };
51
+ }
52
+ }
51
53
  }
52
54
  }
53
55
  function getGradlewTasksToRun(taskIds, taskGraph, inputs, nodes, fullTaskGraph = taskGraph) {
@@ -88,7 +90,7 @@ function getGradlewTasksToRun(taskIds, taskGraph, inputs, nodes, fullTaskGraph =
88
90
  excludeTestTasks,
89
91
  };
90
92
  }
91
- async function runTasksInBatch(gradlewTasksToRun, excludeTasks, excludeTestTasks, args, root) {
93
+ async function* streamTasksInBatch(gradlewTasksToRun, excludeTasks, excludeTestTasks, args, root) {
92
94
  const gradlewBatchStart = performance.mark(`gradlew-batch:start`);
93
95
  const debugOptions = (process.env.NX_GRADLE_BATCH_DEBUG ?? '').trim();
94
96
  const spawnArgs = [
@@ -102,30 +104,74 @@ async function runTasksInBatch(gradlewTasksToRun, excludeTasks, excludeTestTasks
102
104
  `--excludeTestTasks=${Array.from(excludeTestTasks).join(',')}`,
103
105
  ...(process.env.NX_VERBOSE_LOGGING === 'true' ? [] : ['--quiet']),
104
106
  ];
105
- // Use 'inherit' for stderr so Gradle output (tee'd to System.err
106
- // by TeeOutputStream) flows to the terminal in real-time.
107
- // stdout is piped to capture the JSON batch results.
108
- const batchResults = await new Promise((resolve, reject) => {
109
- const cp = (0, child_process_1.spawn)('java', spawnArgs, {
110
- cwd: devkit_1.workspaceRoot,
111
- windowsHide: true,
112
- env: process.env,
113
- stdio: ['pipe', 'pipe', 'inherit'],
114
- });
115
- const chunks = [];
116
- cp.stdout.on('data', (chunk) => chunks.push(chunk));
107
+ // stderr is inherited so Gradle output (tee'd to System.err by TeeOutputStream)
108
+ // and logger output flow to the terminal in real-time.
109
+ // stdout is piped so we can read NX_RESULT lines emitted per task.
110
+ const cp = (0, child_process_1.spawn)('java', spawnArgs, {
111
+ cwd: devkit_1.workspaceRoot,
112
+ windowsHide: true,
113
+ env: process.env,
114
+ stdio: ['pipe', 'pipe', 'inherit'],
115
+ });
116
+ const exit = new Promise((resolve, reject) => {
117
117
  cp.on('error', reject);
118
- cp.on('close', (code) => {
119
- if (code !== 0) {
120
- reject(new Error(`Gradle batch runner exited with code ${code}`));
118
+ cp.on('close', (code) => resolve(code ?? 0));
119
+ });
120
+ const rl = (0, readline_1.createInterface)({ input: cp.stdout, crlfDelay: Infinity });
121
+ // Drain stdout into a queue eagerly. Yielding inside the readline loop creates
122
+ // back-pressure: if the consumer is slow, `yield` blocks, readline pauses, the
123
+ // OS pipe between Java and Node fills, and Java's NX_RESULT println blocks on
124
+ // a full pipe — the JVM hangs even though all task work is done.
125
+ const queue = [];
126
+ let notifyAvailable = null;
127
+ let readerClosed = false;
128
+ rl.on('line', (line) => {
129
+ if (!line.startsWith('NX_RESULT:'))
130
+ return;
131
+ try {
132
+ const data = JSON.parse(line.slice('NX_RESULT:'.length));
133
+ queue.push({
134
+ task: data.task,
135
+ result: {
136
+ success: data.result.success ?? false,
137
+ status: data.result.status,
138
+ terminalOutput: data.result.terminalOutput ?? '',
139
+ startTime: data.result.startTime,
140
+ endTime: data.result.endTime,
141
+ },
142
+ });
143
+ }
144
+ catch (e) {
145
+ console.error('[Gradle Batch] Failed to parse result line:', line, e);
146
+ return;
147
+ }
148
+ notifyAvailable?.();
149
+ notifyAvailable = null;
150
+ });
151
+ rl.on('close', () => {
152
+ readerClosed = true;
153
+ notifyAvailable?.();
154
+ notifyAvailable = null;
155
+ });
156
+ try {
157
+ while (!readerClosed || queue.length > 0) {
158
+ if (queue.length > 0) {
159
+ yield queue.shift();
121
160
  }
122
161
  else {
123
- resolve(Buffer.concat(chunks).toString());
162
+ await new Promise((resolve) => {
163
+ notifyAvailable = resolve;
164
+ });
124
165
  }
125
- });
126
- });
166
+ }
167
+ }
168
+ finally {
169
+ rl.close();
170
+ }
171
+ const code = await exit;
127
172
  const gradlewBatchEnd = performance.mark(`gradlew-batch:end`);
128
173
  performance.measure(`gradlew-batch`, gradlewBatchStart.name, gradlewBatchEnd.name);
129
- const gradlewBatchResults = JSON.parse(batchResults);
130
- return gradlewBatchResults;
174
+ if (code !== 0) {
175
+ throw new Error(`Gradle batch runner exited with code ${code}`);
176
+ }
131
177
  }
@@ -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-21.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"change-plugin-version-0-1-21.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/migrations/23-0-0/change-plugin-version-0-1-21.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.21
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.21';
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
+ }
@@ -2,7 +2,7 @@ import { CreateNodesV2, CreateNodesContextV2, ProjectConfiguration, ProjectGraph
2
2
  import { GradlePluginOptions } from './utils/gradle-plugin-options';
3
3
  type GradleTargets = Record<string, Partial<ProjectConfiguration>>;
4
4
  export declare const createNodesV2: CreateNodesV2<GradlePluginOptions>;
5
- export declare const makeCreateNodesForGradleConfigFile: (projects: Record<string, Partial<ProjectConfiguration>>, projectsCache?: GradleTargets, externalNodes?: Record<string, ProjectGraphExternalNode>) => (gradleFilePath: any, options: GradlePluginOptions | undefined, context: CreateNodesContextV2) => Promise<{
5
+ export declare const makeCreateNodesForGradleConfigFile: (projects: Record<string, Partial<ProjectConfiguration>>, projectsCache?: GradleTargets, externalNodes?: Record<string, ProjectGraphExternalNode>, hashes?: string[]) => (gradleFilePath: any, options: GradlePluginOptions | undefined, context: CreateNodesContextV2, idx?: number) => Promise<{
6
6
  projects?: undefined;
7
7
  externalNodes?: undefined;
8
8
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/plugin/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EAEpB,wBAAwB,EAEzB,MAAM,YAAY,CAAC;AAepB,OAAO,EACL,mBAAmB,EAEpB,MAAM,+BAA+B,CAAC;AAEvC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAgFnE,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,mBAAmB,CA0F5D,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAE3C,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,EACvD,gBAAe,aAAkB,EACjC,gBAAe,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAM,MAG5D,mBAAc,EACd,SAAS,mBAAmB,GAAG,SAAS,EACxC,SAAS,oBAAoB;;;;;;;;EAyB9B,CAAC"}
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/plugin/nodes.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EAEpB,wBAAwB,EAEzB,MAAM,YAAY,CAAC;AAcpB,OAAO,EACL,mBAAmB,EAEpB,MAAM,+BAA+B,CAAC;AAEvC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAgFnE,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,mBAAmB,CA8F5D,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAE3C,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,EACvD,gBAAe,aAAkB,EACjC,gBAAe,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAM,EAC5D,SAAS,MAAM,EAAE,MAGjB,mBAAc,EACd,SAAS,mBAAmB,GAAG,SAAS,EACxC,SAAS,oBAAoB,EAC7B,MAAM,MAAM;;;;;;;;EAyCb,CAAC"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeCreateNodesForGradleConfigFile = exports.createNodesV2 = void 0;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
6
6
  const node_path_1 = require("node:path");
7
7
  const cache_directory_1 = require("nx/src/utils/cache-directory");
8
8
  const plugin_cache_utils_1 = require("nx/src/utils/plugin-cache-utils");
@@ -82,9 +82,12 @@ exports.createNodesV2 = [
82
82
  try {
83
83
  const results = [];
84
84
  const normalizedOptions = (0, gradle_plugin_options_1.normalizeOptions)(options);
85
- for (const gradleFilePath of allBuildFiles) {
86
- const projectRoot = (0, node_path_1.dirname)(gradleFilePath);
87
- const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, normalizedOptions ?? {}, context);
85
+ const buildFileProjectRoots = allBuildFiles.map((f) => (0, node_path_1.dirname)(f));
86
+ const buildFileHashes = await (0, internal_1.calculateHashesForCreateNodes)(buildFileProjectRoots, normalizedOptions ?? {}, context);
87
+ for (let i = 0; i < allBuildFiles.length; i++) {
88
+ const gradleFilePath = allBuildFiles[i];
89
+ const projectRoot = buildFileProjectRoots[i];
90
+ const hash = buildFileHashes[i];
88
91
  // Get project from cache or nodes
89
92
  if (!pluginCache.has(hash)) {
90
93
  const nodeProject = nodes[projectRoot] ?? nodes[(0, node_path_1.join)(devkit_1.workspaceRoot, projectRoot)];
@@ -126,14 +129,27 @@ exports.createNodesV2 = [
126
129
  return results;
127
130
  }
128
131
  finally {
129
- pluginCache.writeToDisk(cachePath);
132
+ pluginCache.writeToDisk();
130
133
  }
131
134
  },
132
135
  ];
133
- const makeCreateNodesForGradleConfigFile = (projects, projectsCache = {}, externalNodes = {}) => async (gradleFilePath, options, context) => {
136
+ const makeCreateNodesForGradleConfigFile = (projects, projectsCache = {}, externalNodes = {}, hashes) => async (gradleFilePath, options, context, idx) => {
134
137
  const projectRoot = (0, node_path_1.dirname)(gradleFilePath);
135
138
  options = (0, gradle_plugin_options_1.normalizeOptions)(options);
136
- const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options ?? {}, context);
139
+ let hash;
140
+ if (hashes && idx !== undefined) {
141
+ hash = hashes[idx];
142
+ if (hash === undefined) {
143
+ throw new Error(`Failed to compute hash for gradle project at ${projectRoot}`);
144
+ }
145
+ }
146
+ else {
147
+ const [computed] = await (0, internal_1.calculateHashesForCreateNodes)([projectRoot], options ?? {}, context);
148
+ if (computed === undefined) {
149
+ throw new Error(`Failed to compute hash for gradle project at ${projectRoot}`);
150
+ }
151
+ hash = computed;
152
+ }
137
153
  projectsCache[hash] ??=
138
154
  projects[projectRoot] ?? projects[(0, node_path_1.join)(devkit_1.workspaceRoot, projectRoot)];
139
155
  const project = projectsCache[hash];
@@ -1,3 +1,7 @@
1
1
  import { CreateDependencies } from '@nx/devkit';
2
+ /**
3
+ * @deprecated The `@nx/gradle/plugin-v1` entry is deprecated and will be removed in Nx 24.
4
+ * Switch to the default `@nx/gradle` plugin.
5
+ */
2
6
  export declare const createDependencies: CreateDependencies;
3
7
  //# sourceMappingURL=dependencies.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/plugin-v1/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAMnB,MAAM,YAAY,CAAC;AAMpB,eAAO,MAAM,kBAAkB,EAAE,kBAoEhC,CAAC"}
1
+ {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/plugin-v1/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAMnB,MAAM,YAAY,CAAC;AAMpB;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAoEhC,CAAC"}
@@ -5,6 +5,10 @@ const devkit_1 = require("@nx/devkit");
5
5
  const node_path_1 = require("node:path");
6
6
  const get_gradle_report_1 = require("./utils/get-gradle-report");
7
7
  const split_config_files_1 = require("../utils/split-config-files");
8
+ /**
9
+ * @deprecated The `@nx/gradle/plugin-v1` entry is deprecated and will be removed in Nx 24.
10
+ * Switch to the default `@nx/gradle` plugin.
11
+ */
8
12
  const createDependencies = async (_, context) => {
9
13
  const gradleFiles = findGradleFiles(context.filesToProcess);
10
14
  if (gradleFiles.length === 0) {
@@ -9,8 +9,12 @@ export interface GradlePluginOptions {
9
9
  buildTargetName?: string;
10
10
  [taskTargetName: string]: string | undefined | boolean;
11
11
  }
12
+ /**
13
+ * @deprecated The `@nx/gradle/plugin-v1` entry is deprecated and will be removed in Nx 24.
14
+ * Switch to the default `@nx/gradle` plugin.
15
+ */
12
16
  export declare const createNodesV2: CreateNodesV2<GradlePluginOptions>;
13
- export declare const makeCreateNodesForGradleConfigFile: (gradleReport: GradleReport, pluginCache?: PluginCache<Partial<ProjectConfiguration>>, gradleProjectRootToTestFilesMap?: Record<string, string[]>) => (gradleFilePath: any, options: GradlePluginOptions | undefined, context: CreateNodesContextV2) => Promise<{
17
+ export declare const makeCreateNodesForGradleConfigFile: (gradleReport: GradleReport, pluginCache: PluginCache<Partial<ProjectConfiguration>>, gradleProjectRootToTestFilesMap?: Record<string, string[]>, hashes?: string[]) => (gradleFilePath: any, options: GradlePluginOptions | undefined, context: CreateNodesContextV2, idx?: number) => Promise<{
14
18
  projects?: undefined;
15
19
  } | {
16
20
  projects: {
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/plugin-v1/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EAGrB,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,OAAO,EAGL,YAAY,EACb,MAAM,2BAA2B,CAAC;AAsBnC,MAAM,WAAW,mBAAmB;IAClC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;CACxD;AAYD,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,mBAAmB,CAuC5D,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAE3C,cAAc,YAAY,EAC1B,cAAa,WAAW,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAqB,EAC3E,kCAAiC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAM,MAG9D,mBAAc,EACd,SAAS,mBAAmB,GAAG,SAAS,EACxC,SAAS,oBAAoB;;;;;;EA+B9B,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,WAAW,oCAAgB,CAAC"}
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/plugin-v1/nodes.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EAGrB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,OAAO,EAGL,YAAY,EACb,MAAM,2BAA2B,CAAC;AAsBnC,MAAM,WAAW,mBAAmB;IAClC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;CACxD;AAYD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,mBAAmB,CA8C5D,CAAC;AAEF,eAAO,MAAM,kCAAkC,GAE3C,cAAc,YAAY,EAC1B,aAAa,WAAW,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,EACvD,kCAAiC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAM,EAC9D,SAAS,MAAM,EAAE,MAGjB,mBAAc,EACd,SAAS,mBAAmB,GAAG,SAAS,EACxC,SAAS,oBAAoB,EAC7B,MAAM,MAAM;;;;;;EAgDb,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,WAAW,oCAAgB,CAAC"}
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNodes = exports.makeCreateNodesForGradleConfigFile = exports.createNodesV2 = void 0;
4
+ const internal_1 = require("@nx/devkit/internal");
4
5
  const devkit_1 = require("@nx/devkit");
5
- const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
6
6
  const node_path_1 = require("node:path");
7
7
  const cache_directory_1 = require("nx/src/utils/cache-directory");
8
8
  const plugin_cache_utils_1 = require("nx/src/utils/plugin-cache-utils");
@@ -25,6 +25,10 @@ function normalizeOptions(options) {
25
25
  options.buildTargetName ??= 'build';
26
26
  return options;
27
27
  }
28
+ /**
29
+ * @deprecated The `@nx/gradle/plugin-v1` entry is deprecated and will be removed in Nx 24.
30
+ * Switch to the default `@nx/gradle` plugin.
31
+ */
28
32
  exports.createNodesV2 = [
29
33
  split_config_files_1.gradleConfigAndTestGlob,
30
34
  async (files, options, context) => {
@@ -36,17 +40,32 @@ exports.createNodesV2 = [
36
40
  const gradleReport = (0, get_gradle_report_1.getCurrentGradleReport)();
37
41
  const gradleProjectRootToTestFilesMap = getGradleProjectRootToTestFilesMap(testFiles, projectRoots);
38
42
  try {
39
- return (0, devkit_1.createNodesFromFiles)((0, exports.makeCreateNodesForGradleConfigFile)(gradleReport, pluginCache, gradleProjectRootToTestFilesMap), buildFiles, options, context);
43
+ const buildFileProjectRoots = buildFiles.map((f) => (0, node_path_1.dirname)(f));
44
+ const buildFileHashes = await (0, internal_1.calculateHashesForCreateNodes)(buildFileProjectRoots, normalizeOptions(options) ?? {}, context);
45
+ return (0, devkit_1.createNodesFromFiles)((0, exports.makeCreateNodesForGradleConfigFile)(gradleReport, pluginCache, gradleProjectRootToTestFilesMap, buildFileHashes), buildFiles, options, context);
40
46
  }
41
47
  finally {
42
- pluginCache.writeToDisk(cachePath);
48
+ pluginCache.writeToDisk();
43
49
  }
44
50
  },
45
51
  ];
46
- const makeCreateNodesForGradleConfigFile = (gradleReport, pluginCache = new plugin_cache_utils_1.PluginCache(), gradleProjectRootToTestFilesMap = {}) => async (gradleFilePath, options, context) => {
52
+ const makeCreateNodesForGradleConfigFile = (gradleReport, pluginCache, gradleProjectRootToTestFilesMap = {}, hashes) => async (gradleFilePath, options, context, idx) => {
47
53
  const projectRoot = (0, node_path_1.dirname)(gradleFilePath);
48
54
  options = normalizeOptions(options);
49
- const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options ?? {}, context);
55
+ let hash;
56
+ if (hashes && idx !== undefined) {
57
+ hash = hashes[idx];
58
+ if (hash === undefined) {
59
+ throw new Error(`Failed to compute hash for gradle project at ${projectRoot}`);
60
+ }
61
+ }
62
+ else {
63
+ const [computed] = await (0, internal_1.calculateHashesForCreateNodes)([projectRoot], options ?? {}, context);
64
+ if (computed === undefined) {
65
+ throw new Error(`Failed to compute hash for gradle project at ${projectRoot}`);
66
+ }
67
+ hash = computed;
68
+ }
50
69
  if (!pluginCache.has(hash)) {
51
70
  pluginCache.set(hash, await createGradleProject(gradleReport, gradleFilePath, options, context, gradleProjectRootToTestFilesMap[projectRoot]));
52
71
  }
@@ -206,7 +225,6 @@ function getTestCiTargets(testFiles, gradleProject, testTargetName, ciTargetName
206
225
  targetGroups[targetGroupName].push(targetName);
207
226
  dependsOn.push({
208
227
  target: targetName,
209
- projects: 'self',
210
228
  params: 'forward',
211
229
  });
212
230
  });
@@ -1,4 +1,4 @@
1
1
  export declare const nxVersion: any;
2
2
  export declare const gradleProjectGraphPluginName = "dev.nx.gradle.project-graph";
3
- export declare const gradleProjectGraphVersion = "0.1.20";
3
+ export declare const gradleProjectGraphVersion = "0.1.21";
4
4
  //# sourceMappingURL=versions.d.ts.map
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.gradleProjectGraphVersion = exports.gradleProjectGraphPluginName = exports.nxVersion = void 0;
4
4
  exports.nxVersion = require('../../package.json').version;
5
5
  exports.gradleProjectGraphPluginName = 'dev.nx.gradle.project-graph';
6
- exports.gradleProjectGraphVersion = '0.1.20';
6
+ exports.gradleProjectGraphVersion = '0.1.21';