@nx/maven 0.0.0-pr-33228-85dcafe → 0.0.0-pr-33435-8aff8f5

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.
Files changed (41) hide show
  1. package/dist/executors.json +1 -8
  2. package/dist/generators/ci-workflow/generator.d.ts +15 -0
  3. package/dist/generators/ci-workflow/generator.d.ts.map +1 -0
  4. package/dist/generators/ci-workflow/generator.js +71 -0
  5. package/dist/generators/init/generator.d.ts +7 -0
  6. package/dist/generators/init/generator.d.ts.map +1 -0
  7. package/dist/generators/init/generator.js +134 -0
  8. package/dist/index.d.ts +3 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +8 -0
  11. package/dist/migrations/0-0-8/update-pom-xml-version.d.ts +7 -0
  12. package/dist/migrations/0-0-8/update-pom-xml-version.d.ts.map +1 -0
  13. package/dist/migrations/0-0-8/update-pom-xml-version.js +11 -0
  14. package/dist/migrations/0-0-9/update-pom-xml-version.d.ts +7 -0
  15. package/dist/migrations/0-0-9/update-pom-xml-version.d.ts.map +1 -0
  16. package/dist/migrations/0-0-9/update-pom-xml-version.js +11 -0
  17. package/dist/plugins/dependencies.d.ts +7 -0
  18. package/dist/plugins/dependencies.d.ts.map +1 -0
  19. package/dist/plugins/dependencies.js +50 -0
  20. package/dist/plugins/maven-analyzer.d.ts +6 -0
  21. package/dist/plugins/maven-analyzer.d.ts.map +1 -0
  22. package/dist/plugins/maven-analyzer.js +140 -0
  23. package/dist/plugins/maven-data-cache.d.ts +14 -0
  24. package/dist/plugins/maven-data-cache.d.ts.map +1 -0
  25. package/dist/plugins/maven-data-cache.js +32 -0
  26. package/dist/plugins/nodes.d.ts +7 -0
  27. package/dist/plugins/nodes.d.ts.map +1 -0
  28. package/dist/plugins/nodes.js +64 -0
  29. package/dist/plugins/types.d.ts +14 -0
  30. package/dist/plugins/types.d.ts.map +1 -0
  31. package/dist/plugins/types.js +4 -0
  32. package/dist/utils/pom-xml-updater.d.ts +10 -0
  33. package/dist/utils/pom-xml-updater.d.ts.map +1 -0
  34. package/dist/utils/pom-xml-updater.js +45 -0
  35. package/dist/utils/versions.d.ts +3 -0
  36. package/dist/utils/versions.d.ts.map +1 -0
  37. package/dist/utils/versions.js +5 -0
  38. package/executors.json +1 -8
  39. package/package.json +3 -3
  40. package/dist/batch-runner.jar +0 -0
  41. package/dist/executors/maven/schema.json +0 -56
@@ -1,11 +1,4 @@
1
1
  {
2
2
  "$schema": "../../node_modules/nx/schemas/executors-schema.json",
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
- }
3
+ "executors": {}
11
4
  }
