Skip to content
Snippets Groups Projects
Commit 279f632b authored by Sergio Zharinov's avatar Sergio Zharinov Committed by Rhys Arkins
Browse files

fix(maven): parse additional Maven repositories from pomfiles (#3198)

parent 27051723
Branches
No related tags found
No related merge requests found
const { XmlDocument } = require('xmldoc');
const { isVersion } = require('../../versioning/maven');
const DEFAULT_MAVEN_REPO = 'https://repo.maven.apache.org/maven2';
function parsePom(raw) {
let project;
try {
......@@ -40,7 +42,7 @@ function depFromNode(node) {
const offset = '<version>'.length - 1;
result.fileReplacePosition = versionNode.startTagPosition + offset;
result.datasource = 'maven';
result.registryUrls = ['https://repo.maven.apache.org/maven2'];
result.registryUrls = [DEFAULT_MAVEN_REPO];
}
return result;
}
......@@ -80,6 +82,22 @@ function extractDependencies(raw) {
result.deps = deepExtract(project);
const repositories = project.childNamed('repositories');
if (repositories && repositories.children) {
const repoUrls = [];
for (const repo of repositories.childrenNamed('repository')) {
const repoUrl = repo.valueWithPath('url');
if (repoUrl) {
repoUrls.push(repoUrl);
}
}
result.deps.forEach(dep => {
if (dep.registryUrls) {
repoUrls.forEach(url => dep.registryUrls.push(url));
}
});
}
return result;
}
......
......@@ -124,4 +124,16 @@
</plugin>
</plugins>
</reporting>
<repositories>
<repository>
<id>atlassian</id>
<name>Atlassian Repository</name>
<url>https://maven.atlassian.com/content/repositories/atlassian-public/</url>
</repository>
<repository>
<id>nonsense</id>
<name>The item without url</name>
</repository>
</repositories>
</project>
......@@ -11,6 +11,7 @@ Object {
"fileReplacePosition": 186,
"registryUrls": Array [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Object {
......@@ -20,6 +21,7 @@ Object {
"fileReplacePosition": 757,
"registryUrls": Array [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Object {
......@@ -29,6 +31,7 @@ Object {
"fileReplacePosition": 905,
"registryUrls": Array [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Object {
......@@ -38,6 +41,7 @@ Object {
"fileReplacePosition": 1337,
"registryUrls": Array [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Object {
......@@ -62,6 +66,7 @@ Object {
"fileReplacePosition": 2529,
"registryUrls": Array [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Object {
......@@ -81,6 +86,7 @@ Object {
"fileReplacePosition": 3218,
"registryUrls": Array [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment