diff --git a/src/features/build-tools/model.test.ts b/src/features/build-tools/model.test.ts index 5d9368605..38e485485 100644 --- a/src/features/build-tools/model.test.ts +++ b/src/features/build-tools/model.test.ts @@ -130,7 +130,7 @@ describe("Maven tree", () => { it("shows profiles, then the aggregator with lifecycle, plugins and its modules", () => { const roots = mavenRoots(maven); expect(labels(roots)).toEqual(["Profiles", "Multi Demo"]); - expect(labels(children(roots[0]!))).toEqual(["dev", "ci"]); + expect(labels(children(roots[0]!))).toEqual(["ci", "dev"]); const top = children(roots[1]!); expect(labels(top)).toEqual(["Lifecycle", "Plugins", "core", "Demo App"]); expect(labels(children(top[0]!))).toEqual([ @@ -148,6 +148,22 @@ describe("Maven tree", () => { expect(nodeIcon(roots[1]!)).toBe("maven-project"); }); + it("sorts Maven profiles by ID ignoring case while preserving the order used for Maven arguments", () => { + const model = { + ...maven, + profiles: [ + { id: "zulu", activeByDefault: false }, + { id: "Beta", activeByDefault: false }, + { id: "alpha_ci", activeByDefault: false }, + { id: "alpha", activeByDefault: true }, + { id: "alpha-edge", activeByDefault: false }, + ], + }; + const group = mavenRoots(model)[0]!; + expect(labels(mavenChildren(group, model, [])!)).toEqual(["alpha", "alpha-edge", "alpha_ci", "Beta", "zulu"]); + expect(profilesArg(model.profiles, { zulu: true, alpha_ci: true, alpha: false })).toBe("zulu,alpha_ci,!alpha"); + }); + it("expands plugins to goals and dependencies to their transitive ones", () => { const core = children(mavenRoots(maven)[1]!)[2]!; const kids = children(core); diff --git a/src/features/build-tools/model.ts b/src/features/build-tools/model.ts index 067fedaaf..f84f12379 100644 --- a/src/features/build-tools/model.ts +++ b/src/features/build-tools/model.ts @@ -187,6 +187,11 @@ export function mavenChildren( case "profiles": return model.profiles .filter((p) => p.projectRoot === node.projectRoot) + .sort((a, b) => { + const aId = a.id.toLowerCase(); + const bId = b.id.toLowerCase(); + return aId < bId ? -1 : aId > bId ? 1 : 0; + }) .map((profile) => ({ kind: "profile", key: `mvn:profile:${profileKey(profile)}`, profile })); case "mavenProject": { const p = node.project;