fix(maven): classify embedded brackets as literal qualifiers (#12228)

This commit is contained in:
ShuaixinHuang authored and GitHub committed 2026-11-19 06:35:18 -05:00
1 parent eac4a1cd14
commit ce02c899e8
2 files changed
+22 -1

No files matched your search

+1 -1
View File
@@ -122,7 +122,7 @@ export const requestedVersionKind = (
if (format === "gradle-module") {
if (GRADLE_RANGE.test(value)) return "range";
if (value.endsWith("+") || value.startsWith("latest.")) return "dynamic";
} else if (/[[(]/u.test(value)) return "range";
} else if (value.startsWith("[") || value.startsWith("(")) return "range";
return "literal";
};
@@ -114,6 +114,27 @@ const expectFailure = (
}
};
it("classifies a Maven qualifier with parentheses as a literal version", () => {
const report = parse(`
<project><modelVersion>4.0.0</modelVersion>
<groupId>example</groupId><artifactId>consumer</artifactId><version>1</version>
<dependencies>
<dependency><groupId>example</groupId><artifactId>literal</artifactId><version>1.0-release(build)</version></dependency>
<dependency><groupId>example</groupId><artifactId>range</artifactId><version>(,2.0]</version></dependency>
</dependencies>
</project>
`);
expect(
report.dependencies.map(({ version, version_kind }) => [
version,
version_kind,
]),
).toEqual([
["1.0-release(build)", "literal"],
["(,2.0]", "range"],
]);
});
it("reads Maven coordinates, parent, BOM import, exclusions, ranges and unresolved properties", () => {
const report = parse(mavenPomFixture);
expect(report.format).toBe("maven-pom");