@nx/maven 22.3.3 → 22.4.0-beta.1
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/dist/batch-runner.jar +0 -0
- package/dist/executors/maven/maven-batch.impl.d.ts +13 -0
- package/dist/executors/maven/maven-batch.impl.d.ts.map +1 -0
- package/dist/executors/maven/maven-batch.impl.js +162 -0
- package/dist/executors/maven/maven.impl.d.ts +9 -0
- package/dist/executors/maven/maven.impl.d.ts.map +1 -0
- package/dist/executors/maven/maven.impl.js +60 -0
- package/dist/executors/maven/schema.d.ts +7 -0
- package/dist/executors/maven/schema.d.ts.map +1 -0
- package/dist/executors/maven/schema.js +2 -0
- package/dist/executors/maven/schema.json +50 -0
- package/dist/executors.json +8 -1
- package/dist/plugins/maven-analyzer.d.ts.map +1 -1
- package/dist/plugins/maven-analyzer.js +2 -35
- package/dist/utils/detect-maven-executable.d.ts +13 -0
- package/dist/utils/detect-maven-executable.d.ts.map +1 -0
- package/dist/utils/detect-maven-executable.js +78 -0
- package/executors.json +8 -1
- package/package.json +3 -3
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExecutorContext, TaskGraph } from '@nx/devkit';
|
|
2
|
+
import { TaskResult } from 'nx/src/config/misc-interfaces';
|
|
3
|
+
import { RunCommandsOptions } from 'nx/src/executors/run-commands/run-commands.impl';
|
|
4
|
+
import { MavenExecutorSchema } from './schema';
|
|
5
|
+
/**
|
|
6
|
+
* Maven batch executor using Kotlin batch runner with Maven Invoker API.
|
|
7
|
+
* Streams task results as they complete via async generator.
|
|
8
|
+
*/
|
|
9
|
+
export default function mavenBatchExecutor(taskGraph: TaskGraph, inputs: Record<string, MavenExecutorSchema>, overrides: RunCommandsOptions, context: ExecutorContext): AsyncGenerator<{
|
|
10
|
+
task: string;
|
|
11
|
+
result: TaskResult;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=maven-batch.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maven-batch.impl.d.ts","sourceRoot":"","sources":["../../../src/executors/maven/maven-batch.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAiB,MAAM,YAAY,CAAC;AAKvE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iDAAiD,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAoE/C;;;GAGG;AACH,wBAA+B,kBAAkB,CAC/C,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC3C,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,eAAe,GACvB,cAAc,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,CAkHtD"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = mavenBatchExecutor;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const readline_1 = require("readline");
|
|
9
|
+
/**
|
|
10
|
+
* Get path to the batch runner JAR
|
|
11
|
+
*/
|
|
12
|
+
function getBatchRunnerJar() {
|
|
13
|
+
const jarPath = (0, path_1.resolve)(__dirname, '../../../dist/batch-runner.jar');
|
|
14
|
+
if (!(0, fs_1.existsSync)(jarPath)) {
|
|
15
|
+
throw new Error(`Maven batch runner JAR not found at: ${jarPath}`);
|
|
16
|
+
}
|
|
17
|
+
return jarPath;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Normalize Maven arguments
|
|
21
|
+
*/
|
|
22
|
+
function normalizeMavenArgs(args) {
|
|
23
|
+
if (!args)
|
|
24
|
+
return [];
|
|
25
|
+
if (Array.isArray(args))
|
|
26
|
+
return args;
|
|
27
|
+
return args
|
|
28
|
+
.trim()
|
|
29
|
+
.split(' ')
|
|
30
|
+
.filter((arg) => arg.length > 0);
|
|
31
|
+
}
|
|
32
|
+
function buildTaskData(options, projectName) {
|
|
33
|
+
return {
|
|
34
|
+
phase: options.phase,
|
|
35
|
+
goals: Array.isArray(options.goals)
|
|
36
|
+
? options.goals
|
|
37
|
+
: options.goals
|
|
38
|
+
? [options.goals]
|
|
39
|
+
: [],
|
|
40
|
+
args: normalizeMavenArgs(options.args),
|
|
41
|
+
project: projectName,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Build tasks map from task graph and inputs
|
|
46
|
+
*/
|
|
47
|
+
function buildTasks(taskGraph, inputs) {
|
|
48
|
+
const tasks = {};
|
|
49
|
+
for (const taskId of Object.keys(taskGraph.tasks)) {
|
|
50
|
+
const task = taskGraph.tasks[taskId];
|
|
51
|
+
const projectName = task.target.project;
|
|
52
|
+
const options = inputs[taskId];
|
|
53
|
+
tasks[taskId] = buildTaskData(options, projectName);
|
|
54
|
+
}
|
|
55
|
+
return tasks;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Maven batch executor using Kotlin batch runner with Maven Invoker API.
|
|
59
|
+
* Streams task results as they complete via async generator.
|
|
60
|
+
*/
|
|
61
|
+
async function* mavenBatchExecutor(taskGraph, inputs, overrides, context) {
|
|
62
|
+
// Get batch runner JAR path
|
|
63
|
+
const batchRunnerJar = getBatchRunnerJar();
|
|
64
|
+
// Build task map for batch runner
|
|
65
|
+
const tasks = buildTasks(taskGraph, inputs);
|
|
66
|
+
// Build arguments for batch runner
|
|
67
|
+
const args = [];
|
|
68
|
+
if (overrides.__overrides_unparsed__?.length) {
|
|
69
|
+
args.push(...overrides.__overrides_unparsed__);
|
|
70
|
+
}
|
|
71
|
+
// Prepare batch runner arguments
|
|
72
|
+
const javaArgs = ['-jar', batchRunnerJar, `--workspaceRoot=${devkit_1.workspaceRoot}`];
|
|
73
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
74
|
+
javaArgs.push('--verbose');
|
|
75
|
+
console.log(`[Maven Batch] Executing: java ${javaArgs.join(' ')}`);
|
|
76
|
+
}
|
|
77
|
+
// Create combined payload for stdin with taskGraph, tasks, and args
|
|
78
|
+
const stdinPayload = {
|
|
79
|
+
taskGraph,
|
|
80
|
+
tasks,
|
|
81
|
+
args,
|
|
82
|
+
};
|
|
83
|
+
// Spawn batch runner process
|
|
84
|
+
// stdin: pipe (send task data), stdout: inherit (Maven output), stderr: pipe (results)
|
|
85
|
+
const child = (0, child_process_1.spawn)('java', javaArgs, {
|
|
86
|
+
cwd: devkit_1.workspaceRoot,
|
|
87
|
+
env: process.env,
|
|
88
|
+
stdio: ['pipe', 'inherit', 'pipe'],
|
|
89
|
+
windowsHide: true,
|
|
90
|
+
});
|
|
91
|
+
// Send task data via stdin (ignore EPIPE if process exits early)
|
|
92
|
+
child.stdin.on('error', (err) => {
|
|
93
|
+
if (err.code !== 'EPIPE') {
|
|
94
|
+
console.error('[Maven Batch] stdin error:', err);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
child.stdin.write(JSON.stringify(stdinPayload));
|
|
98
|
+
child.stdin.end();
|
|
99
|
+
// Read stderr line by line for JSON results
|
|
100
|
+
const rl = (0, readline_1.createInterface)({
|
|
101
|
+
input: child.stderr,
|
|
102
|
+
crlfDelay: Infinity,
|
|
103
|
+
});
|
|
104
|
+
// Collect non-result stderr lines for error reporting
|
|
105
|
+
const stderrLines = [];
|
|
106
|
+
// Collect terminal output from failed tasks
|
|
107
|
+
const failedTaskOutputs = [];
|
|
108
|
+
// Yield results as they stream in
|
|
109
|
+
for await (const line of rl) {
|
|
110
|
+
if (line.startsWith('NX_RESULT:')) {
|
|
111
|
+
try {
|
|
112
|
+
const jsonStr = line.slice('NX_RESULT:'.length);
|
|
113
|
+
const data = JSON.parse(jsonStr);
|
|
114
|
+
const result = {
|
|
115
|
+
success: data.result.success ?? false,
|
|
116
|
+
terminalOutput: data.result.terminalOutput ?? '',
|
|
117
|
+
startTime: data.result.startTime,
|
|
118
|
+
endTime: data.result.endTime,
|
|
119
|
+
};
|
|
120
|
+
// Collect terminal output from failed tasks
|
|
121
|
+
if (!result.success && result.terminalOutput) {
|
|
122
|
+
failedTaskOutputs.push(result.terminalOutput);
|
|
123
|
+
}
|
|
124
|
+
yield {
|
|
125
|
+
task: data.task,
|
|
126
|
+
result,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
console.error('[Maven Batch] Failed to parse result line:', line, e);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else if (line.trim()) {
|
|
134
|
+
// Collect non-empty stderr lines for error reporting
|
|
135
|
+
stderrLines.push(line);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Wait for process to exit
|
|
139
|
+
await new Promise((resolve, reject) => {
|
|
140
|
+
child.on('close', (code) => {
|
|
141
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
142
|
+
console.log(`[Maven Batch] Process exited with code: ${code}`);
|
|
143
|
+
}
|
|
144
|
+
// If process exited unexpectedly, print captured stderr
|
|
145
|
+
if (code !== 0 && stderrLines.length > 0) {
|
|
146
|
+
console.error(`[Maven Batch] Process exited with code ${code}. Stderr output:`);
|
|
147
|
+
for (const line of stderrLines) {
|
|
148
|
+
console.error(line);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// Print failed task outputs to stderr so they appear in error.message
|
|
152
|
+
if (failedTaskOutputs.length > 0) {
|
|
153
|
+
console.error('\n[Maven Batch] Failed task outputs:');
|
|
154
|
+
for (const output of failedTaskOutputs) {
|
|
155
|
+
console.error(output);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
resolve();
|
|
159
|
+
});
|
|
160
|
+
child.on('error', reject);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { MavenExecutorSchema } from './schema';
|
|
3
|
+
/**
|
|
4
|
+
* Maven single-task executor
|
|
5
|
+
*/
|
|
6
|
+
export default function mavenExecutor(options: MavenExecutorSchema, context: ExecutorContext): Promise<{
|
|
7
|
+
success: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=maven.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maven.impl.d.ts","sourceRoot":"","sources":["../../../src/executors/maven/maven.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAiB,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAyD/C;;GAEG;AACH,wBAA8B,aAAa,CACzC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAe/B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = mavenExecutor;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const run_commands_impl_1 = tslib_1.__importDefault(require("nx/src/executors/run-commands/run-commands.impl"));
|
|
7
|
+
const detect_maven_executable_1 = require("../../utils/detect-maven-executable");
|
|
8
|
+
const nxMavenApplyGoal = 'dev.nx.maven:nx-maven-plugin:apply';
|
|
9
|
+
const nxMavenRecordGoal = 'dev.nx.maven:nx-maven-plugin:record';
|
|
10
|
+
/**
|
|
11
|
+
* Build Maven command arguments
|
|
12
|
+
*/
|
|
13
|
+
function buildMavenArgs(options, projectName, useMaven4) {
|
|
14
|
+
const args = [];
|
|
15
|
+
// Verbose flags
|
|
16
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
17
|
+
args.push('-X', '-e');
|
|
18
|
+
}
|
|
19
|
+
// Never update snapshots (faster builds)
|
|
20
|
+
args.push('-nsu');
|
|
21
|
+
// Non-recursive - only build the specified project (Maven 4.x only)
|
|
22
|
+
// Maven 3.x needs to scan modules to find projects
|
|
23
|
+
if (useMaven4) {
|
|
24
|
+
args.push('-N');
|
|
25
|
+
}
|
|
26
|
+
// Project selector - always pass the project
|
|
27
|
+
args.push('-pl', projectName);
|
|
28
|
+
// Goals with apply/record wrappers
|
|
29
|
+
if (options.goals) {
|
|
30
|
+
const goals = Array.isArray(options.goals)
|
|
31
|
+
? options.goals
|
|
32
|
+
: options.goals.split(' ');
|
|
33
|
+
args.push(nxMavenApplyGoal);
|
|
34
|
+
args.push(...goals);
|
|
35
|
+
args.push(nxMavenRecordGoal);
|
|
36
|
+
}
|
|
37
|
+
// Additional args from options
|
|
38
|
+
if (options.args) {
|
|
39
|
+
const additionalArgs = Array.isArray(options.args)
|
|
40
|
+
? options.args
|
|
41
|
+
: options.args.trim().split(' ');
|
|
42
|
+
args.push(...additionalArgs.filter((arg) => arg.length > 0));
|
|
43
|
+
}
|
|
44
|
+
return args;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Maven single-task executor
|
|
48
|
+
*/
|
|
49
|
+
async function mavenExecutor(options, context) {
|
|
50
|
+
const mavenExecutable = (0, detect_maven_executable_1.detectMavenExecutable)(devkit_1.workspaceRoot);
|
|
51
|
+
const projectName = context.projectName;
|
|
52
|
+
const useMaven4 = (0, detect_maven_executable_1.isMaven4)(devkit_1.workspaceRoot);
|
|
53
|
+
const args = buildMavenArgs(options, projectName, useMaven4);
|
|
54
|
+
return (0, run_commands_impl_1.default)({
|
|
55
|
+
command: mavenExecutable,
|
|
56
|
+
cwd: devkit_1.workspaceRoot,
|
|
57
|
+
args,
|
|
58
|
+
__unparsed__: options.__unparsed__ || [],
|
|
59
|
+
}, context);
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/executors/maven/schema.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"title": "Maven Executor",
|
|
5
|
+
"description": "The Maven executor is used to run Maven phases and goals.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"phase": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The Maven lifecycle phase to execute (e.g., 'compile', 'test', 'package', 'install')."
|
|
11
|
+
},
|
|
12
|
+
"goals": {
|
|
13
|
+
"oneOf": [
|
|
14
|
+
{
|
|
15
|
+
"type": "array",
|
|
16
|
+
"items": {
|
|
17
|
+
"type": "string"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"type": "string"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"description": "The Maven goals to execute (e.g., 'clean:clean', 'compiler:compile')."
|
|
25
|
+
},
|
|
26
|
+
"args": {
|
|
27
|
+
"oneOf": [
|
|
28
|
+
{
|
|
29
|
+
"type": "array",
|
|
30
|
+
"items": {
|
|
31
|
+
"type": "string"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "string"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"description": "The arguments to pass to the Maven command.",
|
|
39
|
+
"examples": [["--quiet", "-DskipTests"], "-X"]
|
|
40
|
+
},
|
|
41
|
+
"__unparsed__": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"items": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
},
|
|
46
|
+
"description": "Additional arguments to pass to the Maven command (automatically populated by Nx).",
|
|
47
|
+
"x-priority": "internal"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
package/dist/executors.json
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "../../node_modules/nx/schemas/executors-schema.json",
|
|
3
|
-
"executors": {
|
|
3
|
+
"executors": {
|
|
4
|
+
"maven": {
|
|
5
|
+
"implementation": "./dist/executors/maven/maven.impl",
|
|
6
|
+
"batchImplementation": "./dist/executors/maven/maven-batch.impl",
|
|
7
|
+
"schema": "./dist/executors/maven/schema.json",
|
|
8
|
+
"description": "Runs Maven phases and goals via Maven executable."
|
|
9
|
+
}
|
|
10
|
+
}
|
|
4
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maven-analyzer.d.ts","sourceRoot":"","sources":["../../src/plugins/maven-analyzer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"maven-analyzer.d.ts","sourceRoot":"","sources":["../../src/plugins/maven-analyzer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAGhE;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAyH5B"}
|
|
@@ -6,40 +6,7 @@ const fs_1 = require("fs");
|
|
|
6
6
|
const child_process_1 = require("child_process");
|
|
7
7
|
const devkit_1 = require("@nx/devkit");
|
|
8
8
|
const cache_directory_1 = require("nx/src/utils/cache-directory");
|
|
9
|
-
|
|
10
|
-
* Detect Maven executable: mvnd > mvnw > mvn
|
|
11
|
-
*/
|
|
12
|
-
function detectMavenExecutable(workspaceRoot) {
|
|
13
|
-
devkit_1.logger.verbose(`[Maven Analyzer] Detecting Maven executable in workspace: ${workspaceRoot}`);
|
|
14
|
-
// First priority: Check for Maven Daemon
|
|
15
|
-
try {
|
|
16
|
-
const { execSync } = require('child_process');
|
|
17
|
-
execSync('mvnd --version', { stdio: 'pipe' });
|
|
18
|
-
devkit_1.logger.verbose(`[Maven Analyzer] Found Maven Daemon, using: mvnd`);
|
|
19
|
-
return 'mvnd';
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
devkit_1.logger.verbose(`[Maven Analyzer] Maven Daemon not available`);
|
|
23
|
-
}
|
|
24
|
-
// Second priority: Check for Maven wrapper
|
|
25
|
-
if (process.platform === 'win32') {
|
|
26
|
-
const wrapperPath = (0, path_1.join)(workspaceRoot, 'mvnw.cmd');
|
|
27
|
-
if ((0, fs_1.existsSync)(wrapperPath)) {
|
|
28
|
-
devkit_1.logger.verbose(`[Maven Analyzer] Found Maven wrapper, using: mvnw.cmd`);
|
|
29
|
-
return 'mvnw.cmd';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
const wrapperPath = (0, path_1.join)(workspaceRoot, 'mvnw');
|
|
34
|
-
if ((0, fs_1.existsSync)(wrapperPath)) {
|
|
35
|
-
devkit_1.logger.verbose(`[Maven Analyzer] Found Maven wrapper, using: ./mvnw`);
|
|
36
|
-
return './mvnw';
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
// Fallback: Use regular Maven
|
|
40
|
-
devkit_1.logger.verbose(`[Maven Analyzer] Using fallback: mvn`);
|
|
41
|
-
return 'mvn';
|
|
42
|
-
}
|
|
9
|
+
const detect_maven_executable_1 = require("../utils/detect-maven-executable");
|
|
43
10
|
/**
|
|
44
11
|
* Run Maven analysis using our Kotlin analyzer plugin
|
|
45
12
|
*/
|
|
@@ -52,7 +19,7 @@ async function runMavenAnalysis(workspaceRoot, options) {
|
|
|
52
19
|
devkit_1.logger.verbose(`[Maven Analyzer] Workspace root: ${workspaceRoot}`);
|
|
53
20
|
devkit_1.logger.verbose(`[Maven Analyzer] Workspace data directory: ${cache_directory_1.workspaceDataDirectory}`);
|
|
54
21
|
// Detect Maven executable (mvnd > mvnw > mvn)
|
|
55
|
-
const mavenExecutable = detectMavenExecutable(workspaceRoot);
|
|
22
|
+
const mavenExecutable = (0, detect_maven_executable_1.detectMavenExecutable)(workspaceRoot);
|
|
56
23
|
const mavenArgs = [
|
|
57
24
|
'dev.nx.maven:nx-maven-plugin:analyze',
|
|
58
25
|
'-am',
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect Maven version (e.g., "4.0.0-rc-4" or "3.9.9")
|
|
3
|
+
*/
|
|
4
|
+
export declare function detectMavenVersion(workspaceRoot: string): string | null;
|
|
5
|
+
/**
|
|
6
|
+
* Check if Maven 4.x is being used
|
|
7
|
+
*/
|
|
8
|
+
export declare function isMaven4(workspaceRoot: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Detect Maven executable: mvnd > mvnw > mvn
|
|
11
|
+
*/
|
|
12
|
+
export declare function detectMavenExecutable(workspaceRoot: string): string;
|
|
13
|
+
//# sourceMappingURL=detect-maven-executable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-maven-executable.d.ts","sourceRoot":"","sources":["../../src/utils/detect-maven-executable.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAwBvE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CA4BnE"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectMavenVersion = detectMavenVersion;
|
|
4
|
+
exports.isMaven4 = isMaven4;
|
|
5
|
+
exports.detectMavenExecutable = detectMavenExecutable;
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const child_process_1 = require("child_process");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const devkit_1 = require("@nx/devkit");
|
|
10
|
+
// Cache Maven version to avoid repeated execSync calls
|
|
11
|
+
let cachedMavenVersion = null;
|
|
12
|
+
/**
|
|
13
|
+
* Detect Maven version (e.g., "4.0.0-rc-4" or "3.9.9")
|
|
14
|
+
*/
|
|
15
|
+
function detectMavenVersion(workspaceRoot) {
|
|
16
|
+
if (cachedMavenVersion !== null) {
|
|
17
|
+
return cachedMavenVersion;
|
|
18
|
+
}
|
|
19
|
+
const executable = detectMavenExecutable(workspaceRoot);
|
|
20
|
+
try {
|
|
21
|
+
const output = (0, child_process_1.execSync)(`${executable} --version`, {
|
|
22
|
+
cwd: workspaceRoot,
|
|
23
|
+
stdio: 'pipe',
|
|
24
|
+
encoding: 'utf-8',
|
|
25
|
+
windowsHide: true,
|
|
26
|
+
});
|
|
27
|
+
// Parse version from output like "Apache Maven 4.0.0-rc-4" or "Apache Maven 3.9.9"
|
|
28
|
+
const match = output.match(/Apache Maven (\d+\.\d+\.\d+[^\s]*)/);
|
|
29
|
+
if (match) {
|
|
30
|
+
cachedMavenVersion = match[1];
|
|
31
|
+
devkit_1.logger.verbose(`[Maven] Detected version: ${cachedMavenVersion}`);
|
|
32
|
+
return cachedMavenVersion;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Failed to detect version
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check if Maven 4.x is being used
|
|
42
|
+
*/
|
|
43
|
+
function isMaven4(workspaceRoot) {
|
|
44
|
+
const version = detectMavenVersion(workspaceRoot);
|
|
45
|
+
return version?.startsWith('4') ?? false;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Detect Maven executable: mvnd > mvnw > mvn
|
|
49
|
+
*/
|
|
50
|
+
function detectMavenExecutable(workspaceRoot) {
|
|
51
|
+
// First priority: Check for Maven Daemon
|
|
52
|
+
try {
|
|
53
|
+
(0, child_process_1.execSync)('mvnd --version', { stdio: 'pipe' });
|
|
54
|
+
devkit_1.logger.verbose(`[Maven] Found Maven Daemon, using: mvnd`);
|
|
55
|
+
return 'mvnd';
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// Maven Daemon not available
|
|
59
|
+
}
|
|
60
|
+
// Second priority: Check for Maven wrapper
|
|
61
|
+
if (process.platform === 'win32') {
|
|
62
|
+
const wrapperPath = (0, path_1.join)(workspaceRoot, 'mvnw.cmd');
|
|
63
|
+
if ((0, fs_1.existsSync)(wrapperPath)) {
|
|
64
|
+
devkit_1.logger.verbose(`[Maven] Found Maven wrapper, using: mvnw.cmd`);
|
|
65
|
+
return 'mvnw.cmd';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const wrapperPath = (0, path_1.join)(workspaceRoot, 'mvnw');
|
|
70
|
+
if ((0, fs_1.existsSync)(wrapperPath)) {
|
|
71
|
+
devkit_1.logger.verbose(`[Maven] Found Maven wrapper, using: ./mvnw`);
|
|
72
|
+
return './mvnw';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Fallback: Use regular Maven
|
|
76
|
+
devkit_1.logger.verbose(`[Maven] Using fallback: mvn`);
|
|
77
|
+
return 'mvn';
|
|
78
|
+
}
|
package/executors.json
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "../../node_modules/nx/schemas/executors-schema.json",
|
|
3
|
-
"executors": {
|
|
3
|
+
"executors": {
|
|
4
|
+
"maven": {
|
|
5
|
+
"implementation": "./dist/executors/maven/maven.impl",
|
|
6
|
+
"batchImplementation": "./dist/executors/maven/maven-batch.impl",
|
|
7
|
+
"schema": "./dist/executors/maven/schema.json",
|
|
8
|
+
"description": "Runs Maven phases and goals via Maven executable."
|
|
9
|
+
}
|
|
10
|
+
}
|
|
4
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/maven",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.4.0-beta.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Nx plugin for Maven integration",
|
|
6
6
|
"repository": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"author": "Victor Savkin",
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@nx/devkit": "22.
|
|
48
|
+
"@nx/devkit": "22.4.0-beta.1",
|
|
49
49
|
"@xmldom/xmldom": "^0.8.10",
|
|
50
50
|
"tslib": "^2.3.0"
|
|
51
51
|
},
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@types/xmldom": "^0.1.34",
|
|
56
56
|
"jest": "^30.0.2",
|
|
57
57
|
"memfs": "^4.9.2",
|
|
58
|
-
"nx": "22.
|
|
58
|
+
"nx": "22.4.0-beta.1",
|
|
59
59
|
"ts-jest": "^29.4.0",
|
|
60
60
|
"typescript": "~5.9.2"
|
|
61
61
|
},
|