@@ -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"}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mavenInitGenerator = mavenInitGenerator;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const xmldom_1 = require("@xmldom/xmldom");
6
+ const versions_1 = require("../../utils/versions");
7
+ async function mavenInitGenerator(tree, options) {
8
+ const tasks = [];
9
+ // Add Maven-related dependencies if package.json exists
10
+ if (tree.exists('package.json')) {
11
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
12
+ '@nx/maven': versions_1.nxVersion,
13
+ });
14
+ tasks.push(installTask);
15
+ }
16
+ else {
17
+ devkit_1.logger.info('No package.json found, skipping dependency installation');
18
+ }
19
+ // Add nx-maven-analyzer plugin to root pom.xml if it exists
20
+ addNxMavenAnalyzerPlugin(tree);
21
+ // Add @nx/maven to plugins array in nx.json
22
+ addPluginToNxJson(tree);
23
+ if (!options.skipFormat) {
24
+ await (0, devkit_1.formatFiles)(tree);
25
+ }
26
+ return async () => {
27
+ for (const task of tasks) {
28
+ await task();
29
+ }
30
+ };
31
+ }
32
+ function addNxMavenAnalyzerPlugin(tree) {
33
+ const rootPomPath = 'pom.xml';
34
+ if (!tree.exists(rootPomPath)) {
35
+ devkit_1.logger.warn('Root pom.xml not found, skipping nx-maven-analyzer plugin addition');
36
+ return;
37
+ }
38
+ const pomContent = tree.read(rootPomPath, 'utf-8');
39
+ if (!pomContent) {
40
+ devkit_1.logger.warn('Unable to read root pom.xml content');
41
+ return;
42
+ }
43
+ // Check if plugin is already present
44
+ if (pomContent.includes('dev.nx.maven') &&
45
+ pomContent.includes('nx-maven-plugin')) {
46
+ devkit_1.logger.info('nx-maven plugin already present in pom.xml');
47
+ return;
48
+ }
49
+ const updatedPomContent = addPluginToPom(pomContent);
50
+ if (updatedPomContent !== pomContent) {
51
+ tree.write(rootPomPath, updatedPomContent);
52
+ devkit_1.logger.info('Added nx-maven-analyzer plugin to root pom.xml');
53
+ }
54
+ }
55
+ function addPluginToNxJson(tree) {
56
+ if (!tree.exists('nx.json')) {
57
+ devkit_1.logger.warn('nx.json not found, skipping plugin registration');
58
+ return;
59
+ }
60
+ const nxJson = (0, devkit_1.readNxJson)(tree);
61
+ if (!nxJson) {
62
+ devkit_1.logger.warn('Unable to read nx.json content');
63
+ return;
64
+ }
65
+ // Initialize plugins array if it doesn't exist
66
+ if (!nxJson.plugins) {
67
+ nxJson.plugins = [];
68
+ }
69
+ // Check if @nx/maven is already in plugins
70
+ const pluginExists = nxJson.plugins.some((plugin) => typeof plugin === 'string'
71
+ ? plugin === '@nx/maven'
72
+ : plugin?.plugin === '@nx/maven');
73
+ if (pluginExists) {
74
+ devkit_1.logger.info('@nx/maven plugin already registered in nx.json');
75
+ return;
76
+ }
77
+ // Add @nx/maven to plugins array
78
+ nxJson.plugins.push('@nx/maven');
79
+ (0, devkit_1.updateNxJson)(tree, nxJson);
80
+ devkit_1.logger.info('Added @nx/maven to plugins array in nx.json');
81
+ }
82
+ function addPluginToPom(pomContent) {
83
+ try {
84
+ const parser = new xmldom_1.DOMParser();
85
+ const serializer = new xmldom_1.XMLSerializer();
86
+ const doc = parser.parseFromString(pomContent, 'application/xml');
87
+ const project = doc.getElementsByTagName('project')[0];
88
+ if (!project) {
89
+ devkit_1.logger.warn('Could not find <project> element in pom.xml');
90
+ return pomContent;
91
+ }
92
+ // Find or create <build> element
93
+ let build = project.getElementsByTagName('build')[0];
94
+ if (!build) {
95
+ build = doc.createElement('build');
96
+ project.appendChild(doc.createTextNode('\n '));
97
+ project.appendChild(build);
98
+ project.appendChild(doc.createTextNode('\n'));
99
+ }
100
+ // Find or create <plugins> element
101
+ let plugins = build.getElementsByTagName('plugins')[0];
102
+ if (!plugins) {
103
+ plugins = doc.createElement('plugins');
104
+ build.appendChild(doc.createTextNode('\n '));
105
+ build.appendChild(plugins);
106
+ build.appendChild(doc.createTextNode('\n '));
107
+ }
108
+ // Create the nx-maven-analyzer plugin element
109
+ const plugin = doc.createElement('plugin');
110
+ const groupId = doc.createElement('groupId');
111
+ groupId.appendChild(doc.createTextNode('dev.nx.maven'));
112
+ plugin.appendChild(doc.createTextNode('\n '));
113
+ plugin.appendChild(groupId);
114
+ const artifactId = doc.createElement('artifactId');
115
+ artifactId.appendChild(doc.createTextNode('nx-maven-plugin'));
116
+ plugin.appendChild(doc.createTextNode('\n '));
117
+ plugin.appendChild(artifactId);
118
+ const version = doc.createElement('version');
119
+ version.appendChild(doc.createTextNode(versions_1.mavenPluginVersion));
120
+ plugin.appendChild(doc.createTextNode('\n '));
121
+ plugin.appendChild(version);
122
+ plugin.appendChild(doc.createTextNode('\n '));
123
+ // Add plugin to plugins element
124
+ plugins.appendChild(doc.createTextNode('\n '));
125
+ plugins.appendChild(plugin);
126
+ plugins.appendChild(doc.createTextNode('\n '));
127
+ return serializer.serializeToString(doc);
128
+ }
129
+ catch (error) {
130
+ devkit_1.logger.error(`Failed to parse or modify pom.xml: ${error instanceof Error ? error.message : error}`);
131
+ return pomContent;
132
+ }
133
+ }
134
+ exports.default = mavenInitGenerator;
@@ -0,0 +1,3 @@
1
+ export { createNodes, createNodes as createNodesV2 } from './plugins/nodes';
2
+ export { createDependencies } from './plugins/dependencies';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDependencies = exports.createNodesV2 = exports.createNodes = void 0;
4
+ var nodes_1 = require("./plugins/nodes");
5
+ Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return nodes_1.createNodes; } });
6
+ Object.defineProperty(exports, "createNodesV2", { enumerable: true, get: function () { return nodes_1.createNodes; } });
7
+ var dependencies_1 = require("./plugins/dependencies");
8
+ Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return dependencies_1.createDependencies; } });
@@ -0,0 +1,7 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * Migration for @nx/maven v0.0.8
4
+ * Updates the Maven plugin version from 0.0.7 to 0.0.8 in user pom.xml files
5
+ */
6
+ export default function update(tree: Tree): Promise<void>;
7
+ //# sourceMappingURL=update-pom-xml-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-pom-xml-version.d.ts","sourceRoot":"","sources":["../../../src/migrations/0-0-8/update-pom-xml-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGlC;;;GAGG;AACH,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,iBAE9C"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = update;
4
+ const pom_xml_updater_1 = require("../../utils/pom-xml-updater");
5
+ /**
6
+ * Migration for @nx/maven v0.0.8
7
+ * Updates the Maven plugin version from 0.0.7 to 0.0.8 in user pom.xml files
8
+ */
9
+ async function update(tree) {
10
+ (0, pom_xml_updater_1.updateNxMavenPluginVersion)(tree, '0.0.8');
11
+ }
@@ -0,0 +1,7 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * Migration for @nx/maven v0.0.9
4
+ * Updates the Maven plugin version from 0.0.8 to 0.0.9 in user pom.xml files
5
+ */
6
+ export default function update(tree: Tree): Promise<void>;
7
+ //# sourceMappingURL=update-pom-xml-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-pom-xml-version.d.ts","sourceRoot":"","sources":["../../../src/migrations/0-0-9/update-pom-xml-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGlC;;;GAGG;AACH,wBAA8B,MAAM,CAAC,IAAI,EAAE,IAAI,iBAE9C"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = update;
4
+ const pom_xml_updater_1 = require("../../utils/pom-xml-updater");
5
+ /**
6
+ * Migration for @nx/maven v0.0.9
7
+ * Updates the Maven plugin version from 0.0.8 to 0.0.9 in user pom.xml files
8
+ */
9
+ async function update(tree) {
10
+ (0, pom_xml_updater_1.updateNxMavenPluginVersion)(tree, '0.0.9');
11
+ }
@@ -0,0 +1,7 @@
1
+ import { CreateDependencies } from '@nx/devkit';
2
+ /**
3
+ * Create dependencies between Maven projects by analyzing the createNodesResults
4
+ * Uses cached Maven analysis data that was generated by createNodesV2
5
+ */
6
+ export declare const createDependencies: CreateDependencies;
7
+ //# sourceMappingURL=dependencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/plugins/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,YAAY,CAAC;AASnE;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBA2DhC,CAAC"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDependencies = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const maven_data_cache_1 = require("./maven-data-cache");
6
+ const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
7
+ const internal_1 = require("@nx/devkit/internal");
8
+ const types_1 = require("./types");
9
+ const workspace_context_1 = require("nx/src/utils/workspace-context");
10
+ const path_1 = require("path");
11
+ const devkit_internals_1 = require("nx/src/devkit-internals");
12
+ /**
13
+ * Create dependencies between Maven projects by analyzing the createNodesResults
14
+ * Uses cached Maven analysis data that was generated by createNodesV2
15
+ */
16
+ const createDependencies = async (options, context) => {
17
+ const opts = {
18
+ ...types_1.DEFAULT_OPTIONS,
19
+ ...options,
20
+ };
21
+ // Get cache path based on options
22
+ const optionsHash = (0, devkit_internals_1.hashObject)(opts);
23
+ const cachePath = (0, maven_data_cache_1.getCachePath)(context.workspaceRoot, optionsHash);
24
+ const mavenCache = (0, maven_data_cache_1.readMavenCache)(cachePath);
25
+ // Find all pom.xml files (same as createNodesV2)
26
+ const configFiles = await (0, workspace_context_1.globWithWorkspaceContext)(context.workspaceRoot, [
27
+ '**/pom.xml',
28
+ ]);
29
+ // Calculate the same hash as createNodesV2
30
+ const projectRoots = configFiles.map((file) => (0, path_1.dirname)(file));
31
+ const hashes = await (0, calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes)(projectRoots, opts, context);
32
+ const hash = (0, devkit_1.hashArray)(hashes);
33
+ // Get cached Maven analysis data that was generated by createNodesV2
34
+ const mavenData = mavenCache[hash];
35
+ if (!mavenData) {
36
+ devkit_1.logger.verbose('[Maven Dependencies] No Maven data found in workspace:', context.workspaceRoot);
37
+ return [];
38
+ }
39
+ devkit_1.logger.verbose('[Maven Dependencies] Found Maven data with', mavenData.createDependenciesResults.length, 'dependencies');
40
+ // Create a mapping from project root to project name
41
+ const rootToProjectMap = (0, internal_1.createProjectRootMappingsFromProjectConfigurations)(context.projects);
42
+ // Extract and transform dependencies from the mavenData
43
+ const transformedDependencies = mavenData.createDependenciesResults.map((dep) => ({
44
+ ...dep,
45
+ source: rootToProjectMap.get(dep.source),
46
+ target: rootToProjectMap.get(dep.target),
47
+ }));
48
+ return transformedDependencies;
49
+ };
50
+ exports.createDependencies = createDependencies;
@@ -0,0 +1,6 @@
1
+ import { MavenAnalysisData, MavenPluginOptions } from './types';
2
+ /**
3
+ * Run Maven analysis using our Kotlin analyzer plugin
4
+ */
5
+ export declare function runMavenAnalysis(workspaceRoot: string, options: MavenPluginOptions): Promise<MavenAnalysisData>;
6
+ //# sourceMappingURL=maven-analyzer.d.ts.map
@@ -0,0 +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;AAwChE;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAqH5B"}
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runMavenAnalysis = runMavenAnalysis;
4
+ const path_1 = require("path");
5
+ const fs_1 = require("fs");
6
+ const child_process_1 = require("child_process");
7
+ const devkit_1 = require("@nx/devkit");
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
+ }
43
+ /**
44
+ * Run Maven analysis using our Kotlin analyzer plugin
45
+ */
46
+ async function runMavenAnalysis(workspaceRoot, options) {
47
+ console.log(`[Maven Analyzer] Starting analysis with options:`, options);
48
+ const outputFile = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'nx-maven-projects.json');
49
+ const isVerbose = options.verbose || process.env.NX_VERBOSE_LOGGING === 'true';
50
+ devkit_1.logger.verbose(`[Maven Analyzer] Output file: ${outputFile}`);
51
+ devkit_1.logger.verbose(`[Maven Analyzer] Verbose mode: ${isVerbose}`);
52
+ devkit_1.logger.verbose(`[Maven Analyzer] Workspace root: ${workspaceRoot}`);
53
+ devkit_1.logger.verbose(`[Maven Analyzer] Workspace data directory: ${cache_directory_1.workspaceDataDirectory}`);
54
+ // Detect Maven executable (mvnd > mvnw > mvn)
55
+ const mavenExecutable = detectMavenExecutable(workspaceRoot);
56
+ const mavenArgs = [
57
+ 'dev.nx.maven:nx-maven-plugin:analyze',
58
+ '-am',
59
+ `-DoutputFile=${outputFile}`,
60
+ `-DworkspaceRoot=${workspaceRoot}`,
61
+ '--batch-mode',
62
+ '--no-transfer-progress',
63
+ ];
64
+ if (!isVerbose) {
65
+ mavenArgs.push('-q');
66
+ }
67
+ devkit_1.logger.verbose(`[Maven Analyzer] Maven command: ${mavenExecutable} ${mavenArgs.join(' ')}`);
68
+ devkit_1.logger.verbose(`[Maven Analyzer] Working directory: ${workspaceRoot}`);
69
+ // Debug logging for verbose mode
70
+ if (isVerbose) {
71
+ console.error(`Running Maven analyzer with verbose logging: ${mavenExecutable} ${mavenArgs.join(' ')}`);
72
+ }
73
+ // Run Maven plugin
74
+ devkit_1.logger.verbose(`[Maven Analyzer] Spawning Maven process...`);
75
+ await new Promise((resolve, reject) => {
76
+ const child = (0, child_process_1.spawn)(mavenExecutable, mavenArgs, {
77
+ cwd: workspaceRoot,
78
+ windowsHide: true,
79
+ shell: true,
80
+ stdio: 'pipe', // Always use pipe so we can control output
81
+ });
82
+ devkit_1.logger.verbose(`[Maven Analyzer] Process spawned with PID: ${child.pid}`);
83
+ let stdout = '';
84
+ let stderr = '';
85
+ // In verbose mode, forward output to console in real-time
86
+ if (isVerbose) {
87
+ child.stdout?.on('data', (data) => {
88
+ const text = data.toString();
89
+ stdout += text;
90
+ process.stdout.write(text); // Forward to stdout
91
+ });
92
+ child.stderr?.on('data', (data) => {
93
+ const text = data.toString();
94
+ stderr += text;
95
+ process.stderr.write(text); // Forward to stderr
96
+ });
97
+ }
98
+ else {
99
+ child.stdout?.on('data', (data) => {
100
+ const text = data.toString();
101
+ stdout += text;
102
+ devkit_1.logger.verbose(`[Maven Analyzer] Stdout chunk: ${text.trim()}`);
103
+ });
104
+ child.stderr?.on('data', (data) => {
105
+ const text = data.toString();
106
+ stderr += text;
107
+ devkit_1.logger.verbose(`[Maven Analyzer] Stderr chunk: ${text.trim()}`);
108
+ });
109
+ }
110
+ child.on('close', (code) => {
111
+ devkit_1.logger.verbose(`[Maven Analyzer] Process closed with code: ${code}`);
112
+ if (code === 0) {
113
+ devkit_1.logger.verbose(`[Maven Analyzer] Maven analysis completed successfully`);
114
+ resolve();
115
+ }
116
+ else {
117
+ let errorMsg = `Maven analysis failed with code ${code}`;
118
+ if (stderr)
119
+ errorMsg += `\nStderr: ${stderr}`;
120
+ if (stdout && !isVerbose)
121
+ errorMsg += `\nStdout: ${stdout}`;
122
+ console.error(`[Maven Analyzer] Error: ${errorMsg}`);
123
+ reject(new Error(errorMsg));
124
+ }
125
+ });
126
+ child.on('error', (error) => {
127
+ console.error(`[Maven Analyzer] Process error: ${error.message}`);
128
+ reject(new Error(`Failed to spawn Maven process: ${error.message}`));
129
+ });
130
+ });
131
+ // Read and parse the JSON output
132
+ devkit_1.logger.verbose(`[Maven Analyzer] Checking for output file: ${outputFile}`);
133
+ if (!(0, fs_1.existsSync)(outputFile)) {
134
+ console.error(`[Maven Analyzer] Output file not found: ${outputFile}`);
135
+ throw new Error(`Maven analysis output file not found: ${outputFile}`);
136
+ }
137
+ const result = (0, devkit_1.readJsonFile)(outputFile);
138
+ devkit_1.logger.verbose(`[Maven Analyzer] Output file size: ${result.length} characters`);
139
+ return result;
140
+ }
@@ -0,0 +1,14 @@
1
+ import { MavenAnalysisData } from './types';
2
+ /**
3
+ * Read the Maven targets cache from disk
4
+ */
5
+ export declare function readMavenCache(cachePath: string): Record<string, MavenAnalysisData>;
6
+ /**
7
+ * Write the Maven targets cache to disk
8
+ */
9
+ export declare function writeMavenCache(cachePath: string, cache: Record<string, MavenAnalysisData>): void;
10
+ /**
11
+ * Get the cache path for a given options hash
12
+ */
13
+ export declare function getCachePath(workspaceRoot: string, optionsHash: string): string;
14
+ //# sourceMappingURL=maven-data-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maven-data-cache.d.ts","sourceRoot":"","sources":["../../src/plugins/maven-data-cache.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;GAEG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,GAChB,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAQnC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,GACvC,IAAI,CAEN;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAClB,MAAM,CAOR"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readMavenCache = readMavenCache;
4
+ exports.writeMavenCache = writeMavenCache;
5
+ exports.getCachePath = getCachePath;
6
+ const path_1 = require("path");
7
+ const devkit_1 = require("@nx/devkit");
8
+ /**
9
+ * Read the Maven targets cache from disk
10
+ */
11
+ function readMavenCache(cachePath) {
12
+ try {
13
+ return process.env.NX_CACHE_PROJECT_GRAPH !== 'false'
14
+ ? (0, devkit_1.readJsonFile)(cachePath)
15
+ : {};
16
+ }
17
+ catch {
18
+ return {};
19
+ }
20
+ }
21
+ /**
22
+ * Write the Maven targets cache to disk
23
+ */
24
+ function writeMavenCache(cachePath, cache) {
25
+ (0, devkit_1.writeJsonFile)(cachePath, cache);
26
+ }
27
+ /**
28
+ * Get the cache path for a given options hash
29
+ */
30
+ function getCachePath(workspaceRoot, optionsHash) {
31
+ return (0, path_1.join)(workspaceRoot, '.nx', 'workspace-data', `maven-${optionsHash}.hash`);
32
+ }
@@ -0,0 +1,7 @@
1
+ import { CreateNodesV2 } from '@nx/devkit';
2
+ import { MavenPluginOptions } from './types';
3
+ /**
4
+ * Maven plugin that analyzes Maven projects and returns configurations
5
+ */
6
+ export declare const createNodes: CreateNodesV2<MavenPluginOptions>;
7
+ //# sourceMappingURL=nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/plugins/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,aAAa,EAAa,MAAM,YAAY,CAAC;AAE3E,OAAO,EAAmB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAU9D;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,aAAa,CAAC,kBAAkB,CAiEzD,CAAC"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createNodes = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ const types_1 = require("./types");
7
+ const maven_analyzer_1 = require("./maven-analyzer");
8
+ const maven_data_cache_1 = require("./maven-data-cache");
9
+ const calculate_hash_for_create_nodes_1 = require("@nx/devkit/src/utils/calculate-hash-for-create-nodes");
10
+ const devkit_internals_1 = require("nx/src/devkit-internals");
11
+ /**
12
+ * Maven plugin that analyzes Maven projects and returns configurations
13
+ */
14
+ exports.createNodes = [
15
+ '**/pom.xml',
16
+ async (configFiles, options, context) => {
17
+ const opts = {
18
+ ...types_1.DEFAULT_OPTIONS,
19
+ ...options,
20
+ };
21
+ // Check for verbose logging from multiple sources
22
+ const isVerbose = opts.verbose || process.env.NX_VERBOSE_LOGGING === 'true';
23
+ if (isVerbose) {
24
+ console.error(`Maven plugin running in verbose mode (NX_VERBOSE_LOGGING=${process.env.NX_VERBOSE_LOGGING})`);
25
+ }
26
+ // Only process if we have the root pom.xml in the workspace root
27
+ const rootPomExists = configFiles.some((file) => file === 'pom.xml');
28
+ if (!rootPomExists) {
29
+ return [];
30
+ }
31
+ // Get cache path based on options
32
+ const optionsHash = (0, devkit_internals_1.hashObject)(opts);
33
+ const cachePath = (0, maven_data_cache_1.getCachePath)(context.workspaceRoot, optionsHash);
34
+ const mavenCache = (0, maven_data_cache_1.readMavenCache)(cachePath);
35
+ // Calculate hashes for all pom.xml directories
36
+ const projectRoots = configFiles.map((file) => (0, path_1.dirname)(file));
37
+ const hashes = await (0, calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes)(projectRoots, opts, context);
38
+ // Combine all hashes into a single hash for the cache key
39
+ const hash = (0, devkit_1.hashArray)(hashes);
40
+ try {
41
+ // Try to get cached data first (skip cache if in verbose mode)
42
+ let mavenData = isVerbose ? null : mavenCache[hash];
43
+ // If no cached data or cache is stale, run fresh Maven analysis
44
+ if (!mavenData) {
45
+ mavenData = await (0, maven_analyzer_1.runMavenAnalysis)(context.workspaceRoot, {
46
+ ...opts,
47
+ verbose: isVerbose,
48
+ });
49
+ // Cache the results with the hash
50
+ mavenCache[hash] = mavenData;
51
+ }
52
+ // Return createNodesResults (atomization now handled in Kotlin)
53
+ return mavenData.createNodesResults.map(([configFile, createNodesResult]) => {
54
+ return [
55
+ (0, path_1.relative)(context.workspaceRoot, configFile),
56
+ createNodesResult,
57
+ ];
58
+ });
59
+ }
60
+ finally {
61
+ (0, maven_data_cache_1.writeMavenCache)(cachePath, mavenCache);
62
+ }
63
+ },
64
+ ];
@@ -0,0 +1,14 @@
1
+ import type { CreateNodesResultV2 } from '@nx/devkit';
2
+ import type { RawProjectGraphDependency } from 'nx/src/project-graph/project-graph-builder';
3
+ export interface MavenPluginOptions {
4
+ verbose?: boolean;
5
+ }
6
+ export declare const DEFAULT_OPTIONS: MavenPluginOptions;
7
+ export interface MavenAnalysisData {
8
+ createNodesResults: CreateNodesResultV2;
9
+ createDependenciesResults: RawProjectGraphDependency[];
10
+ generatedAt?: number;
11
+ workspaceRoot?: string;
12
+ totalProjects?: number;
13
+ }
14
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAE5F,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,eAAe,EAAE,kBAAuB,CAAC;AAKtD,MAAM,WAAW,iBAAiB;IAChC,kBAAkB,EAAE,mBAAmB,CAAC;IACxC,yBAAyB,EAAE,yBAAyB,EAAE,CAAC;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_OPTIONS = void 0;
4
+ exports.DEFAULT_OPTIONS = {};
@@ -0,0 +1,10 @@
1
+ import { Tree } from '@nx/devkit';
2
+ /**
3
+ * Updates the version of dev.nx.maven:nx-maven-plugin in pom.xml files.
4
+ * Only updates the version element that belongs to the nx-maven-plugin.
5
+ *
6
+ * @param tree - Nx Tree instance
7
+ * @param version - The new version to set
8
+ */
9
+ export declare function updateNxMavenPluginVersion(tree: Tree, version: string): void;
10
+ //# sourceMappingURL=pom-xml-updater.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pom-xml-updater.d.ts","sourceRoot":"","sources":["../../src/utils/pom-xml-updater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGlC;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CA2C5E"}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateNxMavenPluginVersion = updateNxMavenPluginVersion;
4
+ const xmldom_1 = require("@xmldom/xmldom");
5
+ /**
6
+ * Updates the version of dev.nx.maven:nx-maven-plugin in pom.xml files.
7
+ * Only updates the version element that belongs to the nx-maven-plugin.
8
+ *
9
+ * @param tree - Nx Tree instance
10
+ * @param version - The new version to set
11
+ */
12
+ function updateNxMavenPluginVersion(tree, version) {
13
+ const pomPath = 'pom.xml';
14
+ if (!tree.exists(pomPath)) {
15
+ return;
16
+ }
17
+ const content = tree.read(pomPath, 'utf-8');
18
+ const parser = new xmldom_1.DOMParser();
19
+ const doc = parser.parseFromString(content);
20
+ let hasChanges = false;
21
+ // Find all plugin elements in the document
22
+ const plugins = Array.from(doc.getElementsByTagName('plugin'));
23
+ for (const plugin of plugins) {
24
+ // Check if this is the nx-maven-plugin by looking for groupId and artifactId
25
+ const groupId = plugin.getElementsByTagName('groupId')[0];
26
+ const artifactId = plugin.getElementsByTagName('artifactId')[0];
27
+ const isNxMavenPlugin = groupId?.textContent?.trim() === 'dev.nx.maven' &&
28
+ artifactId?.textContent?.trim() === 'nx-maven-plugin';
29
+ // If this is the nx-maven-plugin, update its version
30
+ if (isNxMavenPlugin) {
31
+ const versionElement = plugin.getElementsByTagName('version')[0];
32
+ const currentVersion = versionElement?.textContent?.trim();
33
+ if (currentVersion && currentVersion !== version) {
34
+ versionElement.textContent = version;
35
+ hasChanges = true;
36
+ }
37
+ }
38
+ }
39
+ // If content changed, write it back using XML serializer to preserve formatting
40
+ if (hasChanges) {
41
+ const serializer = new xmldom_1.XMLSerializer();
42
+ const updatedContent = serializer.serializeToString(doc);
43
+ tree.write(pomPath, updatedContent);
44
+ }
45
+ }
@@ -0,0 +1,3 @@
1
+ export declare const nxVersion: any;
2
+ export declare const mavenPluginVersion = "0.0.9";
3
+ //# sourceMappingURL=versions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../src/utils/versions.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,KAAwC,CAAC;AAC/D,eAAO,MAAM,kBAAkB,UAAU,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mavenPluginVersion = exports.nxVersion = void 0;
4
+ exports.nxVersion = require('../../package.json').version;
5
+ exports.mavenPluginVersion = '0.0.9';
package/executors.json CHANGED
@@ -1,11 +1,4 @@
1
1
  {
2
2
  "$schema": "../../node_modules/nx/schemas/executors-schema.json",
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
- }
3
+ "executors": {}
11
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/maven",
3
- "version": "0.0.0-pr-33228-85dcafe",
3
+ "version": "0.0.0-pr-33435-8aff8f5",
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.1.0-beta.5",
48
+ "@nx/devkit": "0.0.0-pr-33435-8aff8f5",
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": "0.0.0-pr-33228-85dcafe",
58
+ "nx": "0.0.0-pr-33435-8aff8f5",
59
59
  "ts-jest": "^29.4.0",
60
60
  "typescript": "~5.9.2"
61
61
  },
Binary file
@@ -1,56 +0,0 @@
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
- "excludeDependsOn": {
42
- "type": "boolean",
43
- "description": "If true, the tasks will not execute their dependsOn tasks. If false, the task will execute its dependsOn tasks.",
44
- "default": true,
45
- "x-priority": "internal"
46
- },
47
- "__unparsed__": {
48
- "type": "array",
49
- "items": {
50
- "type": "string"
51
- },
52
- "description": "Additional arguments to pass to the Maven command (automatically populated by Nx).",
53
- "x-priority": "internal"
54
- }
55
- }
56
- }