Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(managers/maven): change order of extracted registryUrls #26828

Merged
merged 25 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
970c6c3
follow maven documented repository order
lpriyasivakumar Jan 23, 2024
acbb065
add supported namespaces for maven settings
lpriyasivakumar Jan 23, 2024
7654c4f
Merge branch 'renovatebot:main' into ps/maven-fixes
lpriyasivakumar Jan 23, 2024
d921d88
pr feedback
lpriyasivakumar Jan 24, 2024
5667c29
Update lib/modules/manager/maven/extract.ts
lpriyasivakumar Jan 24, 2024
0e2da99
Merge branch 'renovatebot:main' into ps/maven-fixes
lpriyasivakumar Jan 29, 2024
632d457
test and prettier fixes
lpriyasivakumar Jan 29, 2024
6366d6c
Merge branch 'renovatebot:main' into ps/maven-fixes
lpriyasivakumar Jan 29, 2024
f029d76
refactors from pr feedback
lpriyasivakumar Jan 30, 2024
82b1ac5
Merge branch 'renovatebot:main' into ps/maven-fixes
lpriyasivakumar Jan 30, 2024
0106703
Merge branch 'main' into ps/maven-fixes
lpriyasivakumar Jan 30, 2024
5ad0ab4
remove fixture and refactor
lpriyasivakumar Jan 31, 2024
adc552d
Merge branch 'renovatebot:main' into ps/maven-fixes
lpriyasivakumar Jan 31, 2024
3de2805
Merge branch 'renovatebot:main' into ps/maven-fixes
lpriyasivakumar Feb 2, 2024
09fc354
Apply suggestions from code review
lpriyasivakumar Feb 5, 2024
e582474
Merge branch 'renovatebot:main' into ps/maven-fixes
lpriyasivakumar Feb 5, 2024
90d3ddf
Update lib/modules/manager/maven/extract.ts
lpriyasivakumar Feb 5, 2024
26b365c
Merge branch 'main' into ps/maven-fixes
lpriyasivakumar Feb 5, 2024
0488a23
code cleanup
lpriyasivakumar Feb 6, 2024
cefcaa9
Merge branch 'main' into ps/maven-fixes
lpriyasivakumar Feb 6, 2024
a337279
inline variable
lpriyasivakumar Feb 6, 2024
60c80c7
Merge branch 'ps/maven-fixes' of github.com:lpriyasivakumar/renovate …
lpriyasivakumar Feb 6, 2024
cf8d91b
Merge branch 'main' into ps/maven-fixes
lpriyasivakumar Feb 6, 2024
1a9494f
Merge branch 'main' into ps/maven-fixes
lpriyasivakumar Feb 7, 2024
af490ee
Merge branch 'main' into ps/maven-fixes
lpriyasivakumar Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/modules/manager/maven/__fixtures__/settings.updated.schema.xml
lpriyasivakumar marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
<mirrors>
<mirror>
<id>Test-Internal-repository</id>
<name>Proxy Repository Manager</name>
<url>https:/proxy-repo.com/artifactory/apache-maven</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles/>
<activeProfiles/>
</settings>
18 changes: 0 additions & 18 deletions lib/modules/manager/maven/__snapshots__/extract.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "parent",
"fileReplacePosition": 186,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
secustor marked this conversation as resolved.
Show resolved Hide resolved
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -22,7 +21,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "compile",
"fileReplacePosition": 905,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -33,7 +31,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "compile",
"fileReplacePosition": 1093,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -44,7 +41,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "build",
"fileReplacePosition": 1347,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -55,7 +51,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "build",
"fileReplacePosition": 1545,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -66,7 +61,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "build",
"fileReplacePosition": 2276,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -77,7 +71,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "compile",
"fileReplacePosition": 2484,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -88,7 +81,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "compile",
"fileReplacePosition": 2634,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -99,7 +91,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "compile",
"fileReplacePosition": 2779,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -110,7 +101,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "compile",
"fileReplacePosition": 2938,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -121,7 +111,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "test",
"fileReplacePosition": 3086,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -132,7 +121,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "compile",
"fileReplacePosition": 3252,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -143,7 +131,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "compile",
"fileReplacePosition": 3410,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -154,7 +141,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "optional",
"fileReplacePosition": 3555,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -164,7 +150,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depName": "org.example:relocation-artifact",
"fileReplacePosition": 3787,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -175,7 +160,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "compile",
"fileReplacePosition": 4119,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -186,7 +170,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "build",
"fileReplacePosition": 4375,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand All @@ -197,7 +180,6 @@ exports[`modules/manager/maven/extract extractDependencies extract dependencies
"depType": "build",
"fileReplacePosition": 4769,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"https://maven.atlassian.com/content/repositories/atlassian-public/",
],
},
Expand Down
28 changes: 14 additions & 14 deletions lib/modules/manager/maven/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "parent",
"fileReplacePosition": 185,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/nexus/xyz",
"http://example.com/",
"https://repo.maven.apache.org/maven2",
],
},
{
Expand All @@ -26,9 +26,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"fileReplacePosition": 470,
"groupName": "quuxVersion",
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
},
],
Expand All @@ -44,9 +44,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "parent",
"fileReplacePosition": 186,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
},
{
Expand All @@ -56,9 +56,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "compile",
"fileReplacePosition": 806,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
},
{
Expand All @@ -68,9 +68,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "compile",
"fileReplacePosition": 954,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
},
{
Expand All @@ -80,9 +80,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "build",
"fileReplacePosition": 1188,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
},
{
Expand All @@ -92,9 +92,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "build",
"fileReplacePosition": 1386,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
},
{
Expand All @@ -104,9 +104,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "compile",
"fileReplacePosition": 2131,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
"skipReason": "name-placeholder",
},
Expand All @@ -117,9 +117,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "compile",
"fileReplacePosition": 2281,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
"skipReason": "name-placeholder",
},
Expand All @@ -130,9 +130,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "compile",
"fileReplacePosition": 2574,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
},
{
Expand All @@ -142,9 +142,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "compile",
"fileReplacePosition": 2714,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
},
{
Expand All @@ -154,9 +154,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "compile",
"fileReplacePosition": 2872,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
},
{
Expand All @@ -166,9 +166,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "compile",
"fileReplacePosition": 3134,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
"skipReason": "version-placeholder",
},
Expand All @@ -179,9 +179,9 @@ exports[`modules/manager/maven/index updateDependency should include registryUrl
"depType": "build",
"fileReplacePosition": 3410,
"registryUrls": [
"https://repo.maven.apache.org/maven2",
"http://example.com/",
"http://example.com/nexus/xyz",
"https://repo.maven.apache.org/maven2",
],
},
],
Expand Down
8 changes: 8 additions & 0 deletions lib/modules/manager/maven/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const simpleContent = Fixtures.get(`simple.pom.xml`);
const mirrorSettingsContent = Fixtures.get(`mirror.settings.xml`);
const profileSettingsContent = Fixtures.get(`profile.settings.xml`);
const complexSettingsContent = Fixtures.get(`complex.settings.xml`);
const settingsUpatedContent = Fixtures.get(`settings.updated.schema.xml`);
lpriyasivakumar marked this conversation as resolved.
Show resolved Hide resolved

