@nx/gradle 22.1.0-canary.20251023-59cf495 → 22.1.0-canary.20251024-7712d2a

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.
@@ -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,CA2DvB;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;;;;EAoD/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,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;AAkBhD,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;;;;EAoD/C"}
@@ -15,7 +15,8 @@ async function gradleBatch(taskGraph, inputs, overrides, context) {
15
15
  try {
16
16
  const projectName = taskGraph.tasks[taskGraph.roots[0]]?.target?.project;
17
17
  let projectRoot = context.projectGraph.nodes[projectName]?.data?.root ?? '';
18
- let gradlewPath = (0, exec_gradle_1.findGradlewFile)((0, path_1.join)(projectRoot, 'project.json')); // find gradlew near project root
18
+ const customGradleExecutableDirectory = (0, exec_gradle_1.getCustomGradleExecutableDirectoryFromPlugin)(context.nxJsonConfiguration);
19
+ let gradlewPath = (0, exec_gradle_1.findGradlewFile)((0, path_1.join)(projectRoot, 'project.json'), devkit_1.workspaceRoot, customGradleExecutableDirectory); // find gradlew near project root
19
20
  gradlewPath = (0, path_1.join)(context.root, gradlewPath);
20
21
  const root = (0, path_1.dirname)(gradlewPath);
21
22
  // set args with passed in args and overrides in command line
@@ -1 +1 @@
1
- {"version":3,"file":"gradle.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/executors/gradle/gradle.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAMhD,wBAA8B,cAAc,CAC1C,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA6D/B"}
1
+ {"version":3,"file":"gradle.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/executors/gradle/gradle.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAiB,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAShD,wBAA8B,cAAc,CAC1C,OAAO,EAAE,oBAAoB,EAC7B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAoE/B"}
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = gradleExecutor;
4
+ const devkit_1 = require("@nx/devkit");
4
5
  const exec_gradle_1 = require("../../utils/exec-gradle");
5
6
  const node_path_1 = require("node:path");
6
7
  const run_commands_impl_1 = require("nx/src/executors/run-commands/run-commands.impl");
7
8
  const get_exclude_task_1 = require("./get-exclude-task");
8
9
  async function gradleExecutor(options, context) {
9
10
  let projectRoot = context.projectGraph.nodes[context.projectName]?.data?.root ?? context.root;
10
- let gradlewPath = (0, exec_gradle_1.findGradlewFile)((0, node_path_1.join)(projectRoot, 'project.json')); // find gradlew near project root
11
+ const customGradleExecutableDirectory = (0, exec_gradle_1.getCustomGradleExecutableDirectoryFromPlugin)(context.nxJsonConfiguration);
12
+ let gradlewPath = (0, exec_gradle_1.findGradlewFile)((0, node_path_1.join)(projectRoot, 'project.json'), devkit_1.workspaceRoot, customGradleExecutableDirectory); // find gradlew near project root
11
13
  gradlewPath = (0, node_path_1.join)(context.root, gradlewPath);
12
14
  let args = typeof options.args === 'string'
13
15
  ? options.args.trim().split(' ')
@@ -1 +1 @@
1
- {"version":3,"file":"gradle-project-graph-plugin-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/generators/init/gradle-project-graph-plugin-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,IAAI,EAAiB,MAAM,YAAY,CAAC;AAQpE;;;GAGG;AACH,wBAAsB,sCAAsC,CAC1D,IAAI,EAAE,IAAI,GACT,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CASlD;AA8BD;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgBxB;AAkBD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,MAAM,CASR;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,eAAe,GAAE,MAAkC,iBAYpD"}
1
+ {"version":3,"file":"gradle-project-graph-plugin-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/generators/init/gradle-project-graph-plugin-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,IAAI,EAAiB,MAAM,YAAY,CAAC;AAQpE;;;GAGG;AACH,wBAAsB,sCAAsC,CAC1D,IAAI,EAAE,IAAI,GACT,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CASlD;AA8BD;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAoBxB;AAkBD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,GACjB,MAAM,CASR;AAED;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,eAAe,GAAE,MAAkC,iBAYpD"}
@@ -47,7 +47,7 @@ async function extractNxPluginVersion(gradleFilePath, gradleContent) {
47
47
  let version = match ? match[2] : null;
48
48
  if (!version) {
49
49
  try {
50
- const gradlewFile = (0, exec_gradle_1.findGradlewFile)(gradleFilePath, devkit_1.workspaceRoot);
50
+ const gradlewFile = (0, exec_gradle_1.findGradlewFile)(gradleFilePath, devkit_1.workspaceRoot, undefined);
51
51
  const buildEnvironment = (await (0, exec_gradle_1.execGradleAsync)((0, path_1.join)(devkit_1.workspaceRoot, gradlewFile), [
52
52
  'buildEnvironment',
53
53
  '--quiet',
@@ -21,6 +21,7 @@ export declare function getCurrentBuildFiles(): string[];
21
21
  * It will accumulate the output of all gradlew files.
22
22
  * @param workspaceRoot
23
23
  * @param gradlewFiles absolute paths to all gradlew files in the workspace
24
+ * @param options user specified gradle plugin options
24
25
  * @returns Promise<void>
25
26
  */
26
27
  export declare function populateProjectGraph(workspaceRoot: string, gradlewFiles: string[], options: GradlePluginOptions): Promise<void>;
@@ -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,EAGL,oBAAoB,EACpB,wBAAwB,EAExB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAI9D,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,QAQ5B;AASD,wBAAgB,4BAA4B,IAAI,kBAAkB,CAejE;AAED,wBAAgB,oBAAoB,IAAI,MAAM,EAAE,CAG/C;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EAAE,EACtB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CA8Df;AAED,wBAAgB,qBAAqB,CACnC,iBAAiB,EAAE,MAAM,EAAE,GAC1B,kBAAkB,CAiDpB"}
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,EAGL,oBAAoB,EACpB,wBAAwB,EAExB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAI9D,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,QAQ5B;AASD,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,CA8Df;AAED,wBAAgB,qBAAqB,CACnC,iBAAiB,EAAE,MAAM,EAAE,GAC1B,kBAAkB,CAiDpB"}
@@ -54,6 +54,7 @@ function getCurrentBuildFiles() {
54
54
  * It will accumulate the output of all gradlew files.
55
55
  * @param workspaceRoot
56
56
  * @param gradlewFiles absolute paths to all gradlew files in the workspace
57
+ * @param options user specified gradle plugin options
57
58
  * @returns Promise<void>
58
59
  */
59
60
  async function populateProjectGraph(workspaceRoot, gradlewFiles, options) {
@@ -1,6 +1,7 @@
1
1
  export interface GradlePluginOptions {
2
2
  testTargetName?: string;
3
3
  ciTestTargetName?: string;
4
+ gradleExecutableDirectory?: string;
4
5
  [taskTargetName: string]: string | undefined | boolean;
5
6
  }
6
7
  export declare function normalizeOptions(options: GradlePluginOptions): GradlePluginOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"gradle-plugin-options.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/plugin/utils/gradle-plugin-options.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;CACxD;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,mBAAmB,GAC3B,mBAAmB,CAIrB"}
1
+ {"version":3,"file":"gradle-plugin-options.d.ts","sourceRoot":"","sources":["../../../../../../packages/gradle/src/plugin/utils/gradle-plugin-options.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;CACxD;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,mBAAmB,GAC3B,mBAAmB,CAIrB"}
@@ -1,3 +1,4 @@
1
+ import { NxJsonConfiguration } from '@nx/devkit';
1
2
  import { ExecFileOptions } from 'node:child_process';
2
3
  export declare const fileSeparator: string;
3
4
  export declare const newLineSeparator: string;
@@ -14,13 +15,16 @@ export declare function getGradleExecFile(): string;
14
15
  * @returns promise with the stdout buffer
15
16
  */
16
17
  export declare function execGradleAsync(gradleBinaryPath: string, args: ReadonlyArray<string>, execOptions?: ExecFileOptions): Promise<Buffer>;
18
+ export declare function getCustomGradleExecutableDirectoryFromPlugin(nxJson: NxJsonConfiguration): string | undefined;
17
19
  /**
18
20
  * This function recursively finds the nearest gradlew file in the workspace
19
- * @param originalFileToSearch the original file to search for, relative to workspace root, file path not directory path
20
- * @param wr workspace root
21
- * @param currentSearchPath the path to start searching for gradlew file
21
+ * @param filePathToSearch the original file to search for, relative to workspace root, file path not directory path
22
+ * @param workspaceRoot workspace root
23
+ * @param customExecutableDirectory a custom directory to search for the gradle wrapper file
22
24
  * @returns the relative path of the gradlew file to workspace root, throws an error if gradlew file is not found
23
25
  * It will return relative path to workspace root of gradlew.bat file on windows and gradlew file on other platforms
24
26
  */
25
- export declare function findGradlewFile(originalFileToSearch: string, wr?: string, currentSearchPath?: string): string;
27
+ export declare function findGradlewFile(filePathToSearch: string, workspaceRoot: string, customExecutableDirectory?: string): string;
28
+ export declare function findGradlewUsingFilePathTraversal(filePathToSearch: string, workspaceRoot: string, currentSearchPath?: string): string;
29
+ export declare function findGradlewUsingCustomExecutableDirectory(customGradleExecutableDirectory: string, workspaceRoot: string): string;
26
30
  //# sourceMappingURL=exec-gradle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exec-gradle.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/utils/exec-gradle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAY,MAAM,oBAAoB,CAAC;AAK/D,eAAO,MAAM,aAAa,QAEb,CAAC;AAEd,eAAO,MAAM,gBAAgB,QAErB,CAAC;AAET;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,gBAAgB,EAAE,MAAM,EACxB,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAC3B,WAAW,GAAE,eAAoB,GAChC,OAAO,CAAC,MAAM,CAAC,CA2BjB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,oBAAoB,EAAE,MAAM,EAC5B,EAAE,GAAE,MAAsB,EAC1B,iBAAiB,CAAC,EAAE,MAAM,GACzB,MAAM,CA6BR"}
1
+ {"version":3,"file":"exec-gradle.d.ts","sourceRoot":"","sources":["../../../../../packages/gradle/src/utils/exec-gradle.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EAEpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,eAAe,EAAY,MAAM,oBAAoB,CAAC;AAO/D,eAAO,MAAM,aAAa,QAEb,CAAC;AAEd,eAAO,MAAM,gBAAgB,QAErB,CAAC;AAET;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,gBAAgB,EAAE,MAAM,EACxB,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAC3B,WAAW,GAAE,eAAoB,GAChC,OAAO,CAAC,MAAM,CAAC,CA4BjB;AAED,wBAAgB,4CAA4C,CAC1D,MAAM,EAAE,mBAAmB,GAC1B,MAAM,GAAG,SAAS,CAWpB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE,MAAM,EACrB,yBAAyB,CAAC,EAAE,MAAM,GACjC,MAAM,CASR;AAED,wBAAgB,iCAAiC,CAC/C,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE,MAAM,EACrB,iBAAiB,CAAC,EAAE,MAAM,UAoC3B;AAED,wBAAgB,yCAAyC,CACvD,+BAA+B,EAAE,MAAM,EACvC,aAAa,EAAE,MAAM,UAqCtB"}
@@ -3,12 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.newLineSeparator = exports.fileSeparator = void 0;
4
4
  exports.getGradleExecFile = getGradleExecFile;
5
5
  exports.execGradleAsync = execGradleAsync;
6
+ exports.getCustomGradleExecutableDirectoryFromPlugin = getCustomGradleExecutableDirectoryFromPlugin;
6
7
  exports.findGradlewFile = findGradlewFile;
8
+ exports.findGradlewUsingFilePathTraversal = findGradlewUsingFilePathTraversal;
9
+ exports.findGradlewUsingCustomExecutableDirectory = findGradlewUsingCustomExecutableDirectory;
7
10
  const devkit_1 = require("@nx/devkit");
8
11
  const node_child_process_1 = require("node:child_process");
9
12
  const node_fs_1 = require("node:fs");
10
13
  const node_path_1 = require("node:path");
11
14
  const run_commands_impl_1 = require("nx/src/executors/run-commands/run-commands.impl");
15
+ const exit_codes_1 = require("nx/src/utils/exit-codes");
12
16
  exports.fileSeparator = process.platform.startsWith('win')
13
17
  ? 'file:///'
14
18
  : 'file://';
@@ -46,7 +50,9 @@ function execGradleAsync(gradleBinaryPath, args, execOptions = {}) {
46
50
  cp.stderr?.on('data', (data) => {
47
51
  stdout += data;
48
52
  });
49
- cp.on('exit', (code) => {
53
+ cp.on('exit', (code, signal) => {
54
+ if (code === null)
55
+ code = (0, exit_codes_1.signalToCode)(signal);
50
56
  if (code === 0) {
51
57
  res(stdout);
52
58
  }
@@ -56,36 +62,83 @@ function execGradleAsync(gradleBinaryPath, args, execOptions = {}) {
56
62
  });
57
63
  });
58
64
  }
65
+ function getCustomGradleExecutableDirectoryFromPlugin(nxJson) {
66
+ const gradlePlugin = nxJson.plugins?.find((plugin) => {
67
+ if (typeof plugin === 'string') {
68
+ return plugin === '@nx/gradle';
69
+ }
70
+ return plugin.plugin === '@nx/gradle';
71
+ });
72
+ return gradlePlugin && typeof gradlePlugin !== 'string'
73
+ ? gradlePlugin.options?.gradleExecutableDirectory
74
+ : undefined;
75
+ }
59
76
  /**
60
77
  * This function recursively finds the nearest gradlew file in the workspace
61
- * @param originalFileToSearch the original file to search for, relative to workspace root, file path not directory path
62
- * @param wr workspace root
63
- * @param currentSearchPath the path to start searching for gradlew file
78
+ * @param filePathToSearch the original file to search for, relative to workspace root, file path not directory path
79
+ * @param workspaceRoot workspace root
80
+ * @param customExecutableDirectory a custom directory to search for the gradle wrapper file
64
81
  * @returns the relative path of the gradlew file to workspace root, throws an error if gradlew file is not found
65
82
  * It will return relative path to workspace root of gradlew.bat file on windows and gradlew file on other platforms
66
83
  */
67
- function findGradlewFile(originalFileToSearch, wr = devkit_1.workspaceRoot, currentSearchPath) {
68
- currentSearchPath ??= originalFileToSearch;
84
+ function findGradlewFile(filePathToSearch, workspaceRoot, customExecutableDirectory) {
85
+ if (customExecutableDirectory) {
86
+ return findGradlewUsingCustomExecutableDirectory(customExecutableDirectory, workspaceRoot);
87
+ }
88
+ return findGradlewUsingFilePathTraversal(filePathToSearch, workspaceRoot);
89
+ }
90
+ function findGradlewUsingFilePathTraversal(filePathToSearch, workspaceRoot, currentSearchPath) {
91
+ currentSearchPath ??= filePathToSearch;
69
92
  const parent = (0, node_path_1.dirname)(currentSearchPath);
70
93
  if (currentSearchPath === parent) {
71
94
  throw new devkit_1.AggregateCreateNodesError([
72
95
  [
73
- originalFileToSearch,
74
- new Error('No Gradlew file found. Run "gradle init"'),
96
+ filePathToSearch,
97
+ new Error(`No Gradlew file found at ${filePathToSearch} or any of its parent directories. Run "gradle init"`),
75
98
  ],
76
99
  ], []);
77
100
  }
78
101
  const gradlewPath = (0, node_path_1.join)(parent, 'gradlew');
79
102
  const gradlewBatPath = (0, node_path_1.join)(parent, 'gradlew.bat');
80
103
  if (process.platform.startsWith('win')) {
81
- if ((0, node_fs_1.existsSync)((0, node_path_1.join)(wr, gradlewBatPath))) {
104
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(workspaceRoot, gradlewBatPath))) {
82
105
  return gradlewBatPath;
83
106
  }
84
107
  }
85
108
  else {
86
- if ((0, node_fs_1.existsSync)((0, node_path_1.join)(wr, gradlewPath))) {
109
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(workspaceRoot, gradlewPath))) {
87
110
  return gradlewPath;
88
111
  }
89
112
  }
90
- return findGradlewFile(originalFileToSearch, wr, parent);
113
+ return findGradlewUsingFilePathTraversal(filePathToSearch, workspaceRoot, parent);
114
+ }
115
+ function findGradlewUsingCustomExecutableDirectory(customGradleExecutableDirectory, workspaceRoot) {
116
+ // Resolve the custom installation path - if relative, resolve against workspace root
117
+ const resolvedInstallationPath = (0, node_path_1.isAbsolute)(customGradleExecutableDirectory)
118
+ ? customGradleExecutableDirectory
119
+ : (0, node_path_1.join)(workspaceRoot, customGradleExecutableDirectory);
120
+ const customGradlewPath = (0, node_path_1.join)(resolvedInstallationPath, 'gradlew');
121
+ const customGradlewBatPath = (0, node_path_1.join)(resolvedInstallationPath, 'gradlew.bat');
122
+ if (process.platform.startsWith('win')) {
123
+ if ((0, node_fs_1.existsSync)(customGradlewBatPath)) {
124
+ // Return path relative to workspace root if it was relative, otherwise return absolute
125
+ return (0, node_path_1.isAbsolute)(customGradleExecutableDirectory)
126
+ ? customGradlewBatPath
127
+ : (0, node_path_1.join)(customGradleExecutableDirectory, 'gradlew.bat');
128
+ }
129
+ }
130
+ else {
131
+ if ((0, node_fs_1.existsSync)(customGradlewPath)) {
132
+ // Return path relative to workspace root if it was relative, otherwise return absolute
133
+ return (0, node_path_1.isAbsolute)(customGradleExecutableDirectory)
134
+ ? customGradlewPath
135
+ : (0, node_path_1.join)(customGradleExecutableDirectory, 'gradlew');
136
+ }
137
+ }
138
+ throw new devkit_1.AggregateCreateNodesError([
139
+ [
140
+ customGradleExecutableDirectory,
141
+ new Error(`No Gradlew file found at custom gradle executable directory. Please ensure that there is a gradle wrapper file located at ${customGradleExecutableDirectory}`),
142
+ ],
143
+ ], []);
91
144
  }
@@ -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.7";
3
+ export declare const gradleProjectGraphVersion = "0.1.8";
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.7';
6
+ exports.gradleProjectGraphVersion = '0.1.8';