@nx/gradle 21.0.0-canary.20250501-8f50358 → 21.0.0-canary.20250503-675e6ed

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/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
11
  [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
- [![NPM Version](https://badge.fury.io/js/%40nrwl%2Fworkspace.svg)](https://www.npmjs.com/@nx/workspace)
12
+ [![NPM Version](https://badge.fury.io/js/nx.svg)](https://www.npmjs.com/package/nx)
13
13
  [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
14
14
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
15
  [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
package/executors.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "batchImplementation": "./src/executors/gradle/gradle-batch.impl",
5
5
  "implementation": "./src/executors/gradle/gradle.impl",
6
6
  "schema": "./src/executors/gradle/schema.json",
7
- "description": "The Gradlew executor is used to run Gradle tasks."
7
+ "description": "Runs gradle tasks via the Gradle Tooling API or by invoking gradlew."
8
8
  }
9
9
  }
10
10
  }
package/migrations.json CHANGED
@@ -23,6 +23,12 @@
23
23
  "cli": "nx",
24
24
  "description": "Change @nx/gradle plugin to version 1",
25
25
  "factory": "./src/migrations/21-0-0/change-plugin-to-v1"
26
+ },
27
+ "change-ciTargetName-to-ciTestTargetName": {
28
+ "version": "21.0.0-beta.13",
29
+ "cli": "nx",
30
+ "description": "Change @nx/gradle option from ciTargetName to ciTestTargetName",
31
+ "factory": "./src/migrations/21-0-0/change-ciTargetName-to-ciTestTargetName"
26
32
  }
27
33
  },
28
34
  "packageJsonUpdates": {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/gradle",
3
- "version": "21.0.0-canary.20250501-8f50358",
3
+ "version": "21.0.0-canary.20250503-675e6ed",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Gradle allows Gradle tasks to be run through Nx",
6
6
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "migrations": "./migrations.json"
36
36
  },
37
37
  "dependencies": {
38
- "@nx/devkit": "21.0.0-canary.20250501-8f50358"
38
+ "@nx/devkit": "21.0.0-canary.20250503-675e6ed"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -7,6 +7,7 @@ const run_commands_impl_1 = require("nx/src/executors/run-commands/run-commands.
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 pseudo_terminal_1 = require("nx/src/tasks-runner/pseudo-terminal");
10
11
  exports.batchRunnerPath = (0, path_1.join)(__dirname, '../../../batch-runner/build/libs/batch-runner-all.jar');
11
12
  async function gradleBatch(taskGraph, inputs, overrides, context) {
12
13
  try {
@@ -34,13 +35,35 @@ async function gradleBatch(taskGraph, inputs, overrides, context) {
34
35
  return gradlewTasksToRun;
35
36
  }, {});
36
37
  const gradlewBatchStart = performance.mark(`gradlew-batch:start`);
37
- const batchResults = (0, child_process_1.execSync)(`java -jar ${exports.batchRunnerPath} --tasks='${JSON.stringify(gradlewTasksToRun)}' --workspaceRoot=${root} --args='${args
38
+ const usePseudoTerminal = process.env.NX_NATIVE_COMMAND_RUNNER !== 'false' &&
39
+ pseudo_terminal_1.PseudoTerminal.isSupported();
40
+ const command = `java -jar ${exports.batchRunnerPath} --tasks='${JSON.stringify(gradlewTasksToRun)}' --workspaceRoot=${root} --args='${args
38
41
  .join(' ')
39
- .replaceAll("'", '"')}' ${process.env.NX_VERBOSE_LOGGING === 'true' ? '' : '--quiet'}`, {
40
- windowsHide: true,
41
- env: process.env,
42
- maxBuffer: run_commands_impl_1.LARGE_BUFFER,
43
- });
42
+ .replaceAll("'", '"')}' ${process.env.NX_VERBOSE_LOGGING === 'true' ? '' : '--quiet'}`;
43
+ let batchResults;
44
+ if (usePseudoTerminal) {
45
+ const terminal = (0, pseudo_terminal_1.createPseudoTerminal)();
46
+ await terminal.init();
47
+ const cp = terminal.runCommand(command, {
48
+ cwd: devkit_1.workspaceRoot,
49
+ jsEnv: process.env,
50
+ quiet: process.env.NX_VERBOSE_LOGGING !== 'true',
51
+ });
52
+ const results = await cp.getResults();
53
+ batchResults = results.terminalOutput;
54
+ batchResults = batchResults.replace(command, '');
55
+ const startIndex = batchResults.indexOf('{');
56
+ const endIndex = batchResults.lastIndexOf('}');
57
+ batchResults = batchResults.substring(startIndex, endIndex + 1);
58
+ }
59
+ else {
60
+ batchResults = (0, child_process_1.execSync)(command, {
61
+ cwd: devkit_1.workspaceRoot,
62
+ windowsHide: true,
63
+ env: process.env,
64
+ maxBuffer: run_commands_impl_1.LARGE_BUFFER,
65
+ }).toString();
66
+ }
44
67
  const gradlewBatchEnd = performance.mark(`gradlew-batch:end`);
45
68
  performance.measure(`gradlew-batch`, gradlewBatchStart.name, gradlewBatchEnd.name);
46
69
  const gradlewBatchResults = JSON.parse(batchResults.toString());
@@ -3,6 +3,9 @@ version: 2.1
3
3
  orbs:
4
4
  nx: nrwl/nx@1.6.2
5
5
 
6
+ env:
7
+ NX_BATCH_MODE: true
8
+
6
9
  jobs:
7
10
  main:
8
11
  environment:
@@ -18,13 +21,13 @@ jobs:
18
21
  # Run this command as early as possible, before dependencies are installed
19
22
  # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
20
23
  <% if (connectedToCloud) { %># Uncomment this line to enable task distribution<% } else { %># Connect your workspace by running "nx connect" and uncomment this line to enable task distribution<% } %>
21
- # - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="build"
24
+ # - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="check"
22
25
 
23
26
  - nx/set-shas:
24
27
  main-branch-name: '<%= mainBranch %>'
25
-
26
28
  <% for (const command of commands) { %>
27
- <% if (command.command) { %>- run: <%= command.command %><% } else if (command.comment) { %><%= command.comment %><% } else {%>- run: <%= command %><% } %><% } %>
29
+ <% if (command.command) { %>- run: <%= command.command %><% } else if (command.comments) { %><% for (const comment of command.comments) { %>
30
+ <%= comment %><% } %><% } else {%>- run: <%= command %><% } %><% } %>
28
31
 
29
32
  workflows:
30
33
  version: 2
@@ -10,6 +10,9 @@ permissions:
10
10
  actions: read
11
11
  contents: read
12
12
 
13
+ env:
14
+ NX_BATCH_MODE: true
15
+
13
16
  jobs:
14
17
  main:
15
18
  runs-on: ubuntu-latest
@@ -23,7 +26,7 @@ jobs:
23
26
  # Run this command as early as possible, before dependencies are installed
24
27
  # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
25
28
  <% if (connectedToCloud) { %># Uncomment this line to enable task distribution<% } else { %># Connect your workspace by running "nx connect" and uncomment this line to enable task distribution<% } %>
26
- # - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="build"
29
+ # - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="check"
27
30
 
28
31
  - name: Set up JDK 21 for x64
29
32
  uses: actions/setup-java@v4
@@ -33,9 +36,9 @@ jobs:
33
36
  architecture: x64
34
37
 
35
38
  - name: Setup Gradle
36
- uses: gradle/gradle-build-action@v4
39
+ uses: gradle/actions/setup-gradle@v3
37
40
 
38
41
  - uses: nrwl/nx-set-shas@v4
39
-
40
42
  <% for (const command of commands) { %>
41
- <% if (command.command) { %>- run: <%= command.command %><% } else if (command.comment) { %><%= command.comment %><% } else {%>- run: <%= command %><% } %><% } %>
43
+ <% if (command.command) { %>- run: <%= command.command %><% } else if (command.comments) { %><% for (const comment of command.comments) { %>
44
+ <%= comment %><% } %><% } else {%>- run: <%= command %><% } %><% } %>
@@ -2,7 +2,7 @@ import { Tree } from '@nx/devkit';
2
2
  export type Command = {
3
3
  command: string;
4
4
  } | {
5
- comment: string;
5
+ comments: string[];
6
6
  } | string;
7
7
  export interface Schema {
8
8
  name: string;
@@ -10,19 +10,25 @@ function getCiCommands(ci) {
10
10
  case 'circleci': {
11
11
  return [
12
12
  {
13
- comment: `# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected`,
13
+ comments: [
14
+ `# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected.`,
15
+ `# Change from check to check-ci if you turn on the atomizer. Learn more: https://nx.dev/nx-api/gradle#splitting-e2e-tests.`,
16
+ ],
14
17
  },
15
18
  {
16
- command: `./nx affected --base=$NX_BASE --head=$NX_HEAD -t build`,
19
+ command: `./nx affected --base=$NX_BASE --head=$NX_HEAD -t assemble check`,
17
20
  },
18
21
  ];
19
22
  }
20
23
  default: {
21
24
  return [
22
25
  {
23
- comment: `# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected`,
26
+ comments: [
27
+ `# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected.`,
28
+ `# Change from check to check-ci if you turn on the atomizer. Learn more: https://nx.dev/nx-api/gradle#splitting-tests`,
29
+ ],
24
30
  },
25
- { command: `./nx affected -t build` },
31
+ { command: `./nx affected -t assemble check` },
26
32
  ];
27
33
  }
28
34
  }
@@ -0,0 +1,2 @@
1
+ import { Tree } from '@nx/devkit';
2
+ export default function update(tree: Tree): void;
@@ -0,0 +1,28 @@
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
+ /* This function changes the @nx/gradle plugin option from ciTargetName to ciTestTargetName
7
+ */
8
+ function update(tree) {
9
+ const nxJson = (0, devkit_1.readNxJson)(tree);
10
+ if (!nxJson) {
11
+ return;
12
+ }
13
+ if (!(0, has_gradle_plugin_1.hasGradlePlugin)(tree)) {
14
+ return;
15
+ }
16
+ let gradlePluginIndex = nxJson.plugins.findIndex((p) => typeof p === 'string' ? p === '@nx/gradle' : p.plugin === '@nx/gradle');
17
+ let gradlePlugin = nxJson.plugins[gradlePluginIndex];
18
+ if (typeof gradlePlugin === 'object' &&
19
+ gradlePlugin.plugin === '@nx/gradle') {
20
+ const ciTargetName = gradlePlugin.options?.['ciTargetName'];
21
+ if (ciTargetName) {
22
+ delete gradlePlugin.options?.['ciTargetName'];
23
+ gradlePlugin.options['ciTestTargetName'] =
24
+ ciTargetName;
25
+ }
26
+ }
27
+ (0, devkit_1.updateNxJson)(tree, nxJson);
28
+ }
@@ -6,6 +6,7 @@ const node_path_1 = require("node:path");
6
6
  const get_project_graph_from_gradle_plugin_1 = require("./utils/get-project-graph-from-gradle-plugin");
7
7
  const split_config_files_1 = require("../utils/split-config-files");
8
8
  const workspace_context_1 = require("nx/src/utils/workspace-context");
9
+ const node_fs_1 = require("node:fs");
9
10
  const createDependencies = async (options, context) => {
10
11
  const files = await (0, workspace_context_1.globWithWorkspaceContext)(devkit_1.workspaceRoot, Array.from(split_config_files_1.GRALDEW_FILES));
11
12
  const { gradlewFiles } = (0, split_config_files_1.splitConfigFiles)(files);
@@ -18,7 +19,9 @@ const createDependencies = async (options, context) => {
18
19
  const sourceProjectName = Object.values(context.projects).find((project) => source === project.root)?.name ?? dependencyFromPlugin.source;
19
20
  const target = (0, node_path_1.relative)(devkit_1.workspaceRoot, dependencyFromPlugin.target) || '.';
20
21
  const targetProjectName = Object.values(context.projects).find((project) => target === project.root)?.name ?? dependencyFromPlugin.target;
21
- if (!sourceProjectName || !targetProjectName) {
22
+ if (!sourceProjectName ||
23
+ !targetProjectName ||
24
+ !(0, node_fs_1.existsSync)(dependencyFromPlugin.sourceFile)) {
22
25
  return;
23
26
  }
24
27
  const dependency = {