@nx/maven 0.0.0-pr-33300-a25d58c → 0.0.0-pr-33228-85dcafe

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 (34) hide show
  1. package/dist/batch-runner.jar +0 -0
  2. package/dist/executors/maven/schema.json +56 -0
  3. package/dist/executors.json +8 -1
  4. package/dist/generators/ci-workflow/files/circleci/.circleci/config.yml.template +39 -0
  5. package/dist/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template +42 -0
  6. package/dist/generators/ci-workflow/schema.json +40 -0
  7. package/dist/generators.json +5 -0
  8. package/executors.json +8 -1
  9. package/generators.json +5 -0
  10. package/package.json +3 -3
  11. package/dist/generators/init/generator.d.ts +0 -7
  12. package/dist/generators/init/generator.d.ts.map +0 -1
  13. package/dist/generators/init/generator.js +0 -134
  14. package/dist/index.d.ts +0 -3
  15. package/dist/index.d.ts.map +0 -1
  16. package/dist/index.js +0 -8
  17. package/dist/plugins/dependencies.d.ts +0 -7
  18. package/dist/plugins/dependencies.d.ts.map +0 -1
  19. package/dist/plugins/dependencies.js +0 -42
  20. package/dist/plugins/maven-analyzer.d.ts +0 -6
  21. package/dist/plugins/maven-analyzer.d.ts.map +0 -1
  22. package/dist/plugins/maven-analyzer.js +0 -140
  23. package/dist/plugins/maven-data-cache.d.ts +0 -14
  24. package/dist/plugins/maven-data-cache.d.ts.map +0 -1
  25. package/dist/plugins/maven-data-cache.js +0 -32
  26. package/dist/plugins/nodes.d.ts +0 -7
  27. package/dist/plugins/nodes.d.ts.map +0 -1
  28. package/dist/plugins/nodes.js +0 -64
  29. package/dist/plugins/types.d.ts +0 -14
  30. package/dist/plugins/types.d.ts.map +0 -1
  31. package/dist/plugins/types.js +0 -4
  32. package/dist/utils/versions.d.ts +0 -3
  33. package/dist/utils/versions.d.ts.map +0 -1
  34. package/dist/utils/versions.js +0 -5
Binary file
@@ -0,0 +1,56 @@
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
+ }
@@ -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
  }
@@ -0,0 +1,39 @@
1
+ version: 2.1
2
+
3
+ orbs:
4
+ nx: nrwl/nx@1.7.0
5
+
6
+ env:
7
+ NX_BATCH_MODE: true
8
+
9
+ jobs:
10
+ main:
11
+ environment:
12
+ # Configure the JVM to avoid OOM errors
13
+ _JAVA_OPTIONS: "-Xmx3g"
14
+ MAVEN_OPTS: "-Xmx3g"
15
+ docker:
16
+ - image: cimg/openjdk:21.0-node
17
+ steps:
18
+ - checkout
19
+
20
+ # This enables task distribution via Nx Cloud
21
+ # Run this command as early as possible, before dependencies are installed
22
+ # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
23
+ <% if (connectedToCloud) { %># Uncomment this line to enable task distribution<% } else { %># Connect your workspace by running "nx connect" and uncomment this line to enable task distribution<% } %>
24
+ # - run: ./nx start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="verify-ci"
25
+
26
+ - nx/set-shas:
27
+ main-branch-name: '<%= mainBranch %>'
28
+ <% for (const command of commands) { %><% if (command.comments) { %><% for (const comment of command.comments) { %>
29
+ # <%- comment %><% } %><% } %><% if (command.command) { %>
30
+ - run:
31
+ command: <%= command.command %><% if (command.alwaysRun) { %>
32
+ when: always<% } %><% } %><% } %>
33
+
34
+ workflows:
35
+ version: 2
36
+
37
+ <%= workflowFileName %>:
38
+ jobs:
39
+ - main
@@ -0,0 +1,42 @@
1
+ name: <%= workflowName %>
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - <%= mainBranch %>
7
+ pull_request:
8
+
9
+ permissions:
10
+ actions: read
11
+ contents: read
12
+
13
+ env:
14
+ NX_BATCH_MODE: true
15
+
16
+ jobs:
17
+ main:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ with:
22
+ fetch-depth: 0
23
+ filter: tree:0
24
+
25
+ # This enables task distribution via Nx Cloud
26
+ # Run this command as early as possible, before dependencies are installed
27
+ # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
28
+ <% if (connectedToCloud) { %># Uncomment this line to enable task distribution<% } else { %># Connect your workspace by running "nx connect" and uncomment this line to enable task distribution<% } %>
29
+ # - run: ./nx start-ci-run --distribute-on="3 linux-medium-jvm" --stop-agents-after="verify-ci"
30
+
31
+ - name: Set up JDK 21 for x64
32
+ uses: actions/setup-java@v4
33
+ with:
34
+ java-version: '21'
35
+ distribution: 'temurin'
36
+ architecture: x64
37
+
38
+ - uses: nrwl/nx-set-shas@v4
39
+ <% for (const command of commands) { %><% if (command.comments) { %><% for (const comment of command.comments) { %>
40
+ # <%- comment %><% } %><% } %><% if (command.command) { %>
41
+ - run: <%= command.command %><% if (command.alwaysRun) { %>
42
+ if: always()<% } %><% } %><% } %>
@@ -0,0 +1,40 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "NxMavenCiWorkflowSchema",
4
+ "title": "Maven CI Workflow Generator",
5
+ "description": "Setup a CI Workflow to run Nx in CI.",
6
+ "type": "object",
7
+ "properties": {
8
+ "ci": {
9
+ "type": "string",
10
+ "description": "CI provider.",
11
+ "enum": ["github", "circleci"],
12
+ "x-prompt": {
13
+ "message": "What is your target CI provider?",
14
+ "type": "list",
15
+ "items": [
16
+ {
17
+ "value": "github",
18
+ "label": "GitHub Actions"
19
+ },
20
+ {
21
+ "value": "circleci",
22
+ "label": "Circle CI"
23
+ }
24
+ ]
25
+ }
26
+ },
27
+ "name": {
28
+ "type": "string",
29
+ "description": "Workflow name.",
30
+ "$default": {
31
+ "$source": "argv",
32
+ "index": 0
33
+ },
34
+ "default": "CI",
35
+ "x-prompt": "How should we name your workflow?",
36
+ "pattern": "^[a-zA-Z].*$"
37
+ }
38
+ },
39
+ "required": ["ci", "name"]
40
+ }
@@ -5,6 +5,11 @@
5
5
  "implementation": "./dist/generators/init/generator",
6
6
  "schema": "./dist/generators/init/schema.json",
7
7
  "description": "Initialize Maven support in an Nx workspace"
8
+ },
9
+ "ci-workflow": {
10
+ "implementation": "./dist/generators/ci-workflow/generator",
11
+ "schema": "./dist/generators/ci-workflow/schema.json",
12
+ "description": "Setup a CI Workflow to run Nx in CI"
8
13
  }
9
14
  }
10
15
  }
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/generators.json CHANGED
@@ -5,6 +5,11 @@
5
5
  "implementation": "./dist/generators/init/generator",
