@nx/gradle 19.5.0-beta.0 → 19.5.0-beta.2
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/package.json +2 -2
- package/src/generators/ci-workflow/files/circleci/.circleci/config.yml.template +7 -4
- package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template +7 -3
- package/src/generators/ci-workflow/generator.d.ts +6 -1
- package/src/generators/ci-workflow/generator.js +20 -7
- package/src/generators/init/init.js +3 -4
- package/src/migrations/19-4-0/add-project-report-all.js +1 -1
- package/src/migrations/19-4-1/change-regex-test-production.js +1 -1
- package/src/plugin/dependencies.js +2 -2
- package/src/plugin/nodes.js +26 -2
- package/src/utils/exec-gradle.d.ts +0 -2
- package/src/utils/exec-gradle.js +3 -4
- package/src/utils/get-gradle-report.js +4 -4
- package/src/utils/has-gradle-plugin.js +1 -2
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/gradle",
|
3
|
-
"version": "19.5.0-beta.
|
3
|
+
"version": "19.5.0-beta.2",
|
4
4
|
"private": false,
|
5
5
|
"description": "The Nx Plugin for Gradle allows Gradle tasks to be run through Nx",
|
6
6
|
"repository": {
|
@@ -34,7 +34,7 @@
|
|
34
34
|
"migrations": "./migrations.json"
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
|
-
"@nx/devkit": "19.5.0-beta.
|
37
|
+
"@nx/devkit": "19.5.0-beta.2"
|
38
38
|
},
|
39
39
|
"publishConfig": {
|
40
40
|
"access": "public"
|
@@ -14,15 +14,18 @@ jobs:
|
|
14
14
|
steps:
|
15
15
|
- checkout
|
16
16
|
|
17
|
-
#
|
18
|
-
#
|
17
|
+
# This enables task distribution via Nx Cloud
|
18
|
+
# Run this command as early as possible, before dependencies are installed
|
19
|
+
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
|
20
|
+
<% if (connectedToCloud) { %>- run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-jvm" --stop-agents-after="build"
|
21
|
+
<% } else { %># Connect your workspace by running "nx connect" and uncomment this
|
19
22
|
# - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-jvm" --stop-agents-after="build"
|
20
|
-
|
23
|
+
<% } %>
|
21
24
|
- nx/set-shas:
|
22
25
|
main-branch-name: '<%= mainBranch %>'
|
23
26
|
|
24
27
|
<% for (const command of commands) { %>
|
25
|
-
|
28
|
+
<% if (command.command) { %>- run: <%= command.command %><% } else if (command.comment) { %><%= command.comment %><% } else {%>- run: <%= command %><% } %><% } %>
|
26
29
|
|
27
30
|
workflows:
|
28
31
|
version: 2
|
package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template
CHANGED
@@ -18,9 +18,13 @@ jobs:
|
|
18
18
|
with:
|
19
19
|
fetch-depth: 0
|
20
20
|
|
21
|
-
#
|
22
|
-
#
|
21
|
+
# This enables task distribution via Nx Cloud
|
22
|
+
# Run this command as early as possible, before dependencies are installed
|
23
|
+
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
|
24
|
+
<% if (connectedToCloud) { %>- run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-jvm" --stop-agents-after="build"
|
25
|
+
<% } else { %># Connect your workspace by running "nx connect" and uncomment this
|
23
26
|
# - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="5 linux-medium-jvm" --stop-agents-after="build"
|
27
|
+
<% } %>
|
24
28
|
|
25
29
|
- name: Set up JDK 17 for x64
|
26
30
|
uses: actions/setup-java@v4
|
@@ -35,4 +39,4 @@ jobs:
|
|
35
39
|
- uses: nrwl/nx-set-shas@v4
|
36
40
|
|
37
41
|
<% for (const command of commands) { %>
|
38
|
-
|
42
|
+
<% if (command.command) { %>- run: <%= command.command %><% } else if (command.comment) { %><%= command.comment %><% } else {%>- run: <%= command %><% } %><% } %>
|
@@ -1,9 +1,14 @@
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
2
|
+
export type Command = {
|
3
|
+
command: string;
|
4
|
+
} | {
|
5
|
+
comment: string;
|
6
|
+
} | string;
|
2
7
|
export interface Schema {
|
3
8
|
name: string;
|
4
9
|
ci: 'github' | 'circleci';
|
5
10
|
packageManager?: null;
|
6
|
-
commands?:
|
11
|
+
commands?: Command[];
|
7
12
|
}
|
8
13
|
export declare function ciWorkflowGenerator(tree: Tree, schema: Schema): Promise<void>;
|
9
14
|
export default ciWorkflowGenerator;
|
@@ -1,17 +1,29 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.ciWorkflowGenerator =
|
3
|
+
exports.ciWorkflowGenerator = ciWorkflowGenerator;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
5
|
const path_1 = require("path");
|
6
6
|
const nx_cloud_utils_1 = require("nx/src/utils/nx-cloud-utils");
|
7
7
|
const default_base_1 = require("nx/src/utils/default-base");
|
8
|
-
function getCiCommands(ci
|
8
|
+
function getCiCommands(ci) {
|
9
9
|
switch (ci) {
|
10
10
|
case 'circleci': {
|
11
|
-
return [
|
11
|
+
return [
|
12
|
+
{
|
13
|
+
comment: `# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected`,
|
14
|
+
},
|
15
|
+
{
|
16
|
+
command: `./nx affected --base=$NX_BASE --head=$NX_HEAD -t test build`,
|
17
|
+
},
|
18
|
+
];
|
12
19
|
}
|
13
20
|
default: {
|
14
|
-
return [
|
21
|
+
return [
|
22
|
+
{
|
23
|
+
comment: `# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected`,
|
24
|
+
},
|
25
|
+
{ command: `./nx affected -t test build` },
|
26
|
+
];
|
15
27
|
}
|
16
28
|
}
|
17
29
|
}
|
@@ -21,19 +33,19 @@ async function ciWorkflowGenerator(tree, schema) {
|
|
21
33
|
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', ci), '', options);
|
22
34
|
await (0, devkit_1.formatFiles)(tree);
|
23
35
|
}
|
24
|
-
exports.ciWorkflowGenerator = ciWorkflowGenerator;
|
25
36
|
function getTemplateData(tree, options) {
|
26
37
|
const { name: workflowName, fileName: workflowFileName } = (0, devkit_1.names)(options.name);
|
27
38
|
const packageManager = (0, devkit_1.detectPackageManager)();
|
28
39
|
const { exec: packageManagerPrefix } = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
29
40
|
let nxCloudHost = 'nx.app';
|
30
41
|
try {
|
31
|
-
const nxCloudUrl = (0, nx_cloud_utils_1.getNxCloudUrl)((0, devkit_1.
|
42
|
+
const nxCloudUrl = (0, nx_cloud_utils_1.getNxCloudUrl)((0, devkit_1.readNxJson)(tree));
|
32
43
|
nxCloudHost = new URL(nxCloudUrl).host;
|
33
44
|
}
|
34
45
|
catch { }
|
35
46
|
const mainBranch = (0, default_base_1.deduceDefaultBase)();
|
36
|
-
const commands = options.commands ?? getCiCommands(options.ci
|
47
|
+
const commands = options.commands ?? getCiCommands(options.ci);
|
48
|
+
const connectedToCloud = (0, nx_cloud_utils_1.isNxCloudUsed)((0, devkit_1.readNxJson)(tree));
|
37
49
|
return {
|
38
50
|
workflowName,
|
39
51
|
workflowFileName,
|
@@ -42,6 +54,7 @@ function getTemplateData(tree, options) {
|
|
42
54
|
commands,
|
43
55
|
mainBranch,
|
44
56
|
nxCloudHost,
|
57
|
+
connectedToCloud,
|
45
58
|
};
|
46
59
|
}
|
47
60
|
exports.default = ciWorkflowGenerator;
|
@@ -1,6 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.initGenerator = initGenerator;
|
4
|
+
exports.addBuildGradleFileNextToSettingsGradle = addBuildGradleFileNextToSettingsGradle;
|
5
|
+
exports.updateNxJsonConfiguration = updateNxJsonConfiguration;
|
4
6
|
const devkit_1 = require("@nx/devkit");
|
5
7
|
const child_process_1 = require("child_process");
|
6
8
|
const versions_1 = require("../../utils/versions");
|
@@ -27,7 +29,6 @@ Running 'gradle init':`);
|
|
27
29
|
}
|
28
30
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
29
31
|
}
|
30
|
-
exports.initGenerator = initGenerator;
|
31
32
|
function addPlugin(tree) {
|
32
33
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
33
34
|
if (!(0, has_gradle_plugin_1.hasGradlePlugin)(tree)) {
|
@@ -54,7 +55,6 @@ async function addBuildGradleFileNextToSettingsGradle(tree) {
|
|
54
55
|
addProjectReportToBuildGradle(settingsGradleFile, tree);
|
55
56
|
});
|
56
57
|
}
|
57
|
-
exports.addBuildGradleFileNextToSettingsGradle = addBuildGradleFileNextToSettingsGradle;
|
58
58
|
/**
|
59
59
|
* - creates a build.gradle file next to the settings.gradle file if it does not exist.
|
60
60
|
* - adds the project-report plugin to the build.gradle file if it does not exist.
|
@@ -134,5 +134,4 @@ function updateNxJsonConfiguration(tree) {
|
|
134
134
|
nxJson.namedInputs.production = Array.from(new Set([...productionFileSet, 'default', '!{projectRoot}/src/test/**/*']));
|
135
135
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
136
136
|
}
|
137
|
-
exports.updateNxJsonConfiguration = updateNxJsonConfiguration;
|
138
137
|
exports.default = initGenerator;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = update;
|
3
4
|
const init_1 = require("../../generators/init/init");
|
4
5
|
/**
|
5
6
|
* This migration adds task `projectReportAll` to build.gradle files
|
@@ -7,4 +8,3 @@ const init_1 = require("../../generators/init/init");
|
|
7
8
|
async function update(tree) {
|
8
9
|
await (0, init_1.addBuildGradleFileNextToSettingsGradle)(tree);
|
9
10
|
}
|
10
|
-
exports.default = update;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = update;
|
3
4
|
const devkit_1 = require("@nx/devkit");
|
4
5
|
const has_gradle_plugin_1 = require("../../utils/has-gradle-plugin");
|
5
6
|
// This function changes !{projectRoot}/test/**/* in nx.json for production to !{projectRoot}/src/test/**/*
|
@@ -18,4 +19,3 @@ function update(tree) {
|
|
18
19
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
19
20
|
}
|
20
21
|
}
|
21
|
-
exports.default = update;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.createDependencies = void 0;
|
4
|
+
exports.processGradleDependencies = processGradleDependencies;
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
5
6
|
const node_fs_1 = require("node:fs");
|
6
7
|
const node_path_1 = require("node:path");
|
@@ -79,4 +80,3 @@ function processGradleDependencies(depsFile, gradleProjectToProjectName, sourceP
|
|
79
80
|
}
|
80
81
|
}
|
81
82
|
}
|
82
|
-
exports.processGradleDependencies = processGradleDependencies;
|
package/src/plugin/nodes.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createNodes = exports.makeCreateNodesForGradleConfigFile = exports.createNodesV2 =
|
3
|
+
exports.createNodes = exports.makeCreateNodesForGradleConfigFile = exports.createNodesV2 = void 0;
|
4
|
+
exports.writeTargetsToCache = writeTargetsToCache;
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
5
6
|
const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
|
6
7
|
const node_fs_1 = require("node:fs");
|
@@ -29,7 +30,6 @@ function readTargetsCache(cachePath) {
|
|
29
30
|
function writeTargetsToCache(cachePath, results) {
|
30
31
|
(0, devkit_1.writeJsonFile)(cachePath, results);
|
31
32
|
}
|
32
|
-
exports.writeTargetsToCache = writeTargetsToCache;
|
33
33
|
exports.createNodesV2 = [
|
34
34
|
get_gradle_report_1.gradleConfigAndTestGlob,
|
35
35
|
async (files, options, context) => {
|
@@ -133,6 +133,14 @@ async function createGradleTargets(tasks, options, context, outputDirs, gradlePr
|
|
133
133
|
dependsOn: dependsOnMap[task.name],
|
134
134
|
metadata: {
|
135
135
|
technologies: ['gradle'],
|
136
|
+
help: {
|
137
|
+
command: `${(0, exec_gradle_1.getGradleExecFile)()} help --task ${taskCommandToRun}`,
|
138
|
+
example: {
|
139
|
+
options: {
|
140
|
+
args: ['--rerun'],
|
141
|
+
},
|
142
|
+
},
|
143
|
+
},
|
136
144
|
},
|
137
145
|
...(outputs && outputs.length ? { outputs } : {}),
|
138
146
|
};
|
@@ -175,6 +183,14 @@ function getTestCiTargets(testFiles, gradleProject, testTargetName, ciTargetName
|
|
175
183
|
metadata: {
|
176
184
|
technologies: ['gradle'],
|
177
185
|
description: `Runs Gradle test ${testFile} in CI`,
|
186
|
+
help: {
|
187
|
+
command: `${(0, exec_gradle_1.getGradleExecFile)()} help --task ${taskCommandToRun}`,
|
188
|
+
example: {
|
189
|
+
options: {
|
190
|
+
args: ['--rerun'],
|
191
|
+
},
|
192
|
+
},
|
193
|
+
},
|
178
194
|
},
|
179
195
|
...(outputs && outputs.length > 0 ? { outputs } : {}),
|
180
196
|
};
|
@@ -195,6 +211,14 @@ function getTestCiTargets(testFiles, gradleProject, testTargetName, ciTargetName
|
|
195
211
|
technologies: ['gradle'],
|
196
212
|
description: 'Runs Gradle Tests in CI',
|
197
213
|
nonAtomizedTarget: testTargetName,
|
214
|
+
help: {
|
215
|
+
command: `${(0, exec_gradle_1.getGradleExecFile)()} help --task ${taskCommandToRun}`,
|
216
|
+
example: {
|
217
|
+
options: {
|
218
|
+
args: ['--rerun'],
|
219
|
+
},
|
220
|
+
},
|
221
|
+
},
|
198
222
|
},
|
199
223
|
};
|
200
224
|
targetGroups[targetGroupName].push(ciTargetName);
|
package/src/utils/exec-gradle.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.getGradleBinaryPath = getGradleBinaryPath;
|
4
|
+
exports.getGradleExecFile = getGradleExecFile;
|
5
|
+
exports.execGradleAsync = execGradleAsync;
|
4
6
|
const devkit_1 = require("@nx/devkit");
|
5
7
|
const node_child_process_1 = require("node:child_process");
|
6
8
|
const node_fs_1 = require("node:fs");
|
@@ -15,11 +17,9 @@ function getGradleBinaryPath() {
|
|
15
17
|
}
|
16
18
|
return gradleBinaryPath;
|
17
19
|
}
|
18
|
-
exports.getGradleBinaryPath = getGradleBinaryPath;
|
19
20
|
function getGradleExecFile() {
|
20
21
|
return process.platform.startsWith('win') ? '.\\gradlew.bat' : './gradlew';
|
21
22
|
}
|
22
|
-
exports.getGradleExecFile = getGradleExecFile;
|
23
23
|
function execGradleAsync(args, execOptions = {}) {
|
24
24
|
const gradleBinaryPath = getGradleBinaryPath();
|
25
25
|
return new Promise((res, rej) => {
|
@@ -43,4 +43,3 @@ function execGradleAsync(args, execOptions = {}) {
|
|
43
43
|
});
|
44
44
|
});
|
45
45
|
}
|
46
|
-
exports.execGradleAsync = execGradleAsync;
|
@@ -1,6 +1,9 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.gradleConfigAndTestGlob = exports.gradleConfigGlob = exports.GRADLE_TEST_FILES = exports.GRADLE_BUILD_FILES = exports.newLineSeparator = exports.fileSeparator = void 0;
|
4
|
+
exports.getCurrentGradleReport = getCurrentGradleReport;
|
5
|
+
exports.populateGradleReport = populateGradleReport;
|
6
|
+
exports.processProjectReports = processProjectReports;
|
4
7
|
const node_fs_1 = require("node:fs");
|
5
8
|
const node_path_1 = require("node:path");
|
6
9
|
const devkit_1 = require("@nx/devkit");
|
@@ -28,7 +31,6 @@ function getCurrentGradleReport() {
|
|
28
31
|
}
|
29
32
|
return gradleReportCache;
|
30
33
|
}
|
31
|
-
exports.getCurrentGradleReport = getCurrentGradleReport;
|
32
34
|
async function populateGradleReport(workspaceRoot) {
|
33
35
|
const gradleConfigHash = await (0, workspace_context_1.hashWithWorkspaceContext)(workspaceRoot, [
|
34
36
|
exports.gradleConfigGlob,
|
@@ -67,7 +69,6 @@ async function populateGradleReport(workspaceRoot) {
|
|
67
69
|
performance.measure('gradleProjectReport', gradleProjectReportStart.name, gradleProjectReportEnd.name);
|
68
70
|
gradleReportCache = processProjectReports(projectReportLines);
|
69
71
|
}
|
70
|
-
exports.populateGradleReport = populateGradleReport;
|
71
72
|
function processProjectReports(projectReportLines) {
|
72
73
|
/**
|
73
74
|
* Map of Gradle File path to Gradle Project Name
|
@@ -181,4 +182,3 @@ function processProjectReports(projectReportLines) {
|
|
181
182
|
gradleProjectToProjectName,
|
182
183
|
};
|
183
184
|
}
|
184
|
-
exports.processProjectReports = processProjectReports;
|
@@ -1,9 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.hasGradlePlugin =
|
3
|
+
exports.hasGradlePlugin = hasGradlePlugin;
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
5
5
|
function hasGradlePlugin(tree) {
|
6
6
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
7
7
|
return !!nxJson.plugins?.some((p) => typeof p === 'string' ? p === '@nx/gradle' : p.plugin === '@nx/gradle');
|
8
8
|
}
|
9
|
-
exports.hasGradlePlugin = hasGradlePlugin;
|