@nx/gradle 21.0.0-canary.20250429-cf4a1f3 → 21.0.0-canary.20250430-07b881d
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/batch-runner/build/libs/batch-runner-all.jar +0 -0
- package/batch-runner/build/libs/batch-runner.jar +0 -0
- package/batch-runner/project.json +33 -0
- package/executors.json +8 -1
- package/package.json +2 -2
- package/src/executors/gradle/gradle-batch.impl.d.ts +6 -0
- package/src/executors/gradle/gradle-batch.impl.js +67 -0
- package/src/executors/gradle/gradle.impl.d.ts +5 -0
- package/src/executors/gradle/gradle.impl.js +31 -0
- package/src/executors/gradle/schema.d.ts +5 -0
- package/src/executors/gradle/schema.json +33 -0
- package/src/plugin/dependencies.js +1 -1
- package/src/plugin/nodes.js +5 -0
- package/src/plugin/utils/gradle-plugin-options.d.ts +2 -1
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
Binary file
|
Binary file
|
@@ -0,0 +1,33 @@
|
|
1
|
+
{
|
2
|
+
"name": "gradle-batch-runner",
|
3
|
+
"$schema": "node_modules/nx/schemas/project-schema.json",
|
4
|
+
"projectRoot": "packages/gradle/batch-runner",
|
5
|
+
"sourceRoot": "packages/gradle/batch-runner/src",
|
6
|
+
"targets": {
|
7
|
+
"assemble": {
|
8
|
+
"command": "./gradlew :batch-runner:assemble",
|
9
|
+
"inputs": [
|
10
|
+
"{projectRoot}/src/**",
|
11
|
+
"{projectRoot}/build.gradle.kts",
|
12
|
+
"{projectRoot}/settings.gradle.kts"
|
13
|
+
],
|
14
|
+
"outputs": ["{projectRoot}/build"],
|
15
|
+
"cache": true
|
16
|
+
},
|
17
|
+
"test": {
|
18
|
+
"command": "./gradlew :batch-runner:test",
|
19
|
+
"options": {
|
20
|
+
"args": []
|
21
|
+
},
|
22
|
+
"cache": true
|
23
|
+
},
|
24
|
+
"lint": {
|
25
|
+
"command": "./gradlew :batch-runner:ktfmtCheck",
|
26
|
+
"cache": true
|
27
|
+
},
|
28
|
+
"format": {
|
29
|
+
"command": "./gradlew :batch-runner:ktfmtFormat",
|
30
|
+
"cache": true
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
package/executors.json
CHANGED
@@ -1,3 +1,10 @@
|
|
1
1
|
{
|
2
|
-
"executors": {
|
2
|
+
"executors": {
|
3
|
+
"gradle": {
|
4
|
+
"batchImplementation": "./src/executors/gradle/gradle-batch.impl",
|
5
|
+
"implementation": "./src/executors/gradle/gradle.impl",
|
6
|
+
"schema": "./src/executors/gradle/schema.json",
|
7
|
+
"description": "The Gradlew executor is used to run Gradle tasks."
|
8
|
+
}
|
9
|
+
}
|
3
10
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/gradle",
|
3
|
-
"version": "21.0.0-canary.
|
3
|
+
"version": "21.0.0-canary.20250430-07b881d",
|
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.
|
38
|
+
"@nx/devkit": "21.0.0-canary.20250430-07b881d"
|
39
39
|
},
|
40
40
|
"publishConfig": {
|
41
41
|
"access": "public"
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import { ExecutorContext, TaskGraph } from '@nx/devkit';
|
2
|
+
import { RunCommandsOptions } from 'nx/src/executors/run-commands/run-commands.impl';
|
3
|
+
import { BatchResults } from 'nx/src/tasks-runner/batch/batch-messages';
|
4
|
+
import { gradleExecutorSchema } from './schema';
|
5
|
+
export declare const batchRunnerPath: string;
|
6
|
+
export default function gradleBatch(taskGraph: TaskGraph, inputs: Record<string, gradleExecutorSchema>, overrides: RunCommandsOptions, context: ExecutorContext): Promise<BatchResults>;
|
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.batchRunnerPath = void 0;
|
4
|
+
exports.default = gradleBatch;
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
6
|
+
const run_commands_impl_1 = require("nx/src/executors/run-commands/run-commands.impl");
|
7
|
+
const exec_gradle_1 = require("../../utils/exec-gradle");
|
8
|
+
const path_1 = require("path");
|
9
|
+
const child_process_1 = require("child_process");
|
10
|
+
exports.batchRunnerPath = (0, path_1.join)(__dirname, '../../../batch-runner/build/libs/batch-runner-all.jar');
|
11
|
+
async function gradleBatch(taskGraph, inputs, overrides, context) {
|
12
|
+
try {
|
13
|
+
const projectName = taskGraph.tasks[taskGraph.roots[0]]?.target?.project;
|
14
|
+
let projectRoot = context.projectGraph.nodes[projectName]?.data?.root ?? '';
|
15
|
+
const gradlewPath = (0, exec_gradle_1.findGradlewFile)((0, path_1.join)(projectRoot, 'project.json')); // find gradlew near project root
|
16
|
+
const root = (0, path_1.join)(context.root, (0, path_1.dirname)(gradlewPath));
|
17
|
+
// set args with passed in args and overrides in command line
|
18
|
+
const input = inputs[taskGraph.roots[0]];
|
19
|
+
let args = typeof input.args === 'string'
|
20
|
+
? input.args.trim().split(' ')
|
21
|
+
: Array.isArray(input.args)
|
22
|
+
? input.args
|
23
|
+
: [];
|
24
|
+
if (overrides.__overrides_unparsed__.length) {
|
25
|
+
args.push(...overrides.__overrides_unparsed__);
|
26
|
+
}
|
27
|
+
const gradlewTasksToRun = Object.entries(taskGraph.tasks).reduce((gradlewTasksToRun, [taskId, task]) => {
|
28
|
+
const gradlewTaskName = inputs[task.id].taskName;
|
29
|
+
const testClassName = inputs[task.id].testClassName;
|
30
|
+
gradlewTasksToRun[taskId] = {
|
31
|
+
taskName: gradlewTaskName,
|
32
|
+
testClassName: testClassName,
|
33
|
+
};
|
34
|
+
return gradlewTasksToRun;
|
35
|
+
}, {});
|
36
|
+
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
|
+
.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
|
+
});
|
44
|
+
const gradlewBatchEnd = performance.mark(`gradlew-batch:end`);
|
45
|
+
performance.measure(`gradlew-batch`, gradlewBatchStart.name, gradlewBatchEnd.name);
|
46
|
+
const gradlewBatchResults = JSON.parse(batchResults.toString());
|
47
|
+
Object.keys(taskGraph.tasks).forEach((taskId) => {
|
48
|
+
if (!gradlewBatchResults[taskId]) {
|
49
|
+
gradlewBatchResults[taskId] = {
|
50
|
+
success: false,
|
51
|
+
terminalOutput: `Gradlew batch failed`,
|
52
|
+
};
|
53
|
+
}
|
54
|
+
});
|
55
|
+
return gradlewBatchResults;
|
56
|
+
}
|
57
|
+
catch (e) {
|
58
|
+
devkit_1.output.error({
|
59
|
+
title: `Gradlew batch failed`,
|
60
|
+
bodyLines: [e.toString()],
|
61
|
+
});
|
62
|
+
return taskGraph.roots.reduce((acc, key) => {
|
63
|
+
acc[key] = { success: false, terminalOutput: e.toString() };
|
64
|
+
return acc;
|
65
|
+
}, {});
|
66
|
+
}
|
67
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = gradleExecutor;
|
4
|
+
const exec_gradle_1 = require("../../utils/exec-gradle");
|
5
|
+
const node_path_1 = require("node:path");
|
6
|
+
const run_commands_impl_1 = require("nx/src/executors/run-commands/run-commands.impl");
|
7
|
+
async function gradleExecutor(options, context) {
|
8
|
+
let projectRoot = context.projectGraph.nodes[context.projectName]?.data?.root ?? context.root;
|
9
|
+
let gradlewPath = (0, exec_gradle_1.findGradlewFile)((0, node_path_1.join)(projectRoot, 'project.json')); // find gradlew near project root
|
10
|
+
gradlewPath = (0, node_path_1.join)(context.root, gradlewPath);
|
11
|
+
let args = typeof options.args === 'string'
|
12
|
+
? options.args.trim().split(' ')
|
13
|
+
: Array.isArray(options.args)
|
14
|
+
? options.args
|
15
|
+
: [];
|
16
|
+
if (options.testClassName) {
|
17
|
+
args.push(`--tests`, options.testClassName);
|
18
|
+
}
|
19
|
+
try {
|
20
|
+
await (0, run_commands_impl_1.default)({
|
21
|
+
command: `${gradlewPath} ${options.taskName}`,
|
22
|
+
cwd: (0, node_path_1.dirname)(gradlewPath),
|
23
|
+
args: args,
|
24
|
+
__unparsed__: [],
|
25
|
+
}, context);
|
26
|
+
return { success: true };
|
27
|
+
}
|
28
|
+
catch (e) {
|
29
|
+
return { success: false };
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
3
|
+
"version": 2,
|
4
|
+
"title": "Gradle Impl executor",
|
5
|
+
"description": "The Gradle Impl executor is used to run Gradle tasks.",
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"taskName": {
|
9
|
+
"type": "string",
|
10
|
+
"description": "The name of the Gradle task to run."
|
11
|
+
},
|
12
|
+
"testClassName": {
|
13
|
+
"type": "string",
|
14
|
+
"description": "The test class name to run for test task."
|
15
|
+
},
|
16
|
+
"args": {
|
17
|
+
"oneOf": [
|
18
|
+
{
|
19
|
+
"type": "array",
|
20
|
+
"items": {
|
21
|
+
"type": "string"
|
22
|
+
}
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"type": "string"
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"description": "The arguments to pass to the Gradle task.",
|
29
|
+
"examples": [["--warning-mode", "all"], "--stracktrace"]
|
30
|
+
}
|
31
|
+
},
|
32
|
+
"required": ["taskName"]
|
33
|
+
}
|
@@ -9,7 +9,7 @@ const workspace_context_1 = require("nx/src/utils/workspace-context");
|
|
9
9
|
const createDependencies = async (options, context) => {
|
10
10
|
const files = await (0, workspace_context_1.globWithWorkspaceContext)(devkit_1.workspaceRoot, Array.from(split_config_files_1.GRALDEW_FILES));
|
11
11
|
const { gradlewFiles } = (0, split_config_files_1.splitConfigFiles)(files);
|
12
|
-
await (0, get_project_graph_from_gradle_plugin_1.populateProjectGraph)(context.workspaceRoot, gradlewFiles, options);
|
12
|
+
await (0, get_project_graph_from_gradle_plugin_1.populateProjectGraph)(context.workspaceRoot, gradlewFiles.map((file) => (0, node_path_1.join)(devkit_1.workspaceRoot, file)), options);
|
13
13
|
const { dependencies: dependenciesFromReport } = (0, get_project_graph_from_gradle_plugin_1.getCurrentProjectGraphReport)();
|
14
14
|
const dependencies = [];
|
15
15
|
dependenciesFromReport.forEach((dependencyFromPlugin) => {
|
package/src/plugin/nodes.js
CHANGED
@@ -35,6 +35,11 @@ exports.createNodesV2 = [
|
|
35
35
|
},
|
36
36
|
];
|
37
37
|
const makeCreateNodesForGradleConfigFile = (projects, projectsCache = {}, externalNodes = {}) => async (gradleFilePath, options, context) => {
|
38
|
+
if (process.env.VERCEL) {
|
39
|
+
// Vercel does not allow JAVA_VERSION to be set
|
40
|
+
// skip on Vercel
|
41
|
+
return {};
|
42
|
+
}
|
38
43
|
const projectRoot = (0, node_path_1.dirname)(gradleFilePath);
|
39
44
|
options = (0, gradle_plugin_options_1.normalizeOptions)(options);
|
40
45
|
const hash = await (0, calculate_hash_for_create_nodes_1.calculateHashForCreateNodes)(projectRoot, options ?? {}, context);
|
@@ -1,6 +1,7 @@
|
|
1
1
|
export interface GradlePluginOptions {
|
2
2
|
testTargetName?: string;
|
3
|
-
|
3
|
+
ciTestTargetName?: string;
|
4
|
+
ciIntTestTargetName?: string;
|
4
5
|
[taskTargetName: string]: string | undefined | boolean;
|
5
6
|
}
|
6
7
|
export declare function normalizeOptions(options: GradlePluginOptions): GradlePluginOptions;
|
package/src/utils/versions.d.ts
CHANGED
package/src/utils/versions.js
CHANGED
@@ -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.0
|
6
|
+
exports.gradleProjectGraphVersion = '0.1.0';
|