6
6
  "schema": "./dist/generators/init/schema.json",
7
7
  "description": "Initialize Maven support in an Nx workspace"
8
+ },
9
+ "ci-workflow": {
10
+ "implementation": "./dist/generators/ci-workflow/generator",
11
+ "schema": "./dist/generators/ci-workflow/schema.json",
12
+ "description": "Setup a CI Workflow to run Nx in CI"
8
13
  }
9
14
  }
10
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/maven",
3
- "version": "0.0.0-pr-33300-a25d58c",
3
+ "version": "0.0.0-pr-33228-85dcafe",
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": "0.0.0-pr-33300-a25d58c",
48
+ "@nx/devkit": "22.1.0-beta.5",
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-33300-a25d58c",
58
+ "nx": "0.0.0-pr-33228-85dcafe",
59
59
  "ts-jest": "^29.4.0",
60
60
  "typescript": "~5.9.2"
61
61
  },
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,134 +0,0 @@
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;
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { createNodes, createNodes as createNodesV2 } from './plugins/nodes';
2
- export { createDependencies } from './plugins/dependencies';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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 DELETED
@@ -1,8 +0,0 @@
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; } });
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/plugins/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,YAAY,CAAC;AAQnE;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBA8ChC,CAAC"}
@@ -1,42 +0,0 @@
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 types_1 = require("./types");
8
- const workspace_context_1 = require("nx/src/utils/workspace-context");
9
- const path_1 = require("path");
10
- const devkit_internals_1 = require("nx/src/devkit-internals");
11
- /**
12
- * Create dependencies between Maven projects by analyzing the createNodesResults
13
- * Uses cached Maven analysis data that was generated by createNodesV2
14
- */
15
- const createDependencies = async (options, context) => {
16
- const opts = {
17
- ...types_1.DEFAULT_OPTIONS,
18
- ...options,
19
- };
20
- // Get cache path based on options
21
- const optionsHash = (0, devkit_internals_1.hashObject)(opts);
22
- const cachePath = (0, maven_data_cache_1.getCachePath)(context.workspaceRoot, optionsHash);
23
- const mavenCache = (0, maven_data_cache_1.readMavenCache)(cachePath);
24
- // Find all pom.xml files (same as createNodesV2)
25
- const configFiles = await (0, workspace_context_1.globWithWorkspaceContext)(context.workspaceRoot, [
26
- '**/pom.xml',
27
- ]);
28
- // Calculate the same hash as createNodesV2
29
- const projectRoots = configFiles.map((file) => (0, path_1.dirname)(file));
30
- const hashes = await (0, calculate_hash_for_create_nodes_1.calculateHashesForCreateNodes)(projectRoots, opts, context);
31
- const hash = (0, devkit_1.hashArray)(hashes);
32
- // Get cached Maven analysis data that was generated by createNodesV2
33
- const mavenData = mavenCache[hash];
34
- if (!mavenData) {
35
- devkit_1.logger.verbose('[Maven Dependencies] No Maven data found in workspace:', context.workspaceRoot);
36
- return [];
37
- }
38
- devkit_1.logger.verbose('[Maven Dependencies] Found Maven data with', mavenData.createDependenciesResults.length, 'dependencies');
39
- // Extract dependencies from the mavenData
40
- return mavenData.createDependenciesResults;
41
- };
42
- exports.createDependencies = createDependencies;
@@ -1,6 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,140 +0,0 @@
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
- }
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,32 +0,0 @@
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
- }
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,64 +0,0 @@
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
- ];
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_OPTIONS = void 0;
4
- exports.DEFAULT_OPTIONS = {};
@@ -1,3 +0,0 @@
1
- export declare const nxVersion: any;
2
- export declare const mavenPluginVersion = "0.0.7";
3
- //# sourceMappingURL=versions.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,5 +0,0 @@
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.7';