@nx/maven 22.0.1 → 22.0.3
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/generators/ci-workflow/files/circleci/.circleci/config.yml.template +39 -0
- package/dist/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template +42 -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/ci-workflow/schema.json +40 -0
- package/dist/generators.json +5 -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.map +1 -1
- package/dist/plugins/dependencies.js +10 -2
- package/dist/plugins/maven-analyzer.d.ts.map +1 -1
- package/dist/plugins/maven-analyzer.js +2 -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 +1 -1
- package/dist/utils/versions.js +1 -1
- package/generators.json +5 -0
- package/package.json +6 -6
|
@@ -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
|
package/dist/generators/ci-workflow/files/github/.github/workflows/__workflowFileName__.yml.template
ADDED
|
@@ -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,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,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
|
+
}
|
package/dist/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
|
}
|
|
@@ -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
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/plugins/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAqB,MAAM,YAAY,CAAC;
|
|
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"}
|
|
@@ -4,6 +4,7 @@ exports.createDependencies = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const maven_data_cache_1 = require("./maven-data-cache");
|
|
6
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");
|
|
7
8
|
const types_1 = require("./types");
|
|
8
9
|
const workspace_context_1 = require("nx/src/utils/workspace-context");
|
|
9
10
|
const path_1 = require("path");
|
|
@@ -36,7 +37,14 @@ const createDependencies = async (options, context) => {
|
|
|
36
37
|
return [];
|
|
37
38
|
}
|
|
38
39
|
devkit_1.logger.verbose('[Maven Dependencies] Found Maven data with', mavenData.createDependenciesResults.length, 'dependencies');
|
|
39
|
-
//
|
|
40
|
-
|
|
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;
|
|
41
49
|
};
|
|
42
50
|
exports.createDependencies = createDependencies;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maven-analyzer.d.ts","sourceRoot":"","sources":["../../src/plugins/maven-analyzer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAwChE;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"maven-analyzer.d.ts","sourceRoot":"","sources":["../../src/plugins/maven-analyzer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAwChE;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAqH5B"}
|
|
@@ -75,6 +75,8 @@ async function runMavenAnalysis(workspaceRoot, options) {
|
|
|
75
75
|
await new Promise((resolve, reject) => {
|
|
76
76
|
const child = (0, child_process_1.spawn)(mavenExecutable, mavenArgs, {
|
|
77
77
|
cwd: workspaceRoot,
|
|
78
|
+
windowsHide: true,
|
|
79
|
+
shell: true,
|
|
78
80
|
stdio: 'pipe', // Always use pipe so we can control output
|
|
79
81
|
});
|
|
80
82
|
devkit_1.logger.verbose(`[Maven Analyzer] Process spawned with PID: ${child.pid}`);
|
|
@@ -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
|
+
}
|
package/dist/utils/versions.d.ts
CHANGED
package/dist/utils/versions.js
CHANGED
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": "22.0.
|
|
3
|
+
"version": "22.0.3",
|
|
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.0.
|
|
48
|
+
"@nx/devkit": "22.0.3",
|
|
49
49
|
"@xmldom/xmldom": "^0.8.10",
|
|
50
50
|
"tslib": "^2.3.0"
|
|
51
51
|
},
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"@types/jest": "30.0.0",
|
|
54
54
|
"@types/node": "^20.19.10",
|
|
55
55
|
"@types/xmldom": "^0.1.34",
|
|
56
|
-
"jest": "30.0.2",
|
|
56
|
+
"jest": "^30.0.2",
|
|
57
57
|
"memfs": "^4.9.2",
|
|
58
|
-
"nx": "22.0.
|
|
59
|
-
"ts-jest": "^29.
|
|
60
|
-
"typescript": "
|
|
58
|
+
"nx": "22.0.3",
|
|
59
|
+
"ts-jest": "^29.4.0",
|
|
60
|
+
"typescript": "~5.9.2"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|