mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
refactor(maven): share POM coordinate reads (#16424)
This commit is contained in:
1 parent
090e97c90b
commit
870ea36d94
1 file changed
+12
-19
@@ -246,6 +246,12 @@ const mavenRows = (
|
||||
: xmlChildrenNamed(container, rowName, container.namespaceURI ?? "");
|
||||
};
|
||||
|
||||
const mavenCoordinates = (element: Element) => ({
|
||||
group_id: childText(element, "groupId"),
|
||||
artifact_id: childText(element, "artifactId"),
|
||||
version: childText(element, "version"),
|
||||
});
|
||||
|
||||
const parseMavenDependencies = <
|
||||
Origin extends "dependencies" | "dependencyManagement",
|
||||
>(
|
||||
@@ -255,9 +261,7 @@ const parseMavenDependencies = <
|
||||
maven4Model: boolean,
|
||||
): MavenGradleDependency<Origin>[] =>
|
||||
elements.map((element, index) => {
|
||||
const group_id = childText(element, "groupId");
|
||||
const artifact_id = childText(element, "artifactId");
|
||||
const version = childText(element, "version");
|
||||
const coordinates = mavenCoordinates(element);
|
||||
const type = childText(element, "type");
|
||||
const scope = childText(element, "scope");
|
||||
// Maven 4 also imports a managed `bom` type, whatever its scope. Only a
|
||||
@@ -274,12 +278,7 @@ const parseMavenDependencies = <
|
||||
);
|
||||
const owner =
|
||||
origin === "dependencies" ? "dependency" : "dependency_management";
|
||||
unresolved.coordinates(
|
||||
{ group_id, artifact_id, version },
|
||||
owner,
|
||||
index,
|
||||
false,
|
||||
);
|
||||
unresolved.coordinates(coordinates, owner, index, false);
|
||||
const optional_spelling = childText(element, "optional");
|
||||
const classifier = childText(element, "classifier");
|
||||
unresolved.properties(
|
||||
@@ -293,10 +292,8 @@ const parseMavenDependencies = <
|
||||
index,
|
||||
);
|
||||
return {
|
||||
group_id,
|
||||
artifact_id,
|
||||
version,
|
||||
version_kind: requestedVersionKind(version, "maven-pom"),
|
||||
...coordinates,
|
||||
version_kind: requestedVersionKind(coordinates.version, "maven-pom"),
|
||||
gradle_version: null,
|
||||
scope,
|
||||
type,
|
||||
@@ -354,9 +351,7 @@ const parsePom = (
|
||||
parentElement === undefined
|
||||
? null
|
||||
: {
|
||||
group_id: childText(parentElement, "groupId"),
|
||||
artifact_id: childText(parentElement, "artifactId"),
|
||||
version: childText(parentElement, "version"),
|
||||
...mavenCoordinates(parentElement),
|
||||
packaging: null,
|
||||
relative_path: childText(parentElement, "relativePath"),
|
||||
relative_path_declared:
|
||||
@@ -364,9 +359,7 @@ const parsePom = (
|
||||
};
|
||||
if (parent !== null) unresolved.coordinates(parent, "parent", null, false);
|
||||
const coordinates = {
|
||||
group_id: childText(root, "groupId"),
|
||||
artifact_id: childText(root, "artifactId"),
|
||||
version: childText(root, "version"),
|
||||
...mavenCoordinates(root),
|
||||
packaging: childText(root, "packaging"),
|
||||
};
|
||||
unresolved.coordinates(coordinates, "project", null, parent !== null);
|
||||
|
||||
Reference in new issue
Block a user