diff --git a/lib/manager/maven/__fixtures__/simple.central.pom.xml b/lib/manager/maven/__fixtures__/simple.central.pom.xml new file mode 100644 index 00000000000000..e246df80053a2e --- /dev/null +++ b/lib/manager/maven/__fixtures__/simple.central.pom.xml @@ -0,0 +1,67 @@ + + + + + + + 4.0.0 + org.example + ExamplePomFile + + Example + 0.0.1 + Minimal example + http://example.org/index.html + + + http://example.org/src.git + + + + http://example.org/ + + + + + + org.example + foo + 0.0.1 + + + + + + + org.example + quuz + 1.2.3 + test + + + + + + profile-id + + + + org.example + profile-build-artefact + 2.17 + + google_checks.xml + + + + + + + + + + nonsense + The item without url + + + diff --git a/lib/manager/maven/__snapshots__/extract.spec.ts.snap b/lib/manager/maven/__snapshots__/extract.spec.ts.snap index 39f508a8fd53d6..f81ee37875a4cc 100644 --- a/lib/manager/maven/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/maven/__snapshots__/extract.spec.ts.snap @@ -11,7 +11,6 @@ Object { "depType": "parent", "fileReplacePosition": 186, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -22,7 +21,6 @@ Object { "depType": "compile", "fileReplacePosition": 905, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -33,7 +31,6 @@ Object { "depType": "compile", "fileReplacePosition": 1093, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -44,7 +41,6 @@ Object { "depType": "build", "fileReplacePosition": 1347, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -55,7 +51,6 @@ Object { "depType": "build", "fileReplacePosition": 1545, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -66,7 +61,6 @@ Object { "depType": "build", "fileReplacePosition": 2276, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -77,7 +71,6 @@ Object { "depType": "compile", "fileReplacePosition": 2484, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -88,7 +81,6 @@ Object { "depType": "compile", "fileReplacePosition": 2634, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -99,7 +91,6 @@ Object { "depType": "compile", "fileReplacePosition": 2779, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -110,7 +101,6 @@ Object { "depType": "compile", "fileReplacePosition": 2938, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -121,7 +111,6 @@ Object { "depType": "test", "fileReplacePosition": 3086, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -132,7 +121,6 @@ Object { "depType": "compile", "fileReplacePosition": 3252, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -143,7 +131,6 @@ Object { "depType": "compile", "fileReplacePosition": 3410, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -153,7 +140,6 @@ Object { "depName": "org.example:relocation-artifact", "fileReplacePosition": 3612, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -164,7 +150,6 @@ Object { "depType": "compile", "fileReplacePosition": 3944, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -175,7 +160,6 @@ Object { "depType": "build", "fileReplacePosition": 4200, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -186,7 +170,6 @@ Object { "depType": "build", "fileReplacePosition": 4594, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -211,3 +194,37 @@ Object { "packageFile": null, } `; + +exports[`manager/maven/extract extractDependencies extract dependencies from any XML position with Central Maven 1`] = ` +Object { + "datasource": "maven", + "deps": Array [ + Object { + "currentValue": "0.0.1", + "datasource": "maven", + "depName": "org.example:foo", + "depType": "compile", + "fileReplacePosition": 637, + "registryUrls": Array [], + }, + Object { + "currentValue": "1.2.3", + "datasource": "maven", + "depName": "org.example:quuz", + "depType": "test", + "fileReplacePosition": 842, + "registryUrls": Array [], + }, + Object { + "currentValue": "2.17", + "datasource": "maven", + "depName": "org.example:profile-build-artefact", + "depType": "build", + "fileReplacePosition": 1153, + "registryUrls": Array [], + }, + ], + "mavenProps": Object {}, + "packageFile": null, +} +`; diff --git a/lib/manager/maven/__snapshots__/index.spec.ts.snap b/lib/manager/maven/__snapshots__/index.spec.ts.snap index 7cf2c033c29157..ea8a204b0865a5 100644 --- a/lib/manager/maven/__snapshots__/index.spec.ts.snap +++ b/lib/manager/maven/__snapshots__/index.spec.ts.snap @@ -12,7 +12,6 @@ Array [ "depType": "parent", "fileReplacePosition": 186, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -23,7 +22,6 @@ Array [ "depType": "compile", "fileReplacePosition": 905, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -34,7 +32,6 @@ Array [ "depType": "compile", "fileReplacePosition": 1093, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -45,7 +42,6 @@ Array [ "depType": "build", "fileReplacePosition": 1347, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -56,7 +52,6 @@ Array [ "depType": "build", "fileReplacePosition": 1545, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -67,7 +62,6 @@ Array [ "depType": "build", "fileReplacePosition": 2276, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -78,7 +72,6 @@ Array [ "depType": "compile", "fileReplacePosition": 2484, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], "skipReason": "name-placeholder", @@ -90,7 +83,6 @@ Array [ "depType": "compile", "fileReplacePosition": 2634, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], "skipReason": "name-placeholder", @@ -103,7 +95,6 @@ Array [ "fileReplacePosition": 698, "groupName": "quuxVersion", "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -115,7 +106,6 @@ Array [ "fileReplacePosition": 698, "groupName": "quuxVersion", "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -126,7 +116,6 @@ Array [ "depType": "test", "fileReplacePosition": 3086, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -137,7 +126,6 @@ Array [ "depType": "compile", "fileReplacePosition": 3252, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -148,7 +136,6 @@ Array [ "depType": "compile", "fileReplacePosition": 3410, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -158,7 +145,6 @@ Array [ "depName": "org.example:relocation-artifact", "fileReplacePosition": 3612, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -169,7 +155,6 @@ Array [ "depType": "compile", "fileReplacePosition": 3944, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], "skipReason": "version-placeholder", @@ -181,7 +166,6 @@ Array [ "depType": "build", "fileReplacePosition": 4200, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -192,7 +176,6 @@ Array [ "depType": "build", "fileReplacePosition": 4594, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "https://maven.atlassian.com/content/repositories/atlassian-public/", ], }, @@ -215,7 +198,6 @@ Array [ "depType": "parent", "fileReplacePosition": 185, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/nexus/xyz", "http://example.com/", ], @@ -229,7 +211,6 @@ Array [ "fileReplacePosition": 470, "groupName": "quuxVersion", "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], @@ -248,7 +229,6 @@ Array [ "depType": "parent", "fileReplacePosition": 186, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], @@ -260,7 +240,6 @@ Array [ "depType": "compile", "fileReplacePosition": 806, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], @@ -272,7 +251,6 @@ Array [ "depType": "compile", "fileReplacePosition": 954, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], @@ -284,7 +262,6 @@ Array [ "depType": "build", "fileReplacePosition": 1188, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], @@ -296,7 +273,6 @@ Array [ "depType": "build", "fileReplacePosition": 1386, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], @@ -308,7 +284,6 @@ Array [ "depType": "compile", "fileReplacePosition": 2131, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], @@ -321,7 +296,6 @@ Array [ "depType": "compile", "fileReplacePosition": 2281, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], @@ -334,7 +308,6 @@ Array [ "depType": "compile", "fileReplacePosition": 2574, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], @@ -346,7 +319,6 @@ Array [ "depType": "compile", "fileReplacePosition": 2714, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], @@ -358,7 +330,6 @@ Array [ "depType": "compile", "fileReplacePosition": 2872, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], @@ -370,7 +341,6 @@ Array [ "depType": "compile", "fileReplacePosition": 3134, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], @@ -383,7 +353,6 @@ Array [ "depType": "build", "fileReplacePosition": 3410, "registryUrls": Array [ - "https://repo.maven.apache.org/maven2", "http://example.com/", "http://example.com/nexus/xyz", ], diff --git a/lib/manager/maven/extract.spec.ts b/lib/manager/maven/extract.spec.ts index 2a576580489ec6..ac5461dd75fc09 100644 --- a/lib/manager/maven/extract.spec.ts +++ b/lib/manager/maven/extract.spec.ts @@ -3,6 +3,7 @@ import { extractPackage, extractRegistries } from './extract'; const minimumContent = Fixtures.get(`minimum.pom.xml`); const simpleContent = Fixtures.get(`simple.pom.xml`); +const simpleCentralContent = Fixtures.get(`simple.central.pom.xml`); const mirrorSettingsContent = Fixtures.get(`mirror.settings.xml`); const profileSettingsContent = Fixtures.get(`profile.settings.xml`); @@ -123,6 +124,32 @@ describe('manager/maven/extract', () => { packageFile: null, }); }); + it('extract dependencies from any XML position with Central Maven', () => { + const res = extractPackage(simpleCentralContent); + expect(res).toMatchSnapshot({ + deps: [ + { + depName: 'org.example:foo', + currentValue: '0.0.1', + depType: 'compile', + registryUrls: [], + }, + { + depName: 'org.example:quuz', + currentValue: '1.2.3', + depType: 'test', + registryUrls: [], + }, + { + depName: 'org.example:profile-build-artefact', + currentValue: '2.17', + depType: 'build', + registryUrls: [], + }, + ], + packageFile: null, + }); + }); it('tries minimum manifests', () => { const res = extractPackage(minimumContent); expect(res).toEqual({ diff --git a/lib/manager/maven/extract.ts b/lib/manager/maven/extract.ts index e56d97c5bb5525..de94657b4a115a 100644 --- a/lib/manager/maven/extract.ts +++ b/lib/manager/maven/extract.ts @@ -2,7 +2,6 @@ import is from '@sindresorhus/is'; import upath from 'upath'; import { XmlDocument, XmlElement } from 'xmldoc'; import * as datasourceMaven from '../../datasource/maven'; -import { MAVEN_REPO } from '../../datasource/maven/common'; import { logger } from '../../logger'; import { readLocalFile } from '../../util/fs'; import { regEx } from '../../util/regex'; @@ -57,7 +56,7 @@ function depFromNode( const versionNode = node.descendantWithPath('version'); const fileReplacePosition = versionNode.position; const datasource = datasourceMaven.id; - const registryUrls = [MAVEN_REPO]; + const registryUrls = []; const result: PackageDependency = { datasource, depName, diff --git a/lib/manager/maven/index.spec.ts b/lib/manager/maven/index.spec.ts index 1cd584c6b81eb6..214a060a5bc221 100644 --- a/lib/manager/maven/index.spec.ts +++ b/lib/manager/maven/index.spec.ts @@ -38,7 +38,6 @@ describe('manager/maven/index', () => { 'simple.pom.xml', ]); const urls = [ - 'https://repo.maven.apache.org/maven2', 'https://maven.atlassian.com/content/repositories/atlassian-public/', 'https://artifactory.company.com/artifactory/my-maven-repo', ]; @@ -180,7 +179,6 @@ describe('manager/maven/index', () => { 'child.pom.xml', ]); const urls = new Set([ - 'https://repo.maven.apache.org/maven2', 'http://example.com/', 'http://example.com/nexus/xyz', ]);