@nx/gradle 19.0.0-canary.20240420-9ca53b7 → 19.0.0-canary.20240425-cec57c4
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
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nx/gradle",
|
3
|
-
"version": "19.0.0-canary.
|
3
|
+
"version": "19.0.0-canary.20240425-cec57c4",
|
4
4
|
"private": false,
|
5
5
|
"description": "The Nx Plugin for Gradle allows Gradle tasks to be run through Nx",
|
6
6
|
"repository": {
|
@@ -33,7 +33,7 @@
|
|
33
33
|
"migrations": "./migrations.json"
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
|
-
"@nx/devkit": "19.0.0-canary.
|
36
|
+
"@nx/devkit": "19.0.0-canary.20240425-cec57c4"
|
37
37
|
},
|
38
38
|
"publishConfig": {
|
39
39
|
"access": "public"
|
package/src/plugin/nodes.js
CHANGED
@@ -90,8 +90,9 @@ function createGradleTargets(tasks, projectRoot, options, context, outputDirs) {
|
|
90
90
|
for (const task of tasks) {
|
91
91
|
const targetName = options?.[`${task.name}TargetName`] ?? task.name;
|
92
92
|
const outputs = outputDirs.get(task.name);
|
93
|
+
const path = (0, node_path_1.relative)((0, node_path_1.join)(context.workspaceRoot, projectRoot), (0, exec_gradle_1.getGradleBinaryPath)());
|
93
94
|
targets[targetName] = {
|
94
|
-
command: `${
|
95
|
+
command: `${path} ${task.name}`,
|
95
96
|
options: {
|
96
97
|
cwd: projectRoot,
|
97
98
|
},
|
@@ -2,6 +2,6 @@
|
|
2
2
|
/// <reference types="node" />
|
3
3
|
import { ExecFileOptions } from 'child_process';
|
4
4
|
import { ExecFileSyncOptionsWithBufferEncoding } from 'node:child_process';
|
5
|
-
export declare function execGradle(args: string[], execOptions
|
5
|
+
export declare function execGradle(args: string[], execOptions?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
|
6
6
|
export declare function getGradleBinaryPath(): string;
|
7
|
-
export declare function execGradleAsync(args: ReadonlyArray<string>, execOptions
|
7
|
+
export declare function execGradleAsync(args: ReadonlyArray<string>, execOptions?: ExecFileOptions): Promise<Buffer>;
|
package/src/utils/exec-gradle.js
CHANGED
@@ -23,9 +23,6 @@ function getGradleBinaryPath() {
|
|
23
23
|
exports.getGradleBinaryPath = getGradleBinaryPath;
|
24
24
|
function execGradleAsync(args, execOptions) {
|
25
25
|
const gradleBinaryPath = getGradleBinaryPath();
|
26
|
-
if (!(0, node_fs_1.existsSync)(gradleBinaryPath)) {
|
27
|
-
throw new Error('Gradle is not setup. Run "gradle init"');
|
28
|
-
}
|
29
26
|
return new Promise((res, rej) => {
|
30
27
|
const cp = (0, node_child_process_1.execFile)(gradleBinaryPath, args, execOptions);
|
31
28
|
let stdout = Buffer.from('');
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
export declare const fileSeparator: string;
|
2
|
+
export interface GradleReport {
|
2
3
|
gradleFileToGradleProjectMap: Map<string, string>;
|
3
4
|
buildFileToDepsMap: Map<string, string>;
|
4
5
|
gradleFileToOutputDirsMap: Map<string, Map<string, string>>;
|
@@ -7,4 +8,4 @@ interface GradleReport {
|
|
7
8
|
}
|
8
9
|
export declare function invalidateGradleReportCache(): void;
|
9
10
|
export declare function getGradleReport(): GradleReport;
|
10
|
-
export
|
11
|
+
export declare function processProjectReports(projectReportLines: string[]): GradleReport;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getGradleReport = exports.invalidateGradleReportCache = void 0;
|
3
|
+
exports.processProjectReports = exports.getGradleReport = exports.invalidateGradleReportCache = exports.fileSeparator = void 0;
|
4
4
|
const node_fs_1 = require("node:fs");
|
5
5
|
const node_path_1 = require("node:path");
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
7
7
|
const exec_gradle_1 = require("./exec-gradle");
|
8
|
-
|
8
|
+
exports.fileSeparator = process.platform.startsWith('win')
|
9
9
|
? 'file:///'
|
10
10
|
: 'file://';
|
11
11
|
const newLineSeparator = process.platform.startsWith('win') ? '\r\n' : '\n';
|
@@ -54,20 +54,29 @@ function processProjectReports(projectReportLines) {
|
|
54
54
|
* e.g. {build.gradle.kts: { projectReportDir: '' testReportDir: '' }}
|
55
55
|
*/
|
56
56
|
const gradleFileToOutputDirsMap = new Map();
|
57
|
-
|
57
|
+
let index = 0;
|
58
|
+
while (index < projectReportLines.length) {
|
59
|
+
const line = projectReportLines[index].trim();
|
58
60
|
if (line.startsWith('> Task ')) {
|
59
|
-
const nextLine = projectReportLines[index + 1];
|
60
61
|
if (line.endsWith(':dependencyReport')) {
|
61
62
|
const gradleProject = line.substring('> Task '.length, line.length - ':dependencyReport'.length);
|
62
|
-
|
63
|
+
while (index < projectReportLines.length &&
|
64
|
+
!projectReportLines[index].includes(exports.fileSeparator)) {
|
65
|
+
index++;
|
66
|
+
}
|
67
|
+
const [_, file] = projectReportLines[index].split(exports.fileSeparator);
|
63
68
|
dependenciesMap.set(gradleProject, file);
|
64
69
|
}
|
65
70
|
if (line.endsWith('propertyReport')) {
|
66
71
|
const gradleProject = line.substring('> Task '.length, line.length - ':propertyReport'.length);
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
72
|
+
while (index < projectReportLines.length &&
|
73
|
+
!projectReportLines[index].includes(exports.fileSeparator)) {
|
74
|
+
index++;
|
75
|
+
}
|
76
|
+
const [_, file] = projectReportLines[index].split(exports.fileSeparator);
|
77
|
+
const propertyReportLines = (0, node_fs_1.existsSync)(file)
|
78
|
+
? (0, node_fs_1.readFileSync)(file).toString().split(newLineSeparator)
|
79
|
+
: [];
|
71
80
|
let projectName, absBuildFilePath, absBuildDirPath;
|
72
81
|
const outputDirMap = new Map();
|
73
82
|
for (const line of propertyReportLines) {
|
@@ -87,7 +96,7 @@ function processProjectReports(projectReportLines) {
|
|
87
96
|
}
|
88
97
|
}
|
89
98
|
if (!projectName || !absBuildFilePath || !absBuildDirPath) {
|
90
|
-
|
99
|
+
continue;
|
91
100
|
}
|
92
101
|
const buildFile = (0, devkit_1.normalizePath)((0, node_path_1.relative)(devkit_1.workspaceRoot, absBuildFilePath));
|
93
102
|
const buildDir = (0, node_path_1.relative)(devkit_1.workspaceRoot, absBuildDirPath);
|
@@ -101,11 +110,15 @@ function processProjectReports(projectReportLines) {
|
|
101
110
|
}
|
102
111
|
if (line.endsWith('taskReport')) {
|
103
112
|
const gradleProject = line.substring('> Task '.length, line.length - ':taskReport'.length);
|
104
|
-
|
113
|
+
while (index < projectReportLines.length &&
|
114
|
+
!projectReportLines[index].includes(exports.fileSeparator)) {
|
115
|
+
index++;
|
116
|
+
}
|
117
|
+
const [_, file] = projectReportLines[index].split(exports.fileSeparator);
|
105
118
|
const taskTypeMap = new Map();
|
106
|
-
const tasksFileLines = (0, node_fs_1.
|
107
|
-
.toString()
|
108
|
-
|
119
|
+
const tasksFileLines = (0, node_fs_1.existsSync)(file)
|
120
|
+
? (0, node_fs_1.readFileSync)(file).toString().split(newLineSeparator)
|
121
|
+
: [];
|
109
122
|
let i = 0;
|
110
123
|
while (i < tasksFileLines.length) {
|
111
124
|
const line = tasksFileLines[i];
|
@@ -125,7 +138,8 @@ function processProjectReports(projectReportLines) {
|
|
125
138
|
gradleProjectToTasksTypeMap.set(gradleProject, taskTypeMap);
|
126
139
|
}
|
127
140
|
}
|
128
|
-
|
141
|
+
index++;
|
142
|
+
}
|
129
143
|
return {
|
130
144
|
gradleFileToGradleProjectMap,
|
131
145
|
buildFileToDepsMap,
|
@@ -134,3 +148,4 @@ function processProjectReports(projectReportLines) {
|
|
134
148
|
gradleProjectToProjectName,
|
135
149
|
};
|
136
150
|
}
|
151
|
+
exports.processProjectReports = processProjectReports;
|