describe('modules/manager/maven/extract', () => {
describe('extractDependencies', () => {
Expand Down Expand Up @@ -173,5 +174,12 @@ describe('modules/manager/maven/extract', () => {
'https://repo.adobe.com/v4/nexus/content/groups/public',
]);
});

it('extract registries from a settings file that uses updated schema', () => {
const res = extractRegistries(settingsUpatedContent);
lpriyasivakumar marked this conversation as resolved.
Show resolved Hide resolved
expect(res).toStrictEqual([
'https:/proxy-repo.com/artifactory/apache-maven',
lpriyasivakumar marked this conversation as resolved.
Show resolved Hide resolved
]);
});
});
});
15 changes: 11 additions & 4 deletions lib/modules/manager/maven/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function depFromNode(
const versionNode = node.descendantWithPath('version')!;
const fileReplacePosition = versionNode.position;
const datasource = MavenDatasource.id;
const registryUrls = [MAVEN_REPO];
const registryUrls: string[] = [];
lpriyasivakumar marked this conversation as resolved.
Show resolved Hide resolved
const result: PackageDependency = {
datasource,
depName,
Expand Down Expand Up @@ -337,7 +337,6 @@ export function extractRegistries(rawContent: string): string[] {
const repositoryUrls = parseUrls(profile, 'repositories');
urls.push(...repositoryUrls);
});

lpriyasivakumar marked this conversation as resolved.
Show resolved Hide resolved
// filter out duplicates
return [...new Set(urls)];
}
Expand Down Expand Up @@ -367,7 +366,13 @@ export function parseSettings(raw: string): XmlDocument | null {
if (name !== 'settings') {
return null;
}
if (attr.xmlns === 'http://maven.apache.org/SETTINGS/1.0.0') {
if (
[
'http://maven.apache.org/SETTINGS/1.0.0',
'http://maven.apache.org/SETTINGS/1.1.0',
'http://maven.apache.org/SETTINGS/1.2.0'
].includes(attr.xmlns)
) {
return settings;
}
return null;
Expand Down Expand Up @@ -464,6 +469,8 @@ function cleanResult(packageFiles: MavenInterimPackageFile[]): PackageFile[] {
delete packageFile.parent;
packageFile.deps.forEach((dep) => {
delete dep.propSource;
//Add Registry From SuperPom
dep.registryUrls?.push(MAVEN_REPO);
lpriyasivakumar marked this conversation as resolved.
Show resolved Hide resolved
});
});
return packageFiles;
Expand Down Expand Up @@ -505,7 +512,7 @@ export async function extractAllPackageFiles(
for (const dep of pkgFile.deps) {
/* istanbul ignore else */
lpriyasivakumar marked this conversation as resolved.
Show resolved Hide resolved
if (dep.registryUrls) {
dep.registryUrls.push(...additionalRegistryUrls);
dep.registryUrls.unshift(...additionalRegistryUrls);
secustor marked this conversation as resolved.
Show resolved Hide resolved
} else {
dep.registryUrls = [...additionalRegistryUrls];
}
Expand Down
Loading
Loading