@nx/gradle 0.0.0-pr-11-e92ae29 → 0.0.0-pr-29464-ce29f31
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/executors.json +10 -0
- package/native/gradle.properties +7 -0
- package/native/project.json +4 -0
- package/package.json +4 -2
- package/plugin-v1.d.ts +2 -0
- package/plugin-v1.js +8 -0
- package/plugin.d.ts +1 -1
- package/plugin.js +1 -2
- package/src/executors/gradlew/gradlew.impl.d.ts +8 -0
- package/src/executors/gradlew/gradlew.impl.js +46 -0
- package/src/executors/gradlew/schema.json +9 -0
- package/src/generators/ci-workflow/files/circleci/.circleci/config.yml.template +1 -1
- package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template +3 -3
- package/src/generators/init/init.js +24 -41
- package/src/migrations/19-4-0/add-project-report-all.d.ts +4 -0
- package/src/migrations/19-4-0/add-project-report-all.js +83 -2
- package/src/plugin/dependencies.js +23 -55
- package/src/plugin/nodes.d.ts +3 -16
- package/src/plugin/nodes.js +19 -224
- package/src/plugin/utils/__mocks__/gradle_composite.json +38 -0
- package/src/plugin/utils/__mocks__/gradle_nx_list.json +590 -0
- package/src/plugin/utils/__mocks__/gradle_tutorial.json +344 -0
- package/src/plugin/utils/create-ci-targets.d.ts +13 -0
- package/src/plugin/utils/create-ci-targets.js +107 -0
- package/src/plugin/utils/get-create-nodes-lines.d.ts +1 -0
- package/src/plugin/utils/get-create-nodes-lines.js +45 -0
- package/src/plugin/utils/get-nodes-from-gradle-plugin.d.ts +25 -0
- package/src/plugin/utils/get-nodes-from-gradle-plugin.js +111 -0
- package/src/plugin/utils/gradle-plugin-options.d.ts +6 -0
- package/src/plugin/utils/gradle-plugin-options.js +8 -0
- package/src/plugin-v1/dependencies.d.ts +2 -0
- package/src/plugin-v1/dependencies.js +64 -0
- package/src/plugin-v1/nodes.d.ts +20 -0
- package/src/plugin-v1/nodes.js +266 -0
- package/src/{utils → plugin-v1/utils}/get-gradle-report.js +11 -10
- package/src/{utils → plugin-v1/utils}/get-project-report-lines.d.ts +0 -2
- package/src/{utils → plugin-v1/utils}/get-project-report-lines.js +2 -9
- package/src/utils/exec-gradle.d.ts +2 -0
- package/src/utils/exec-gradle.js +7 -0
- /package/src/{utils → plugin-v1/utils}/get-gradle-report.d.ts +0 -0
package/executors.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"executors": {
|
|
3
|
+
"gradlew": {
|
|
4
|
+
"batchImplementation": "./src/executors/gradlew/gradlew.impl#batchGradlew",
|
|
5
|
+
"implementation": "./src/executors/gradlew/gradlew.impl",
|
|
6
|
+
"schema": "./src/executors/gradlew/schema.json",
|
|
7
|
+
"description": "gradlew.impl executor"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# This file was generated by the Gradle 'init' task.
|
|
2
|
+
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
|
|
3
|
+
|
|
4
|
+
org.gradle.parallel=true
|
|
5
|
+
org.gradle.caching=true
|
|
6
|
+
org.gradle.configuration-cache=false
|
|
7
|
+
version=0.0.1-alpha.3
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/gradle",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-29464-ce29f31",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Gradle allows Gradle tasks to be run through Nx",
|
|
6
6
|
"repository": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"generators": "./generators.json",
|
|
27
27
|
"exports": {
|
|
28
28
|
".": "./index.js",
|
|
29
|
+
"./plugin-v1": "./plugin-v1.js",
|
|
29
30
|
"./package.json": "./package.json",
|
|
30
31
|
"./migrations.json": "./migrations.json",
|
|
31
32
|
"./generators.json": "./generators.json"
|
|
@@ -34,11 +35,12 @@
|
|
|
34
35
|
"migrations": "./migrations.json"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@nx/devkit": "0.0.0-pr-
|
|
38
|
+
"@nx/devkit": "0.0.0-pr-29464-ce29f31"
|
|
38
39
|
},
|
|
39
40
|
"publishConfig": {
|
|
40
41
|
"access": "public"
|
|
41
42
|
},
|
|
43
|
+
"executors": "./executors.json",
|
|
42
44
|
"types": "./index.d.ts",
|
|
43
45
|
"type": "commonjs"
|
|
44
46
|
}
|
package/plugin-v1.d.ts
ADDED
package/plugin-v1.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createNodesV2 = exports.createNodes = exports.createDependencies = void 0;
|
|
4
|
+
var dependencies_1 = require("./src/plugin-v1/dependencies");
|
|
5
|
+
Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return dependencies_1.createDependencies; } });
|
|
6
|
+
var nodes_1 = require("./src/plugin-v1/nodes");
|
|
7
|
+
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return nodes_1.createNodes; } });
|
|
8
|
+
Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return nodes_1.createNodesV2; } });
|
package/plugin.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { createDependencies } from './src/plugin/dependencies';
|
|
2
|
-
export {
|
|
2
|
+
export { createNodesV2 } from './src/plugin/nodes';
|
package/plugin.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createNodesV2 = exports.
|
|
3
|
+
exports.createNodesV2 = exports.createDependencies = void 0;
|
|
4
4
|
var dependencies_1 = require("./src/plugin/dependencies");
|
|
5
5
|
Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return dependencies_1.createDependencies; } });
|
|
6
6
|
var nodes_1 = require("./src/plugin/nodes");
|
|
7
|
-
Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return nodes_1.createNodes; } });
|
|
8
7
|
Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return nodes_1.createNodesV2; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
export declare function graldewExecutor(options: RunCommandsOptions, context: ExecutorContext): Promise<{
|
|
5
|
+
success: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
export default graldewExecutor;
|
|
8
|
+
export declare function batchGradlew(taskGraph: TaskGraph, inputs: Record<string, RunCommandsOptions>, overrides: RunCommandsOptions, context: ExecutorContext): Promise<BatchResults>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.graldewExecutor = graldewExecutor;
|
|
4
|
+
exports.batchGradlew = batchGradlew;
|
|
5
|
+
const run_commands_impl_1 = require("nx/src/executors/run-commands/run-commands.impl");
|
|
6
|
+
const MAX_PROJECTS_IN_BATCH = 10;
|
|
7
|
+
async function graldewExecutor(options, context) {
|
|
8
|
+
const results = await (0, run_commands_impl_1.default)(options, context);
|
|
9
|
+
return { success: results.success };
|
|
10
|
+
}
|
|
11
|
+
exports.default = graldewExecutor;
|
|
12
|
+
async function batchGradlew(taskGraph, inputs, overrides, context) {
|
|
13
|
+
const regex = /[./\\]*gradlew[\w.-]*/;
|
|
14
|
+
let gradlewCommand;
|
|
15
|
+
const roots = taskGraph.roots.slice(0, MAX_PROJECTS_IN_BATCH);
|
|
16
|
+
const tasksRan = [];
|
|
17
|
+
const results = {};
|
|
18
|
+
const gradlewTasks = roots.flatMap((task) => {
|
|
19
|
+
const gradlewTask = inputs[task].command;
|
|
20
|
+
if (typeof gradlewTask !== 'string')
|
|
21
|
+
return [];
|
|
22
|
+
const match = gradlewTask.match(regex);
|
|
23
|
+
if (!match)
|
|
24
|
+
return [];
|
|
25
|
+
results[task] = { success: false, terminalOutput: '' };
|
|
26
|
+
tasksRan.push(task);
|
|
27
|
+
gradlewCommand = match[0]; // Store the first found gradlewCommand
|
|
28
|
+
return gradlewTask.replace(gradlewCommand, '').trim();
|
|
29
|
+
});
|
|
30
|
+
const startTime = Date.now();
|
|
31
|
+
const { success, terminalOutput } = await (0, run_commands_impl_1.default)({
|
|
32
|
+
command: `${gradlewCommand} ${gradlewTasks.join(' ')}`,
|
|
33
|
+
__unparsed__: [],
|
|
34
|
+
...(overrides ?? {}),
|
|
35
|
+
}, context);
|
|
36
|
+
const endTime = Date.now();
|
|
37
|
+
tasksRan.forEach((task) => {
|
|
38
|
+
results[task] = {
|
|
39
|
+
success,
|
|
40
|
+
terminalOutput,
|
|
41
|
+
startTime,
|
|
42
|
+
endTime,
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
return results;
|
|
46
|
+
}
|
package/src/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template
CHANGED
|
@@ -24,15 +24,15 @@ jobs:
|
|
|
24
24
|
<% 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<% } %>
|
|
25
25
|
# - run: <%= packageManagerPrefix %> nx-cloud start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="build"
|
|
26
26
|
|
|
27
|
-
- name: Set up JDK
|
|
27
|
+
- name: Set up JDK 21 for x64
|
|
28
28
|
uses: actions/setup-java@v4
|
|
29
29
|
with:
|
|
30
|
-
java-version: '
|
|
30
|
+
java-version: '21'
|
|
31
31
|
distribution: 'temurin'
|
|
32
32
|
architecture: x64
|
|
33
33
|
|
|
34
34
|
- name: Setup Gradle
|
|
35
|
-
uses: gradle/gradle-build-action@
|
|
35
|
+
uses: gradle/gradle-build-action@v4
|
|
36
36
|
|
|
37
37
|
- uses: nrwl/nx-set-shas@v4
|
|
38
38
|
|
|
@@ -7,6 +7,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
7
7
|
const versions_1 = require("../../utils/versions");
|
|
8
8
|
const has_gradle_plugin_1 = require("../../utils/has-gradle-plugin");
|
|
9
9
|
const path_1 = require("path");
|
|
10
|
+
const nativePluginName = 'dev.nx.gradle.native';
|
|
10
11
|
async function initGenerator(tree, options) {
|
|
11
12
|
const tasks = [];
|
|
12
13
|
if (!options.skipPackageJson && tree.exists('package.json')) {
|
|
@@ -32,7 +33,6 @@ function addPlugin(tree) {
|
|
|
32
33
|
testTargetName: 'test',
|
|
33
34
|
classesTargetName: 'classes',
|
|
34
35
|
buildTargetName: 'build',
|
|
35
|
-
includeSubprojectsTasks: false,
|
|
36
36
|
},
|
|
37
37
|
});
|
|
38
38
|
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
@@ -46,15 +46,14 @@ async function addBuildGradleFileNextToSettingsGradle(tree) {
|
|
|
46
46
|
'**/settings.gradle?(.kts)',
|
|
47
47
|
]);
|
|
48
48
|
settingsGradleFiles.forEach((settingsGradleFile) => {
|
|
49
|
-
|
|
49
|
+
addCreateNodesPluginToBuildGradle(settingsGradleFile, tree);
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* - creates a build.gradle file next to the settings.gradle file if it does not exist.
|
|
54
|
-
* - adds the
|
|
55
|
-
* - adds a task to generate project reports for all subprojects and included builds.
|
|
54
|
+
* - adds the createNodes plugin to the build.gradle file if it does not exist.
|
|
56
55
|
*/
|
|
57
|
-
function
|
|
56
|
+
function addCreateNodesPluginToBuildGradle(settingsGradleFile, tree) {
|
|
58
57
|
const filename = (0, path_1.basename)(settingsGradleFile);
|
|
59
58
|
let gradleFilePath = 'build.gradle';
|
|
60
59
|
if (filename.endsWith('.kts')) {
|
|
@@ -68,53 +67,37 @@ function addProjectReportToBuildGradle(settingsGradleFile, tree) {
|
|
|
68
67
|
else {
|
|
69
68
|
buildGradleContent = tree.read(gradleFilePath).toString();
|
|
70
69
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
const applyNodesPlugin = `plugin("${nativePluginName}")`;
|
|
71
|
+
if (buildGradleContent.includes('allprojects {')) {
|
|
72
|
+
if (!buildGradleContent.includes(applyNodesPlugin)) {
|
|
73
|
+
devkit_1.logger.warn(`Please add the ${nativePluginName} plugin to your ${gradleFilePath}:
|
|
74
74
|
allprojects {
|
|
75
75
|
apply {
|
|
76
|
-
|
|
76
|
+
${applyNodesPlugin}
|
|
77
77
|
}
|
|
78
78
|
}`);
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
else {
|
|
82
|
-
buildGradleContent
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
}`;
|
|
82
|
+
buildGradleContent = `${buildGradleContent}\n\rallprojects {
|
|
83
|
+
apply {
|
|
84
|
+
${applyNodesPlugin}
|
|
87
85
|
}
|
|
88
|
-
|
|
89
|
-
if (gradleFilePath.endsWith('.kts')) {
|
|
90
|
-
buildGradleContent += `\n\rtasks.register("projectReportAll") {
|
|
91
|
-
// All project reports of subprojects
|
|
92
|
-
allprojects.forEach {
|
|
93
|
-
dependsOn(it.tasks.get("projectReport"))
|
|
86
|
+
}`;
|
|
94
87
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
else {
|
|
103
|
-
buildGradleContent += `\n\rtasks.register("projectReportAll") {
|
|
104
|
-
// All project reports of subprojects
|
|
105
|
-
allprojects.forEach {
|
|
106
|
-
dependsOn(it.tasks.getAt("projectReport"))
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// All projectReportAll of included builds
|
|
110
|
-
gradle.includedBuilds.forEach {
|
|
111
|
-
dependsOn(it.task(":projectReportAll"))
|
|
112
|
-
}
|
|
113
|
-
}`;
|
|
88
|
+
const nodesPlugin = filename.endsWith('.kts')
|
|
89
|
+
? `id("${nativePluginName}") version("+")`
|
|
90
|
+
: `id "${nativePluginName}" version "+"`;
|
|
91
|
+
if (buildGradleContent.includes('plugins {')) {
|
|
92
|
+
if (!buildGradleContent.includes(nativePluginName)) {
|
|
93
|
+
buildGradleContent = buildGradleContent.replace('plugins {', `plugins {
|
|
94
|
+
${nodesPlugin}`);
|
|
114
95
|
}
|
|
115
96
|
}
|
|
116
|
-
|
|
117
|
-
|
|
97
|
+
else {
|
|
98
|
+
buildGradleContent = `plugins {
|
|
99
|
+
${nodesPlugin}
|
|
100
|
+
}\n\r${buildGradleContent}`;
|
|
118
101
|
}
|
|
119
102
|
}
|
|
120
103
|
function updateNxJsonConfiguration(tree) {
|
|
@@ -3,3 +3,7 @@ import { Tree } from '@nx/devkit';
|
|
|
3
3
|
* This migration adds task `projectReportAll` to build.gradle files
|
|
4
4
|
*/
|
|
5
5
|
export default function update(tree: Tree): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* This function creates and populate build.gradle file next to the settings.gradle file.
|
|
8
|
+
*/
|
|
9
|
+
export declare function addBuildGradleFileNextToSettingsGradle(tree: Tree): Promise<void>;
|
|
@@ -1,10 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = update;
|
|
4
|
-
|
|
4
|
+
exports.addBuildGradleFileNextToSettingsGradle = addBuildGradleFileNextToSettingsGradle;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
5
7
|
/**
|
|
6
8
|
* This migration adds task `projectReportAll` to build.gradle files
|
|
7
9
|
*/
|
|
8
10
|
async function update(tree) {
|
|
9
|
-
await
|
|
11
|
+
await addBuildGradleFileNextToSettingsGradle(tree);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* This function creates and populate build.gradle file next to the settings.gradle file.
|
|
15
|
+
*/
|
|
16
|
+
async function addBuildGradleFileNextToSettingsGradle(tree) {
|
|
17
|
+
const settingsGradleFiles = await (0, devkit_1.globAsync)(tree, [
|
|
18
|
+
'**/settings.gradle?(.kts)',
|
|
19
|
+
]);
|
|
20
|
+
settingsGradleFiles.forEach((settingsGradleFile) => {
|
|
21
|
+
addProjectReportToBuildGradle(settingsGradleFile, tree);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* - creates a build.gradle file next to the settings.gradle file if it does not exist.
|
|
26
|
+
* - adds the project-report plugin to the build.gradle file if it does not exist.
|
|
27
|
+
* - adds a task to generate project reports for all subprojects and included builds.
|
|
28
|
+
*/
|
|
29
|
+
function addProjectReportToBuildGradle(settingsGradleFile, tree) {
|
|
30
|
+
const filename = (0, node_path_1.basename)(settingsGradleFile);
|
|
31
|
+
let gradleFilePath = 'build.gradle';
|
|
32
|
+
if (filename.endsWith('.kts')) {
|
|
33
|
+
gradleFilePath = 'build.gradle.kts';
|
|
34
|
+
}
|
|
35
|
+
gradleFilePath = (0, node_path_1.join)((0, node_path_1.dirname)(settingsGradleFile), gradleFilePath);
|
|
36
|
+
let buildGradleContent = '';
|
|
37
|
+
if (!tree.exists(gradleFilePath)) {
|
|
38
|
+
tree.write(gradleFilePath, buildGradleContent); // create a build.gradle file near settings.gradle file if it does not exist
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
buildGradleContent = tree.read(gradleFilePath).toString();
|
|
42
|
+
}
|
|
43
|
+
if (buildGradleContent.includes('allprojects')) {
|
|
44
|
+
if (!buildGradleContent.includes('"project-report"')) {
|
|
45
|
+
devkit_1.logger.warn(`Please add the project-report plugin to your ${gradleFilePath}:
|
|
46
|
+
allprojects {
|
|
47
|
+
apply {
|
|
48
|
+
plugin("project-report")
|
|
49
|
+
}
|
|
50
|
+
}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
buildGradleContent += `\n\rallprojects {
|
|
55
|
+
apply {
|
|
56
|
+
plugin("project-report")
|
|
57
|
+
}
|
|
58
|
+
}`;
|
|
59
|
+
}
|
|
60
|
+
if (!buildGradleContent.includes(`tasks.register("projectReportAll")`)) {
|
|
61
|
+
if (gradleFilePath.endsWith('.kts')) {
|
|
62
|
+
buildGradleContent += `\n\rtasks.register("projectReportAll") {
|
|
63
|
+
// All project reports of subprojects
|
|
64
|
+
allprojects.forEach {
|
|
65
|
+
dependsOn(it.tasks.get("projectReport"))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// All projectReportAll of included builds
|
|
69
|
+
gradle.includedBuilds.forEach {
|
|
70
|
+
dependsOn(it.task(":projectReportAll"))
|
|
71
|
+
}
|
|
72
|
+
}`;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
buildGradleContent += `\n\rtasks.register("projectReportAll") {
|
|
76
|
+
// All project reports of subprojects
|
|
77
|
+
allprojects.forEach {
|
|
78
|
+
dependsOn(it.tasks.getAt("projectReport"))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// All projectReportAll of included builds
|
|
82
|
+
gradle.includedBuilds.forEach {
|
|
83
|
+
dependsOn(it.task(":projectReportAll"))
|
|
84
|
+
}
|
|
85
|
+
}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (buildGradleContent) {
|
|
89
|
+
tree.write(gradleFilePath, buildGradleContent);
|
|
90
|
+
}
|
|
10
91
|
}
|
|
@@ -3,62 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createDependencies = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
|
-
const
|
|
7
|
-
const split_config_files_1 = require("../utils/split-config-files");
|
|
6
|
+
const get_nodes_from_gradle_plugin_1 = require("./utils/get-nodes-from-gradle-plugin");
|
|
8
7
|
const createDependencies = async (_, context) => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const dependedProjects = buildFileToDepsMap.get(gradleFile);
|
|
20
|
-
if (projectName && dependedProjects?.size) {
|
|
21
|
-
dependedProjects?.forEach((dependedProject) => {
|
|
22
|
-
const targetProjectRoot = gradleProjectNameToProjectRootMap.get(dependedProject);
|
|
23
|
-
const targetProjectName = Object.values(context.projects).find((project) => project.root === targetProjectRoot)?.name;
|
|
24
|
-
if (targetProjectName) {
|
|
25
|
-
const dependency = {
|
|
26
|
-
source: projectName,
|
|
27
|
-
target: targetProjectName,
|
|
28
|
-
type: devkit_1.DependencyType.static,
|
|
29
|
-
sourceFile: gradleFile,
|
|
30
|
-
};
|
|
31
|
-
(0, devkit_1.validateDependency)(dependency, context);
|
|
32
|
-
dependencies.add(dependency);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
gradleProjectToChildProjects.get(gradleProject)?.forEach((childProject) => {
|
|
37
|
-
if (childProject) {
|
|
38
|
-
const dependency = {
|
|
39
|
-
source: projectName,
|
|
40
|
-
target: childProject,
|
|
41
|
-
type: devkit_1.DependencyType.static,
|
|
42
|
-
sourceFile: gradleFile,
|
|
43
|
-
};
|
|
44
|
-
(0, devkit_1.validateDependency)(dependency, context);
|
|
45
|
-
dependencies.add(dependency);
|
|
8
|
+
const { dependencies: dependenciesFromReport } = (0, get_nodes_from_gradle_plugin_1.getCurrentNodesReport)();
|
|
9
|
+
const dependencies = [];
|
|
10
|
+
dependenciesFromReport.forEach((dependencyFromPlugin) => {
|
|
11
|
+
try {
|
|
12
|
+
const source = (0, node_path_1.relative)(devkit_1.workspaceRoot, dependencyFromPlugin.source) || '.';
|
|
13
|
+
const sourceProjectName = Object.values(context.projects).find((project) => source === project.root)?.name ?? dependencyFromPlugin.source;
|
|
14
|
+
const target = (0, node_path_1.relative)(devkit_1.workspaceRoot, dependencyFromPlugin.target) || '.';
|
|
15
|
+
const targetProjectName = Object.values(context.projects).find((project) => target === project.root)?.name ?? dependencyFromPlugin.target;
|
|
16
|
+
if (!sourceProjectName || !targetProjectName) {
|
|
17
|
+
return;
|
|
46
18
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
19
|
+
const dependency = {
|
|
20
|
+
source: sourceProjectName,
|
|
21
|
+
target: targetProjectName,
|
|
22
|
+
type: devkit_1.DependencyType.static,
|
|
23
|
+
sourceFile: (0, node_path_1.relative)(devkit_1.workspaceRoot, dependencyFromPlugin.sourceFile),
|
|
24
|
+
};
|
|
25
|
+
(0, devkit_1.validateDependency)(dependency, context);
|
|
26
|
+
dependencies.push(dependency);
|
|
27
|
+
}
|
|
28
|
+
catch { } // ignore invalid dependencies
|
|
29
|
+
});
|
|
30
|
+
return dependencies;
|
|
52
31
|
};
|
|
53
32
|
exports.createDependencies = createDependencies;
|
|
54
|
-
function findGradleFiles(fileMap) {
|
|
55
|
-
const gradleFiles = [];
|
|
56
|
-
for (const [_, files] of Object.entries(fileMap.projectFileMap)) {
|
|
57
|
-
for (const file of files) {
|
|
58
|
-
if (split_config_files_1.GRADLE_BUILD_FILES.has((0, node_path_1.basename)(file.file))) {
|
|
59
|
-
gradleFiles.push(file.file);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return gradleFiles;
|
|
64
|
-
}
|
package/src/plugin/nodes.d.ts
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export interface GradlePluginOptions {
|
|
4
|
-
includeSubprojectsTasks?: boolean;
|
|
5
|
-
ciTargetName?: string;
|
|
6
|
-
testTargetName?: string;
|
|
7
|
-
classesTargetName?: string;
|
|
8
|
-
buildTargetName?: string;
|
|
9
|
-
[taskTargetName: string]: string | undefined | boolean;
|
|
10
|
-
}
|
|
1
|
+
import { CreateNodesV2, ProjectConfiguration, CreateNodesFunction, ProjectGraphExternalNode } from '@nx/devkit';
|
|
2
|
+
import { GradlePluginOptions } from './utils/gradle-plugin-options';
|
|
11
3
|
type GradleTargets = Record<string, Partial<ProjectConfiguration>>;
|
|
12
4
|
export declare function writeTargetsToCache(cachePath: string, results: GradleTargets): void;
|
|
13
5
|
export declare const createNodesV2: CreateNodesV2<GradlePluginOptions>;
|
|
14
|
-
export declare const makeCreateNodesForGradleConfigFile: (
|
|
15
|
-
/**
|
|
16
|
-
@deprecated This is replaced with {@link createNodesV2}. Update your plugin to export its own `createNodesV2` function that wraps this one instead.
|
|
17
|
-
This function will change to the v2 function in Nx 20.
|
|
18
|
-
*/
|
|
19
|
-
export declare const createNodes: CreateNodes<GradlePluginOptions>;
|
|
6
|
+
export declare const makeCreateNodesForGradleConfigFile: (projects: Record<string, Partial<ProjectConfiguration>>, targetsCache?: GradleTargets, externalNodes?: Record<string, ProjectGraphExternalNode>) => CreateNodesFunction;
|
|
20
7
|
export {};
|