@nx/gradle 21.2.1 → 21.2.3
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/package.json +2 -2
- package/src/executors/gradle/gradle.impl.js +7 -5
- package/src/generators/ci-workflow/files/circleci/.circleci/config.yml.template +6 -4
- package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template +5 -4
- package/src/generators/ci-workflow/generator.d.ts +4 -4
- package/src/generators/ci-workflow/generator.js +14 -9
- package/src/plugin/nodes.js +6 -3
- package/src/plugin/utils/__mocks__/gradle_composite.json +1 -0
- package/src/plugin/utils/__mocks__/gradle_tutorial.json +1 -0
- package/src/plugin/utils/get-project-graph-from-gradle-plugin.d.ts +2 -0
- package/src/plugin/utils/get-project-graph-from-gradle-plugin.js +11 -0
Binary file
|
Binary file
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/gradle",
|
3
|
-
"version": "21.2.
|
3
|
+
"version": "21.2.3",
|
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.2.
|
38
|
+
"@nx/devkit": "21.2.3"
|
39
39
|
},
|
40
40
|
"publishConfig": {
|
41
41
|
"access": "public"
|
@@ -17,11 +17,13 @@ async function gradleExecutor(options, context) {
|
|
17
17
|
if (options.testClassName) {
|
18
18
|
args.push(`--tests`, options.testClassName);
|
19
19
|
}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
if (options.excludeDependsOn) {
|
21
|
+
(0, get_exclude_task_1.getExcludeTasks)(new Set([`${context.projectName}:${context.targetName}`]), context.projectGraph.nodes).forEach((task) => {
|
22
|
+
if (task) {
|
23
|
+
args.push('--exclude-task', task);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
}
|
25
27
|
try {
|
26
28
|
const { success } = await (0, run_commands_impl_1.default)({
|
27
29
|
command: `${gradlewPath} ${options.taskName}`,
|
@@ -21,13 +21,15 @@ jobs:
|
|
21
21
|
# Run this command as early as possible, before dependencies are installed
|
22
22
|
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
|
23
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<% } %>
|
24
|
-
# - run:
|
24
|
+
# - run: ./nx start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="check"
|
25
25
|
|
26
26
|
- nx/set-shas:
|
27
27
|
main-branch-name: '<%= mainBranch %>'
|
28
|
-
<% for (const command of commands) { %>
|
29
|
-
|
30
|
-
|
28
|
+
<% for (const command of commands) { %><% if (command.comments) { %><% for (const comment of command.comments) { %>
|
29
|
+
# <%- comment %><% } %><% } %><% if (command.command) { %>
|
30
|
+
- run:
|
31
|
+
command: <%= command.command %><% if (command.alwaysRun) { %>
|
32
|
+
when: always<% } %><% } %><% } %>
|
31
33
|
|
32
34
|
workflows:
|
33
35
|
version: 2
|
package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template
CHANGED
@@ -26,7 +26,7 @@ jobs:
|
|
26
26
|
# Run this command as early as possible, before dependencies are installed
|
27
27
|
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
|
28
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<% } %>
|
29
|
-
# - run:
|
29
|
+
# - run: ./nx start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="check"
|
30
30
|
|
31
31
|
- name: Set up JDK 21 for x64
|
32
32
|
uses: actions/setup-java@v4
|
@@ -39,6 +39,7 @@ jobs:
|
|
39
39
|
uses: gradle/actions/setup-gradle@v3
|
40
40
|
|
41
41
|
- uses: nrwl/nx-set-shas@v4
|
42
|
-
<% for (const command of commands) { %>
|
43
|
-
|
44
|
-
|
42
|
+
<% for (const command of commands) { %><% if (command.comments) { %><% for (const comment of command.comments) { %>
|
43
|
+
# <%- comment %><% } %><% } %><% if (command.command) { %>
|
44
|
+
- run: <%= command.command %><% if (command.alwaysRun) { %>
|
45
|
+
if: always()<% } %><% } %><% } %>
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
2
2
|
export type Command = {
|
3
|
-
command
|
4
|
-
|
5
|
-
|
6
|
-
}
|
3
|
+
command?: string;
|
4
|
+
comments?: string[];
|
5
|
+
alwaysRun?: boolean;
|
6
|
+
};
|
7
7
|
export interface Schema {
|
8
8
|
name: string;
|
9
9
|
ci: 'github' | 'circleci';
|
@@ -11,13 +11,12 @@ function getCiCommands(ci) {
|
|
11
11
|
return [
|
12
12
|
{
|
13
13
|
comments: [
|
14
|
-
|
15
|
-
|
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
16
|
],
|
17
|
-
},
|
18
|
-
{
|
19
17
|
command: `./nx affected --base=$NX_BASE --head=$NX_HEAD -t assemble check`,
|
20
18
|
},
|
19
|
+
getNxCloudFixCiCommand(),
|
21
20
|
];
|
22
21
|
}
|
23
22
|
default: {
|
@@ -27,12 +26,22 @@ function getCiCommands(ci) {
|
|
27
26
|
`# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected.`,
|
28
27
|
`# Change from check to check-ci if you turn on the atomizer. Learn more: https://nx.dev/nx-api/gradle#splitting-tests`,
|
29
28
|
],
|
29
|
+
command: `./nx affected -t assemble check`,
|
30
30
|
},
|
31
|
-
|
31
|
+
getNxCloudFixCiCommand(),
|
32
32
|
];
|
33
33
|
}
|
34
34
|
}
|
35
35
|
}
|
36
|
+
function getNxCloudFixCiCommand() {
|
37
|
+
return {
|
38
|
+
comments: [
|
39
|
+
`Nx Cloud recommends fixes for failures to help you get CI green faster. Learn more: https://nx.dev/ci/features/self-healing-ci`,
|
40
|
+
],
|
41
|
+
command: `./nx fix-ci`,
|
42
|
+
alwaysRun: true,
|
43
|
+
};
|
44
|
+
}
|
36
45
|
async function ciWorkflowGenerator(tree, schema) {
|
37
46
|
const ci = schema.ci;
|
38
47
|
const options = getTemplateData(tree, schema);
|
@@ -41,8 +50,6 @@ async function ciWorkflowGenerator(tree, schema) {
|
|
41
50
|
}
|
42
51
|
function getTemplateData(tree, options) {
|
43
52
|
const { name: workflowName, fileName: workflowFileName } = (0, devkit_1.names)(options.name);
|
44
|
-
const packageManager = (0, devkit_1.detectPackageManager)();
|
45
|
-
const { exec: packageManagerPrefix } = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
46
53
|
let nxCloudHost = 'nx.app';
|
47
54
|
try {
|
48
55
|
const nxCloudUrl = (0, nx_cloud_utils_1.getNxCloudUrl)((0, devkit_1.readNxJson)(tree));
|
@@ -55,8 +62,6 @@ function getTemplateData(tree, options) {
|
|
55
62
|
return {
|
56
63
|
workflowName,
|
57
64
|
workflowFileName,
|
58
|
-
packageManager,
|
59
|
-
packageManagerPrefix,
|
60
65
|
commands,
|
61
66
|
mainBranch,
|
62
67
|
nxCloudHost,
|
package/src/plugin/nodes.js
CHANGED
@@ -20,14 +20,17 @@ function writeTargetsToCache(cachePath, results) {
|
|
20
20
|
exports.createNodesV2 = [
|
21
21
|
split_config_files_1.gradleConfigAndTestGlob,
|
22
22
|
async (files, options, context) => {
|
23
|
-
const { buildFiles, gradlewFiles } = (0, split_config_files_1.splitConfigFiles)(files);
|
23
|
+
const { buildFiles: buildFilesFromSplitConfigFiles, gradlewFiles } = (0, split_config_files_1.splitConfigFiles)(files);
|
24
24
|
const optionsHash = (0, file_hasher_1.hashObject)(options);
|
25
25
|
const cachePath = (0, node_path_1.join)(cache_directory_1.workspaceDataDirectory, `gradle-${optionsHash}.hash`);
|
26
26
|
const projectsCache = readProjectsCache(cachePath);
|
27
27
|
await (0, get_project_graph_from_gradle_plugin_1.populateProjectGraph)(context.workspaceRoot, gradlewFiles.map((f) => (0, node_path_1.join)(context.workspaceRoot, f)), options);
|
28
|
-
const
|
28
|
+
const report = (0, get_project_graph_from_gradle_plugin_1.getCurrentProjectGraphReport)();
|
29
|
+
const { nodes, externalNodes, buildFiles = [] } = report;
|
30
|
+
// Combine buildFilesFromSplitConfigFiles and buildFiles, making each value distinct
|
31
|
+
const allBuildFiles = Array.from(new Set([...buildFilesFromSplitConfigFiles, ...buildFiles]));
|
29
32
|
try {
|
30
|
-
return (0, devkit_1.createNodesFromFiles)((0, exports.makeCreateNodesForGradleConfigFile)(nodes, projectsCache, externalNodes),
|
33
|
+
return (0, devkit_1.createNodesFromFiles)((0, exports.makeCreateNodesForGradleConfigFile)(nodes, projectsCache, externalNodes), allBuildFiles, options, context);
|
31
34
|
}
|
32
35
|
finally {
|
33
36
|
writeTargetsToCache(cachePath, projectsCache);
|
@@ -6,12 +6,14 @@ export interface ProjectGraphReport {
|
|
6
6
|
};
|
7
7
|
dependencies: Array<StaticDependency>;
|
8
8
|
externalNodes?: Record<string, ProjectGraphExternalNode>;
|
9
|
+
buildFiles?: string[];
|
9
10
|
}
|
10
11
|
export interface ProjectGraphReportCache extends ProjectGraphReport {
|
11
12
|
hash: string;
|
12
13
|
}
|
13
14
|
export declare function writeProjectGraphReportToCache(cachePath: string, results: ProjectGraphReport): void;
|
14
15
|
export declare function getCurrentProjectGraphReport(): ProjectGraphReport;
|
16
|
+
export declare function getCurrentBuildFiles(): string[];
|
15
17
|
/**
|
16
18
|
* This function populates the gradle report cache.
|
17
19
|
* For each gradlew file, it runs the `nxProjectGraph` task and processes the output.
|
@@ -2,6 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.writeProjectGraphReportToCache = writeProjectGraphReportToCache;
|
4
4
|
exports.getCurrentProjectGraphReport = getCurrentProjectGraphReport;
|
5
|
+
exports.getCurrentBuildFiles = getCurrentBuildFiles;
|
5
6
|
exports.populateProjectGraph = populateProjectGraph;
|
6
7
|
exports.processNxProjectGraph = processNxProjectGraph;
|
7
8
|
const node_fs_1 = require("node:fs");
|
@@ -42,6 +43,10 @@ function getCurrentProjectGraphReport() {
|
|
42
43
|
}
|
43
44
|
return projectGraphReportCache;
|
44
45
|
}
|
46
|
+
function getCurrentBuildFiles() {
|
47
|
+
const report = getCurrentProjectGraphReport();
|
48
|
+
return report.buildFiles || [];
|
49
|
+
}
|
45
50
|
/**
|
46
51
|
* This function populates the gradle report cache.
|
47
52
|
* For each gradlew file, it runs the `nxProjectGraph` task and processes the output.
|
@@ -84,6 +89,7 @@ function processNxProjectGraph(projectGraphLines) {
|
|
84
89
|
dependencies: [],
|
85
90
|
externalNodes: {},
|
86
91
|
};
|
92
|
+
const allBuildFiles = new Set();
|
87
93
|
while (index < projectGraphLines.length) {
|
88
94
|
const line = projectGraphLines[index].trim();
|
89
95
|
if (line.startsWith('> Task ') && line.endsWith(':nxProjectGraph')) {
|
@@ -106,8 +112,13 @@ function processNxProjectGraph(projectGraphLines) {
|
|
106
112
|
...projectGraphReportJson.externalNodes,
|
107
113
|
};
|
108
114
|
}
|
115
|
+
if (projectGraphReportJson.buildFiles) {
|
116
|
+
projectGraphReportJson.buildFiles.forEach((buildFile) => allBuildFiles.add(buildFile));
|
117
|
+
}
|
109
118
|
}
|
110
119
|
index++;
|
111
120
|
}
|
121
|
+
// Convert Set to array for the final result
|
122
|
+
projectGraphReportForAllProjects.buildFiles = Array.from(allBuildFiles);
|
112
123
|
return projectGraphReportForAllProjects;
|
113
124
|
}
|