@nx/maven 0.0.0-pr-33228-85dcafe → 0.0.0-pr-33228-82dc549
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/batch-runner.d.ts +24 -0
- package/dist/executors/maven/batch-runner.d.ts.map +1 -0
- package/dist/executors/maven/batch-runner.js +111 -0
- package/dist/executors/maven/maven-batch.impl.d.ts +9 -0
- package/dist/executors/maven/maven-batch.impl.d.ts.map +1 -0
- package/dist/executors/maven/maven-batch.impl.js +183 -0
- package/dist/executors/maven/maven.impl.d.ts +11 -0
- package/dist/executors/maven/maven.impl.d.ts.map +1 -0
- package/dist/executors/maven/maven.impl.js +118 -0
- package/dist/executors/maven/schema.d.ts +8 -0
- package/dist/executors/maven/schema.d.ts.map +1 -0
- package/dist/executors/maven/schema.js +2 -0
- package/dist/generators/ci-workflow/generator.d.ts +15 -0
- package/dist/generators/ci-workflow/generator.d.ts.map +1 -0
- package/dist/generators/ci-workflow/generator.js +71 -0
- package/dist/generators/init/generator.d.ts +7 -0
- package/dist/generators/init/generator.d.ts.map +1 -0
- package/dist/generators/init/generator.js +134 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/migrations/0-0-8/update-pom-xml-version.d.ts +7 -0
- package/dist/migrations/0-0-8/update-pom-xml-version.d.ts.map +1 -0
- package/dist/migrations/0-0-8/update-pom-xml-version.js +11 -0
- package/dist/migrations/0-0-9/update-pom-xml-version.d.ts +7 -0
- package/dist/migrations/0-0-9/update-pom-xml-version.d.ts.map +1 -0
- package/dist/migrations/0-0-9/update-pom-xml-version.js +11 -0
- package/dist/plugins/dependencies.d.ts +7 -0
- package/dist/plugins/dependencies.d.ts.map +1 -0
- package/dist/plugins/dependencies.js +50 -0
- package/dist/plugins/maven-analyzer.d.ts +6 -0
- package/dist/plugins/maven-analyzer.d.ts.map +1 -0
- package/dist/plugins/maven-analyzer.js +143 -0
- package/dist/plugins/maven-data-cache.d.ts +14 -0
- package/dist/plugins/maven-data-cache.d.ts.map +1 -0
- package/dist/plugins/maven-data-cache.js +32 -0
- package/dist/plugins/nodes.d.ts +7 -0
- package/dist/plugins/nodes.d.ts.map +1 -0
- package/dist/plugins/nodes.js +64 -0
- package/dist/plugins/types.d.ts +15 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +4 -0
- package/dist/utils/pom-xml-updater.d.ts +10 -0
- package/dist/utils/pom-xml-updater.d.ts.map +1 -0
- package/dist/utils/pom-xml-updater.js +45 -0
- package/dist/utils/versions.d.ts +3 -0
- package/dist/utils/versions.d.ts.map +1 -0
- package/dist/utils/versions.js +5 -0
- package/package.json +3 -3
package/dist/batch-runner.jar
CHANGED
|
Binary file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch runner for Maven - handles multi-task Maven execution
|
|
3
|
+
* This is a simplified implementation that can later be migrated to Kotlin/Java
|
|
4
|
+
* for more advanced features like true parallel execution and result parsing
|
|
5
|
+
*/
|
|
6
|
+
import { BatchResults } from 'nx/src/tasks-runner/batch/batch-messages';
|
|
7
|
+
export interface BatchTask {
|
|
8
|
+
id: string;
|
|
9
|
+
phase?: string;
|
|
10
|
+
goals?: string[];
|
|
11
|
+
args?: string[];
|
|
12
|
+
}
|
|
13
|
+
export interface BatchRunnerOptions {
|
|
14
|
+
workspaceRoot: string;
|
|
15
|
+
mavenExecutable: string;
|
|
16
|
+
tasks: BatchTask[];
|
|
17
|
+
verbose?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Run Maven tasks in batch
|
|
21
|
+
* Groups tasks by shared targets and executes them in batches
|
|
22
|
+
*/
|
|
23
|
+
export declare function runMavenBatch(options: BatchRunnerOptions): Promise<BatchResults>;
|
|
24
|
+
//# sourceMappingURL=batch-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-runner.d.ts","sourceRoot":"","sources":["../../../src/executors/maven/batch-runner.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,YAAY,CAAC,CA2CvB"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Batch runner for Maven - handles multi-task Maven execution
|
|
4
|
+
* This is a simplified implementation that can later be migrated to Kotlin/Java
|
|
5
|
+
* for more advanced features like true parallel execution and result parsing
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.runMavenBatch = runMavenBatch;
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
/**
|
|
11
|
+
* Run Maven tasks in batch
|
|
12
|
+
* Groups tasks by shared targets and executes them in batches
|
|
13
|
+
*/
|
|
14
|
+
async function runMavenBatch(options) {
|
|
15
|
+
const results = {};
|
|
16
|
+
// Group tasks by target combination
|
|
17
|
+
const taskGroups = groupTasksByTargets(options.tasks);
|
|
18
|
+
try {
|
|
19
|
+
// Execute each group
|
|
20
|
+
for (const group of taskGroups) {
|
|
21
|
+
const args = buildMavenArgs(group);
|
|
22
|
+
if (options.verbose) {
|
|
23
|
+
console.log(`[Maven Batch] Executing group with targets: ${args.join(' ')}`);
|
|
24
|
+
}
|
|
25
|
+
const success = await executeMavenCommand(options.mavenExecutable, args, options.workspaceRoot, options.verbose);
|
|
26
|
+
// Assign the same result to all tasks in the group
|
|
27
|
+
for (const taskId of group.taskIds) {
|
|
28
|
+
results[taskId] = {
|
|
29
|
+
success,
|
|
30
|
+
terminalOutput: `Executed with Maven batch runner`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
37
|
+
for (const task of options.tasks) {
|
|
38
|
+
results[task.id] = {
|
|
39
|
+
success: false,
|
|
40
|
+
terminalOutput: message,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return results;
|
|
45
|
+
}
|
|
46
|
+
function groupTasksByTargets(tasks) {
|
|
47
|
+
const groups = new Map();
|
|
48
|
+
for (const task of tasks) {
|
|
49
|
+
const goals = task.goals || [];
|
|
50
|
+
const args = task.args || [];
|
|
51
|
+
const key = JSON.stringify({
|
|
52
|
+
phase: task.phase,
|
|
53
|
+
goals,
|
|
54
|
+
args,
|
|
55
|
+
});
|
|
56
|
+
if (!groups.has(key)) {
|
|
57
|
+
groups.set(key, {
|
|
58
|
+
taskIds: [],
|
|
59
|
+
phase: task.phase,
|
|
60
|
+
goals,
|
|
61
|
+
args,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
groups.get(key).taskIds.push(task.id);
|
|
65
|
+
}
|
|
66
|
+
return Array.from(groups.values());
|
|
67
|
+
}
|
|
68
|
+
function buildMavenArgs(group) {
|
|
69
|
+
const args = [];
|
|
70
|
+
if (group.phase) {
|
|
71
|
+
args.push(group.phase);
|
|
72
|
+
}
|
|
73
|
+
if (group.goals.length > 0) {
|
|
74
|
+
args.push(...group.goals);
|
|
75
|
+
}
|
|
76
|
+
if (group.args.length > 0) {
|
|
77
|
+
args.push(...group.args);
|
|
78
|
+
}
|
|
79
|
+
return args;
|
|
80
|
+
}
|
|
81
|
+
async function executeMavenCommand(executable, args, cwd, verbose) {
|
|
82
|
+
return new Promise((resolve) => {
|
|
83
|
+
let hasErrors = false;
|
|
84
|
+
const child = (0, child_process_1.spawn)(executable, args, {
|
|
85
|
+
cwd,
|
|
86
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
87
|
+
shell: process.platform === 'win32',
|
|
88
|
+
});
|
|
89
|
+
child.stdout?.on('data', (data) => {
|
|
90
|
+
const text = data.toString();
|
|
91
|
+
if (verbose) {
|
|
92
|
+
process.stdout.write(text);
|
|
93
|
+
}
|
|
94
|
+
if (text.includes('BUILD FAILURE')) {
|
|
95
|
+
hasErrors = true;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
child.stderr?.on('data', (data) => {
|
|
99
|
+
const text = data.toString();
|
|
100
|
+
if (verbose) {
|
|
101
|
+
process.stderr.write(text);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
child.on('close', (code) => {
|
|
105
|
+
resolve(code === 0 && !hasErrors);
|
|
106
|
+
});
|
|
107
|
+
child.on('error', () => {
|
|
108
|
+
resolve(false);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
import { MavenExecutorSchema } from './schema';
|
|
5
|
+
/**
|
|
6
|
+
* Maven batch executor using Kotlin batch runner with Maven Invoker API
|
|
7
|
+
*/
|
|
8
|
+
export default function mavenBatchExecutor(taskGraph: TaskGraph, inputs: Record<string, MavenExecutorSchema>, overrides: RunCommandsOptions, context: ExecutorContext): Promise<BatchResults>;
|
|
9
|
+
//# 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,EAAU,SAAS,EAAiB,MAAM,YAAY,CAAC;AAI/E,OAAO,EAEL,kBAAkB,EACnB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AA6D/C;;GAEG;AACH,wBAA8B,kBAAkB,CAC9C,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC3C,SAAS,EAAE,kBAAkB,EAC7B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC,CAsJvB"}
|
|
@@ -0,0 +1,183 @@
|
|
|
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 run_commands_impl_1 = require("nx/src/executors/run-commands/run-commands.impl");
|
|
9
|
+
/**
|
|
10
|
+
* Get path to the batch runner JAR
|
|
11
|
+
*/
|
|
12
|
+
function getBatchRunnerJar() {
|
|
13
|
+
// Try multiple locations
|
|
14
|
+
const possiblePaths = [
|
|
15
|
+
// Fallback relative to this file's dist location
|
|
16
|
+
(0, path_1.resolve)(__dirname, '../../../dist/batch-runner.jar'),
|
|
17
|
+
];
|
|
18
|
+
for (const path of possiblePaths) {
|
|
19
|
+
if ((0, fs_1.existsSync)(path)) {
|
|
20
|
+
return path;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`Maven batch runner JAR not found. Tried: ${possiblePaths.join(', ')}`);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Normalize Maven arguments
|
|
27
|
+
*/
|
|
28
|
+
function normalizeMavenArgs(args) {
|
|
29
|
+
if (!args)
|
|
30
|
+
return [];
|
|
31
|
+
if (Array.isArray(args))
|
|
32
|
+
return args;
|
|
33
|
+
return args
|
|
34
|
+
.trim()
|
|
35
|
+
.split(' ')
|
|
36
|
+
.filter((arg) => arg.length > 0);
|
|
37
|
+
}
|
|
38
|
+
function buildTaskData(options, projectName) {
|
|
39
|
+
return {
|
|
40
|
+
phase: options.phase,
|
|
41
|
+
goals: Array.isArray(options.goals)
|
|
42
|
+
? options.goals
|
|
43
|
+
: options.goals
|
|
44
|
+
? [options.goals]
|
|
45
|
+
: [],
|
|
46
|
+
args: normalizeMavenArgs(options.args),
|
|
47
|
+
project: projectName,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Maven batch executor using Kotlin batch runner with Maven Invoker API
|
|
52
|
+
*/
|
|
53
|
+
async function mavenBatchExecutor(taskGraph, inputs, overrides, context) {
|
|
54
|
+
try {
|
|
55
|
+
const batchStart = performance.mark('maven-batch:start');
|
|
56
|
+
// Get batch runner JAR path
|
|
57
|
+
const batchRunnerJar = getBatchRunnerJar();
|
|
58
|
+
// Build task map for batch runner
|
|
59
|
+
const tasks = {};
|
|
60
|
+
const taskIds = Object.keys(taskGraph.tasks);
|
|
61
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
62
|
+
console.log('[Maven Batch] Building tasks for execution:');
|
|
63
|
+
}
|
|
64
|
+
for (const taskId of taskIds) {
|
|
65
|
+
const task = taskGraph.tasks[taskId];
|
|
66
|
+
const projectName = task.target.project;
|
|
67
|
+
const options = inputs[taskId] || inputs[projectName];
|
|
68
|
+
tasks[taskId] = buildTaskData(options, projectName);
|
|
69
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
70
|
+
console.log(`[Maven Batch] Task ID: "${taskId}"`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Build arguments for batch runner
|
|
74
|
+
const args = [];
|
|
75
|
+
if (overrides.__overrides_unparsed__?.length) {
|
|
76
|
+
args.push(...overrides.__overrides_unparsed__);
|
|
77
|
+
}
|
|
78
|
+
// Prepare batch runner arguments - JSON output to stdout like Gradle
|
|
79
|
+
const tasksJson = JSON.stringify(tasks).replaceAll("'", '"');
|
|
80
|
+
const argsJson = args.join(' ').replaceAll("'", '"');
|
|
81
|
+
const workspaceDataDir = (0, path_1.join)(devkit_1.workspaceRoot, '.nx');
|
|
82
|
+
// Add debug logging flags if verbose mode is enabled
|
|
83
|
+
let debugFlags = '';
|
|
84
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
85
|
+
debugFlags =
|
|
86
|
+
'-Dorg.slf4j.simpleLogger.defaultLogLevel=debug -Dorg.slf4j.simpleLogger.log.org.apache.maven=debug ';
|
|
87
|
+
}
|
|
88
|
+
const command = `java ${debugFlags}-jar "${batchRunnerJar}" --workspaceRoot="${devkit_1.workspaceRoot}" --workspaceDataDirectory="${workspaceDataDir}" --tasks='${tasksJson}' --args='${argsJson}'`;
|
|
89
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
90
|
+
console.log(`[Maven Batch] Executing: ${command}`);
|
|
91
|
+
}
|
|
92
|
+
let batchResults;
|
|
93
|
+
try {
|
|
94
|
+
// Execute batch runner - output goes to terminal in real-time
|
|
95
|
+
// We capture the result but the user sees Maven output on their terminal
|
|
96
|
+
const buffer = (0, child_process_1.execSync)(command, {
|
|
97
|
+
cwd: devkit_1.workspaceRoot,
|
|
98
|
+
input: JSON.stringify(taskGraph),
|
|
99
|
+
windowsHide: true,
|
|
100
|
+
env: process.env,
|
|
101
|
+
maxBuffer: run_commands_impl_1.LARGE_BUFFER,
|
|
102
|
+
encoding: 'utf-8',
|
|
103
|
+
stdio: ['pipe', 'pipe', 'inherit'], // Capture stdout, inherit stderr so logs show
|
|
104
|
+
});
|
|
105
|
+
batchResults = buffer.toString();
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
// Batch runner may exit with non-zero code if tasks fail
|
|
109
|
+
// Try to extract JSON output from the error buffer
|
|
110
|
+
if (e.stdout) {
|
|
111
|
+
batchResults = e.stdout.toString();
|
|
112
|
+
}
|
|
113
|
+
else if (e.message) {
|
|
114
|
+
console.error('[Maven Batch] Error:', e.message);
|
|
115
|
+
throw e;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Parse JSON results from stdout
|
|
119
|
+
let results = {};
|
|
120
|
+
try {
|
|
121
|
+
// Extract JSON from output (may have logs before it)
|
|
122
|
+
const startIndex = batchResults.indexOf('{');
|
|
123
|
+
const endIndex = batchResults.lastIndexOf('}');
|
|
124
|
+
if (startIndex >= 0 && endIndex > startIndex) {
|
|
125
|
+
const jsonStr = batchResults.substring(startIndex, endIndex + 1);
|
|
126
|
+
const rawResults = JSON.parse(jsonStr);
|
|
127
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
128
|
+
console.log('[Maven Batch] Expected task IDs:', taskIds);
|
|
129
|
+
}
|
|
130
|
+
results = Object.entries(rawResults).reduce((acc, [taskId, taskResult]) => {
|
|
131
|
+
const result = taskResult;
|
|
132
|
+
acc[taskId] = {
|
|
133
|
+
success: result.success ?? false,
|
|
134
|
+
terminalOutput: result.terminalOutput ?? '',
|
|
135
|
+
startTime: result.startTime,
|
|
136
|
+
endTime: result.endTime,
|
|
137
|
+
};
|
|
138
|
+
return acc;
|
|
139
|
+
}, {});
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
throw new Error('No JSON found in batch runner output');
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
console.warn('Failed to parse batch runner results:', e);
|
|
147
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
148
|
+
console.log('[Maven Batch] Output was:', batchResults);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// Ensure all tasks have results
|
|
152
|
+
for (const taskId of taskIds) {
|
|
153
|
+
if (!results[taskId]) {
|
|
154
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
155
|
+
console.log(`[Maven Batch] Missing result for task ID: "${taskId}"`);
|
|
156
|
+
console.log(`[Maven Batch] Available task IDs in results:`, Object.keys(results));
|
|
157
|
+
}
|
|
158
|
+
results[taskId] = {
|
|
159
|
+
success: false,
|
|
160
|
+
terminalOutput: 'No result returned from batch runner',
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const batchEnd = performance.mark('maven-batch:end');
|
|
165
|
+
performance.measure('maven-batch', batchStart.name, batchEnd.name);
|
|
166
|
+
return results;
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
170
|
+
devkit_1.output.error({
|
|
171
|
+
title: 'Maven batch execution failed',
|
|
172
|
+
bodyLines: [errorMessage],
|
|
173
|
+
});
|
|
174
|
+
const results = {};
|
|
175
|
+
for (const taskId of Object.keys(taskGraph.tasks)) {
|
|
176
|
+
results[taskId] = {
|
|
177
|
+
success: false,
|
|
178
|
+
terminalOutput: errorMessage,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
return results;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
+
import { MavenExecutorSchema } from './schema';
|
|
3
|
+
export interface MavenExecutorResult {
|
|
4
|
+
success: boolean;
|
|
5
|
+
terminalOutput?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Maven single-task executor
|
|
9
|
+
*/
|
|
10
|
+
export default function mavenExecutor(options: MavenExecutorSchema, context: ExecutorContext): Promise<MavenExecutorResult>;
|
|
11
|
+
//# 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;AAI5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AA2GD;;GAEG;AACH,wBAA8B,aAAa,CACzC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,mBAAmB,CAAC,CAoB9B"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = mavenExecutor;
|
|
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
|
+
/**
|
|
9
|
+
* Detect Maven executable: mvnw > mvn
|
|
10
|
+
*/
|
|
11
|
+
function detectMavenExecutable(root) {
|
|
12
|
+
// Check for Maven wrapper
|
|
13
|
+
if (process.platform === 'win32') {
|
|
14
|
+
const wrapperPath = (0, path_1.join)(root, 'mvnw.cmd');
|
|
15
|
+
if ((0, fs_1.existsSync)(wrapperPath)) {
|
|
16
|
+
return 'mvnw.cmd';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const wrapperPath = (0, path_1.join)(root, 'mvnw');
|
|
21
|
+
if ((0, fs_1.existsSync)(wrapperPath)) {
|
|
22
|
+
return './mvnw';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Fallback to Maven
|
|
26
|
+
return 'mvn';
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build Maven command arguments
|
|
30
|
+
*/
|
|
31
|
+
function buildMavenArgs(options) {
|
|
32
|
+
const args = [];
|
|
33
|
+
if (options.phase) {
|
|
34
|
+
args.push(options.phase);
|
|
35
|
+
}
|
|
36
|
+
if (options.goals) {
|
|
37
|
+
const goals = Array.isArray(options.goals)
|
|
38
|
+
? options.goals
|
|
39
|
+
: options.goals.split(' ');
|
|
40
|
+
args.push(...goals);
|
|
41
|
+
}
|
|
42
|
+
if (options.args) {
|
|
43
|
+
const additionalArgs = Array.isArray(options.args)
|
|
44
|
+
? options.args
|
|
45
|
+
: options.args.trim().split(' ');
|
|
46
|
+
args.push(...additionalArgs.filter((arg) => arg.length > 0));
|
|
47
|
+
}
|
|
48
|
+
if (options.__unparsed__) {
|
|
49
|
+
args.push(...options.__unparsed__);
|
|
50
|
+
}
|
|
51
|
+
return args;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Execute Maven command in a child process
|
|
55
|
+
*/
|
|
56
|
+
async function executeMaven(executable, args, cwd) {
|
|
57
|
+
return new Promise((resolve) => {
|
|
58
|
+
let stdout = '';
|
|
59
|
+
let stderr = '';
|
|
60
|
+
const child = (0, child_process_1.spawn)(executable, args, {
|
|
61
|
+
cwd,
|
|
62
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
63
|
+
shell: process.platform === 'win32',
|
|
64
|
+
});
|
|
65
|
+
if (child.stdout) {
|
|
66
|
+
child.stdout.on('data', (data) => {
|
|
67
|
+
const text = data.toString();
|
|
68
|
+
stdout += text;
|
|
69
|
+
process.stdout.write(text);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (child.stderr) {
|
|
73
|
+
child.stderr.on('data', (data) => {
|
|
74
|
+
const text = data.toString();
|
|
75
|
+
stderr += text;
|
|
76
|
+
process.stderr.write(text);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
child.on('close', (code) => {
|
|
80
|
+
resolve({
|
|
81
|
+
success: code === 0,
|
|
82
|
+
stdout,
|
|
83
|
+
stderr,
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
child.on('error', (error) => {
|
|
87
|
+
stderr += error.message;
|
|
88
|
+
process.stderr.write(`Error: ${error.message}`);
|
|
89
|
+
resolve({
|
|
90
|
+
success: false,
|
|
91
|
+
stdout,
|
|
92
|
+
stderr,
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Maven single-task executor
|
|
99
|
+
*/
|
|
100
|
+
async function mavenExecutor(options, context) {
|
|
101
|
+
const projectRoot = context.projectGraph.nodes[context.projectName]?.data?.root ?? context.root;
|
|
102
|
+
const mavenExecutable = detectMavenExecutable(devkit_1.workspaceRoot);
|
|
103
|
+
const args = buildMavenArgs(options);
|
|
104
|
+
try {
|
|
105
|
+
const result = await executeMaven(mavenExecutable, args, projectRoot);
|
|
106
|
+
return {
|
|
107
|
+
success: result.success,
|
|
108
|
+
terminalOutput: result.stdout + result.stderr,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
113
|
+
return {
|
|
114
|
+
success: false,
|
|
115
|
+
terminalOutput: errorMessage,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -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,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
export type Command = {
|
|
3
|
+
command?: string;
|
|
4
|
+
comments?: string[];
|
|
5
|
+
alwaysRun?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export interface Schema {
|
|
8
|
+
name: string;
|
|
9
|
+
ci: 'github' | 'circleci';
|
|
10
|
+
packageManager?: null;
|
|
11
|
+
commands?: Command[];
|
|
12
|
+
}
|
|
13
|
+
export declare function ciWorkflowGenerator(tree: Tree, schema: Schema): Promise<void>;
|
|
14
|
+
export default ciWorkflowGenerator;
|
|
15
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/ci-workflow/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,IAAI,EACL,MAAM,YAAY,CAAC;AA4CpB,MAAM,MAAM,OAAO,GAAG;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC1B,cAAc,CAAC,EAAE,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAMnE;AAsCD,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ciWorkflowGenerator = ciWorkflowGenerator;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const nx_cloud_utils_1 = require("nx/src/utils/nx-cloud-utils");
|
|
7
|
+
const default_base_1 = require("nx/src/utils/default-base");
|
|
8
|
+
function getCiCommands(ci) {
|
|
9
|
+
switch (ci) {
|
|
10
|
+
case 'circleci': {
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
comments: [
|
|
14
|
+
`# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected.`,
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
command: `./nx affected --base=$NX_BASE --head=$NX_HEAD -t verify-ci`,
|
|
19
|
+
},
|
|
20
|
+
getNxCloudFixCiCommand(),
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
default: {
|
|
24
|
+
return [
|
|
25
|
+
{
|
|
26
|
+
comments: [
|
|
27
|
+
`Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected.`,
|
|
28
|
+
],
|
|
29
|
+
command: `./nx affected -t verify-ci`,
|
|
30
|
+
},
|
|
31
|
+
getNxCloudFixCiCommand(),
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
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
|
+
}
|
|
45
|
+
async function ciWorkflowGenerator(tree, schema) {
|
|
46
|
+
const ci = schema.ci;
|
|
47
|
+
const options = getTemplateData(tree, schema);
|
|
48
|
+
(0, devkit_1.generateFiles)(tree, (0, path_1.join)(__dirname, 'files', ci), '', options);
|
|
49
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
50
|
+
}
|
|
51
|
+
function getTemplateData(tree, options) {
|
|
52
|
+
const { name: workflowName, fileName: workflowFileName } = (0, devkit_1.names)(options.name);
|
|
53
|
+
let nxCloudHost = 'nx.app';
|
|
54
|
+
try {
|
|
55
|
+
const nxCloudUrl = (0, nx_cloud_utils_1.getNxCloudUrl)((0, devkit_1.readNxJson)(tree));
|
|
56
|
+
nxCloudHost = new URL(nxCloudUrl).host;
|
|
57
|
+
}
|
|
58
|
+
catch { }
|
|
59
|
+
const mainBranch = (0, default_base_1.deduceDefaultBase)();
|
|
60
|
+
const commands = options.commands ?? getCiCommands(options.ci);
|
|
61
|
+
const connectedToCloud = (0, nx_cloud_utils_1.isNxCloudUsed)((0, devkit_1.readNxJson)(tree));
|
|
62
|
+
return {
|
|
63
|
+
workflowName,
|
|
64
|
+
workflowFileName,
|
|
65
|
+
commands,
|
|
66
|
+
mainBranch,
|
|
67
|
+
nxCloudHost,
|
|
68
|
+
connectedToCloud,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
exports.default = ciWorkflowGenerator;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Tree } from '@nx/devkit';
|
|
2
|
+
export interface MavenInitGeneratorSchema {
|
|
3
|
+
skipFormat?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function mavenInitGenerator(tree: Tree, options: MavenInitGeneratorSchema): Promise<() => Promise<void>>;
|
|
6
|
+
export default mavenInitGenerator;
|
|
7
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../src/generators/init/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,IAAI,EAIL,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,wBAAwB,gCAiClC;AAsID,eAAe,kBAAkB,CAAC"}
|