diff --git a/lib/datasource/maven/__fixtures__/child-all-info/meta.xml b/lib/datasource/maven/__fixtures__/child-all-info/meta.xml new file mode 100644 index 0000000000000000000000000000000000000000..8927f14aa205f0f58464d41af6483b2d62536472 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-all-info/meta.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?><metadata> + <groupId>org.example</groupId> + <artifactId>child-all-info</artifactId> + <version>2.0.0</version> + <versioning> + <versions> + <version>2.0.0</version> + </versions> + <lastUpdated>20130301200000</lastUpdated> + </versioning> +</metadata> diff --git a/lib/datasource/maven/__fixtures__/child-all-info/pom.xml b/lib/datasource/maven/__fixtures__/child-all-info/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..38a060ce1769f1d9ac0a7824d772ef4a82792cde --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-all-info/pom.xml @@ -0,0 +1,12 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.example</groupId> + <artifactId>parent</artifactId> + <version>1.0.0</version> + </parent> + <scm> + <!-- example taken from https://maven.apache.org/scm/git.html --> + <url>scm:git:http://www.github.com/child-scm/child</url> + </scm> + <url>https://child-home.example.com</url> +</project> diff --git a/lib/datasource/maven/__fixtures__/child-empty/meta.xml b/lib/datasource/maven/__fixtures__/child-empty/meta.xml new file mode 100644 index 0000000000000000000000000000000000000000..efcaf6091919d537e00bf44bd84d268808c419d4 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-empty/meta.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?><metadata> + <groupId>org.example</groupId> + <artifactId>child-no-info</artifactId> + <version>2.0.0</version> + <versioning> + <versions> + <version>2.0.0</version> + </versions> + <lastUpdated>20130301200000</lastUpdated> + </versioning> +</metadata> diff --git a/lib/datasource/maven/__fixtures__/child-empty/pom.xml b/lib/datasource/maven/__fixtures__/child-empty/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..b3f546cac09a4e0b57347db3f4799bd748933920 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-empty/pom.xml @@ -0,0 +1,4 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + </parent> +</project> diff --git a/lib/datasource/maven/__fixtures__/child-no-info/meta.xml b/lib/datasource/maven/__fixtures__/child-no-info/meta.xml new file mode 100644 index 0000000000000000000000000000000000000000..efcaf6091919d537e00bf44bd84d268808c419d4 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-no-info/meta.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?><metadata> + <groupId>org.example</groupId> + <artifactId>child-no-info</artifactId> + <version>2.0.0</version> + <versioning> + <versions> + <version>2.0.0</version> + </versions> + <lastUpdated>20130301200000</lastUpdated> + </versioning> +</metadata> diff --git a/lib/datasource/maven/__fixtures__/child-no-info/pom.xml b/lib/datasource/maven/__fixtures__/child-no-info/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..1ec845afb4486561cdb8317b78174f9f036968ea --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-no-info/pom.xml @@ -0,0 +1,7 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.example</groupId> + <artifactId>parent</artifactId> + <version>1.0.0</version> + </parent> +</project> diff --git a/lib/datasource/maven/__fixtures__/child-parent-cycle/child.meta.xml b/lib/datasource/maven/__fixtures__/child-parent-cycle/child.meta.xml new file mode 100644 index 0000000000000000000000000000000000000000..07848472aec2ec218df716ceb5b0b98af2efbaec --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-parent-cycle/child.meta.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?><metadata> + <groupId>org.example</groupId> + <artifactId>package</artifactId> + <version>2.0.0</version> + <versioning> + <versions> + <version>2.0.0</version> + </versions> + <lastUpdated>20130301200000</lastUpdated> + </versioning> +</metadata> diff --git a/lib/datasource/maven/__fixtures__/child-parent-cycle/child.pom.xml b/lib/datasource/maven/__fixtures__/child-parent-cycle/child.pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e3c7456bae805a9277918c60eea44c453fd7675 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-parent-cycle/child.pom.xml @@ -0,0 +1,17 @@ + +<!-- + License +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.example</groupId> + <artifactId>parent</artifactId> + <version>2.0.0</version> + </parent> + <groupId>org.example</groupId> + <artifactId>child</artifactId> + <name>Generic Package</name> + <description>Generic Maven Package</description> +</project> diff --git a/lib/datasource/maven/__fixtures__/child-parent-cycle/parent.pom.xml b/lib/datasource/maven/__fixtures__/child-parent-cycle/parent.pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..2760a1dd818d774b01e89ec71c1ae4372c23b104 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-parent-cycle/parent.pom.xml @@ -0,0 +1,8 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.example</groupId> + <artifactId>child</artifactId> + <version>2.0.0</version> + </parent> + <url>https://parent-home.example.com</url> +</project> diff --git a/lib/datasource/maven/__fixtures__/child-scm-gitatcolon/meta.xml b/lib/datasource/maven/__fixtures__/child-scm-gitatcolon/meta.xml new file mode 100644 index 0000000000000000000000000000000000000000..f42fe8589746f09dbd8512f5eac689eccf869920 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-scm-gitatcolon/meta.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?><metadata> + <groupId>org.example</groupId> + <artifactId>child-scm-gitatcolon</artifactId> + <version>2.0.0</version> + <versioning> + <versions> + <version>2.0.0</version> + </versions> + <lastUpdated>20130301200000</lastUpdated> + </versioning> +</metadata> diff --git a/lib/datasource/maven/__fixtures__/child-scm-gitatcolon/pom.xml b/lib/datasource/maven/__fixtures__/child-scm-gitatcolon/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..7c3157b5c445bb7657ae3efa772b6dc4b79f35c5 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-scm-gitatcolon/pom.xml @@ -0,0 +1,6 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <scm> + <!-- as seen in https://repo.maven.apache.org/maven2/org/freemarker/freemarker/2.3.20/freemarker-2.3.20.pom --> + <url>git@github.com:child-scm/child</url> + </scm> +</project> diff --git a/lib/datasource/maven/__fixtures__/child-scm-gitatslash/meta.xml b/lib/datasource/maven/__fixtures__/child-scm-gitatslash/meta.xml new file mode 100644 index 0000000000000000000000000000000000000000..07a2b3af129a9edfa18d372d5410195231623f8b --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-scm-gitatslash/meta.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?><metadata> + <groupId>org.example</groupId> + <artifactId>child-scm-gitatslash</artifactId> + <version>2.0.0</version> + <versioning> + <versions> + <version>2.0.0</version> + </versions> + <lastUpdated>20130301200000</lastUpdated> + </versioning> +</metadata> diff --git a/lib/datasource/maven/__fixtures__/child-scm-gitatslash/pom.xml b/lib/datasource/maven/__fixtures__/child-scm-gitatslash/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..2ad57eaa1ffde2304086447e9650533978658640 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-scm-gitatslash/pom.xml @@ -0,0 +1,6 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <scm> + <!-- as seen in https://repo.maven.apache.org/maven2/ro/nextreports/nextreports-engine/9.2/nextreports-engine-9.2.pom --> + <url>git@github.com/child-scm/child</url> + </scm> +</project> diff --git a/lib/datasource/maven/__fixtures__/child-scm-gitprotocol/meta.xml b/lib/datasource/maven/__fixtures__/child-scm-gitprotocol/meta.xml new file mode 100644 index 0000000000000000000000000000000000000000..1741d3965409af818ba33ba09a87653679260aa6 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-scm-gitprotocol/meta.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?><metadata> + <groupId>org.example</groupId> + <artifactId>child-scm-gitprotocol</artifactId> + <version>2.0.0</version> + <versioning> + <versions> + <version>2.0.0</version> + </versions> + <lastUpdated>20130301200000</lastUpdated> + </versioning> +</metadata> diff --git a/lib/datasource/maven/__fixtures__/child-scm-gitprotocol/pom.xml b/lib/datasource/maven/__fixtures__/child-scm-gitprotocol/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..da09dda8a96e767e44a5e448a737c6007f921e25 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-scm-gitprotocol/pom.xml @@ -0,0 +1,6 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <scm> + <!-- as seen in https://repo.maven.apache.org/maven2/org/xhtmlrenderer/flying-saucer-parent/9.1.9/flying-saucer-parent-9.1.9.pom --> + <url>git://github.com/child-scm/child</url> + </scm> +</project> diff --git a/lib/datasource/maven/__fixtures__/child-scm/meta.xml b/lib/datasource/maven/__fixtures__/child-scm/meta.xml new file mode 100644 index 0000000000000000000000000000000000000000..c0f390f2aee0f13e906a47e0f871a93a77060104 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-scm/meta.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?><metadata> + <groupId>org.example</groupId> + <artifactId>child-scm</artifactId> + <version>2.0.0</version> + <versioning> + <versions> + <version>2.0.0</version> + </versions> + <lastUpdated>20130301200000</lastUpdated> + </versioning> +</metadata> diff --git a/lib/datasource/maven/__fixtures__/child-scm/pom.xml b/lib/datasource/maven/__fixtures__/child-scm/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..a6cf6fea3a0ff7b93eed09a3dba7ba9d29ac3f65 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-scm/pom.xml @@ -0,0 +1,11 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.example</groupId> + <artifactId>parent</artifactId> + <version>1.0.0</version> + </parent> + <scm> + <!-- example taken from https://maven.apache.org/scm/git.html --> + <url>scm:git:https://www.github.com/child-scm/child</url> + </scm> +</project> diff --git a/lib/datasource/maven/__fixtures__/child-url/meta.xml b/lib/datasource/maven/__fixtures__/child-url/meta.xml new file mode 100644 index 0000000000000000000000000000000000000000..3fd1398f527e5f4df9068e142fd80e7973f5cb2e --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-url/meta.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?><metadata> + <groupId>org.example</groupId> + <artifactId>child-url</artifactId> + <version>2.0.0</version> + <versioning> + <versions> + <version>2.0.0</version> + </versions> + <lastUpdated>20130301200000</lastUpdated> + </versioning> +</metadata> diff --git a/lib/datasource/maven/__fixtures__/child-url/pom.xml b/lib/datasource/maven/__fixtures__/child-url/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..f153707958a38a8546f24581d76fa59a8416fbb6 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/child-url/pom.xml @@ -0,0 +1,8 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.example</groupId> + <artifactId>parent</artifactId> + <version>1.0.0</version> + </parent> + <url>https://child-home.example.com</url> +</project> diff --git a/lib/datasource/maven/__fixtures__/parent-scm-homepage/meta.xml b/lib/datasource/maven/__fixtures__/parent-scm-homepage/meta.xml new file mode 100644 index 0000000000000000000000000000000000000000..2a44ff77578734ca623b9ef78e7d81f38bf719d2 --- /dev/null +++ b/lib/datasource/maven/__fixtures__/parent-scm-homepage/meta.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?><metadata> + <groupId>org.example</groupId> + <artifactId>parent</artifactId> + <version>1.0.0</version> + <versioning> + <versions> + <version>1.0.0</version> + </versions> + <lastUpdated>20130301200000</lastUpdated> + </versioning> +</metadata> diff --git a/lib/datasource/maven/__fixtures__/parent-scm-homepage/pom.xml b/lib/datasource/maven/__fixtures__/parent-scm-homepage/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..18357e50fb13514c589dcd3332d93e10a4a82f4a --- /dev/null +++ b/lib/datasource/maven/__fixtures__/parent-scm-homepage/pom.xml @@ -0,0 +1,7 @@ +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <scm> + <!-- example taken from https://maven.apache.org/scm/git.html --> + <url>scm:git:git://www.github.com/parent-scm/parent</url> + </scm> + <url>https://parent-home.example.com</url> +</project> diff --git a/lib/datasource/maven/__snapshots__/index.spec.ts.snap b/lib/datasource/maven/__snapshots__/index.spec.ts.snap index aba4930ded3c4945c08b5ad7edb68888de56d1de..f401e28a77d53d1f5dae6c0ff21c0dfd602e5a6b 100644 --- a/lib/datasource/maven/__snapshots__/index.spec.ts.snap +++ b/lib/datasource/maven/__snapshots__/index.spec.ts.snap @@ -204,6 +204,366 @@ Array [ ] `; +exports[`datasource/maven/index fetching parent info should be able to detect git://@github.com/child-scm as valid sourceUrl 1`] = ` +Array [ + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, +] +`; + +exports[`datasource/maven/index fetching parent info should be able to detect git@github.com/child-scm as valid sourceUrl 1`] = ` +Array [ + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, +] +`; + +exports[`datasource/maven/index fetching parent info should be able to detect git@github.com:child-scm as valid sourceUrl 1`] = ` +Array [ + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, +] +`; + +exports[`datasource/maven/index fetching parent info should deal with circular hierarchy 1`] = ` +Array [ + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/child/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/child/2.0.0/child-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/child/2.0.0/child-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/parent/2.0.0/parent-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/child/2.0.0/child-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/parent/2.0.0/parent-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/child/2.0.0/child-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/parent/2.0.0/parent-2.0.0.pom", + }, +] +`; + +exports[`datasource/maven/index fetching parent info should deal with missing parent fields 1`] = ` +Array [ + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, +] +`; + +exports[`datasource/maven/index fetching parent info should get homepage and source from own pom 1`] = ` +Array [ + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, +] +`; + +exports[`datasource/maven/index fetching parent info should get homepage from own pom and source from parent 1`] = ` +Array [ + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/parent/1.0.0/parent-1.0.0.pom", + }, +] +`; + +exports[`datasource/maven/index fetching parent info should get source and homepage from parent 1`] = ` +Array [ + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/parent/1.0.0/parent-1.0.0.pom", + }, +] +`; + +exports[`datasource/maven/index fetching parent info should get source from own pom and homepage from parent 1`] = ` +Array [ + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/maven-metadata.xml", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "HEAD", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/package/2.0.0/package-2.0.0.pom", + }, + Object { + "headers": Object { + "accept-encoding": "gzip, deflate, br", + "host": "repo.maven.apache.org", + "user-agent": "https://github.com/renovatebot/renovate", + }, + "method": "GET", + "url": "https://repo.maven.apache.org/maven2/org/example/parent/1.0.0/parent-1.0.0.pom", + }, +] +`; + exports[`datasource/maven/index handles optional slash at the end of registry url 1`] = ` Array [ Object { diff --git a/lib/datasource/maven/index.spec.ts b/lib/datasource/maven/index.spec.ts index 4c9c719fcbcee48fef7eaac38fdae836ebed1f16..e610a5cc68d35d3ca6ddafe9befe2b272a869f66 100644 --- a/lib/datasource/maven/index.spec.ts +++ b/lib/datasource/maven/index.spec.ts @@ -305,4 +305,191 @@ describe(getName(), () => { expect(res).toMatchSnapshot(); expect(httpMock.getTrace()).toMatchSnapshot(); }); + + describe('fetching parent info', () => { + const parentPackage = { + dep: 'org.example:parent', + meta: null, + pom: loadFixture('parent-scm-homepage/pom.xml'), + latest: '1.0.0', + jars: null, + }; + + it('should get source and homepage from parent', async () => { + mockGenericPackage({ + meta: loadFixture('child-no-info/meta.xml'), + pom: loadFixture('child-no-info/pom.xml'), + latest: '2.0.0', + jars: { '2.0.0': 200 }, + }); + mockGenericPackage(parentPackage); + + const res = await get(); + + expect(res).toMatchObject({ + sourceUrl: 'https://github.com/parent-scm/parent', + homepage: 'https://parent-home.example.com', + }); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); + + it('should deal with missing parent fields', async () => { + mockGenericPackage({ + meta: loadFixture('child-empty/meta.xml'), + pom: loadFixture('child-empty/pom.xml'), + latest: '2.0.0', + jars: { '2.0.0': 200 }, + }); + + const res = await get(); + + expect(res).toMatchObject({ + display: 'org.example:package', + group: 'org.example', + name: 'package', + }); + expect(res).not.toHaveProperty('homepage'); + expect(res).not.toHaveProperty('sourceUrl'); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); + + it('should deal with circular hierarchy', async () => { + const parentPom = loadFixture('child-parent-cycle/parent.pom.xml'); + const parentPomMock = { + dep: 'org.example:parent', + meta: null, + pom: parentPom, + latest: '2.0.0', + jars: null, + }; + + const childMeta = loadFixture('child-parent-cycle/child.meta.xml'); + const childPom = loadFixture('child-parent-cycle/child.pom.xml'); + const childPomMock = { + dep: 'org.example:child', + meta: null, + pom: childPom, + latest: '2.0.0', + jars: null, + }; + + mockGenericPackage({ + ...childPomMock, + meta: childMeta, + jars: { '2.0.0': 200 }, + }); + mockGenericPackage(parentPomMock); + mockGenericPackage(childPomMock); + mockGenericPackage(parentPomMock); + mockGenericPackage(childPomMock); + mockGenericPackage(parentPomMock); + + const res = await get('org.example:child'); + + expect(res).toMatchObject({ + homepage: 'https://parent-home.example.com', + }); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); + + it('should get source from own pom and homepage from parent', async () => { + mockGenericPackage({ + meta: loadFixture('child-scm/meta.xml'), + pom: loadFixture('child-scm/pom.xml'), + latest: '2.0.0', + jars: { '2.0.0': 200 }, + }); + mockGenericPackage(parentPackage); + + const res = await get(); + + expect(res).toMatchObject({ + sourceUrl: 'https://github.com/child-scm/child', + homepage: 'https://parent-home.example.com', + }); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); + + it('should get homepage from own pom and source from parent', async () => { + mockGenericPackage({ + meta: loadFixture('child-url/meta.xml'), + pom: loadFixture('child-url/pom.xml'), + latest: '2.0.0', + jars: { '2.0.0': 200 }, + }); + mockGenericPackage(parentPackage); + + const res = await get(); + + expect(res).toMatchObject({ + sourceUrl: 'https://github.com/parent-scm/parent', + homepage: 'https://child-home.example.com', + }); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); + + it('should get homepage and source from own pom', async () => { + mockGenericPackage({ + meta: loadFixture('child-all-info/meta.xml'), + pom: loadFixture('child-all-info/pom.xml'), + latest: '2.0.0', + jars: { '2.0.0': 200 }, + }); + + const res = await get(); + + expect(res).toMatchObject({ + sourceUrl: 'https://github.com/child-scm/child', + homepage: 'https://child-home.example.com', + }); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); + + it('should be able to detect git@github.com:child-scm as valid sourceUrl', async () => { + mockGenericPackage({ + meta: loadFixture('child-scm-gitatcolon/meta.xml'), + pom: loadFixture('child-scm-gitatcolon/pom.xml'), + latest: '2.0.0', + jars: { '2.0.0': 200 }, + }); + + const res = await get(); + + expect(res).toMatchObject({ + sourceUrl: 'https://github.com/child-scm/child', + }); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); + + it('should be able to detect git@github.com/child-scm as valid sourceUrl', async () => { + mockGenericPackage({ + meta: loadFixture('child-scm-gitatslash/meta.xml'), + pom: loadFixture('child-scm-gitatslash/pom.xml'), + latest: '2.0.0', + jars: { '2.0.0': 200 }, + }); + + const res = await get(); + + expect(res).toMatchObject({ + sourceUrl: 'https://github.com/child-scm/child', + }); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); + it('should be able to detect git://@github.com/child-scm as valid sourceUrl', async () => { + mockGenericPackage({ + meta: loadFixture('child-scm-gitprotocol/meta.xml'), + pom: loadFixture('child-scm-gitprotocol/pom.xml'), + latest: '2.0.0', + jars: { '2.0.0': 200 }, + }); + + const res = await get(); + + expect(res).toMatchObject({ + sourceUrl: 'https://github.com/child-scm/child', + }); + expect(httpMock.getTrace()).toMatchSnapshot(); + }); + }); }); diff --git a/lib/datasource/maven/util.ts b/lib/datasource/maven/util.ts index ed7f7355ce467819f1c34ddb6cabfa127794e0ca..18316d73df55b2120623ab8ab5b006728691fbe9 100644 --- a/lib/datasource/maven/util.ts +++ b/lib/datasource/maven/util.ts @@ -163,10 +163,22 @@ export async function downloadMavenXml( return { authorization, xml: new XmlDocument(rawContent) }; } +export function getDependencyParts(lookupName: string): MavenDependency { + const [group, name] = lookupName.split(':'); + const dependencyUrl = `${group.replace(/\./g, '/')}/${name}`; + return { + display: lookupName, + group, + name, + dependencyUrl, + }; +} + export async function getDependencyInfo( dependency: MavenDependency, repoUrl: string, - version: string + version: string, + recursionLimit = 5 ): Promise<Partial<ReleaseResult>> { const result: Partial<ReleaseResult> = {}; const path = `${version}/${dependency.name}-${version}.pom`; @@ -185,19 +197,46 @@ export async function getDependencyInfo( const sourceUrl = pomContent.valueWithPath('scm.url'); if (sourceUrl && !containsPlaceholder(sourceUrl)) { - result.sourceUrl = sourceUrl.replace(/^scm:/, ''); + result.sourceUrl = sourceUrl + .replace(/^scm:/, '') + .replace(/^git:/, '') + .replace(/^git@github.com:/, 'https://github.com/') + .replace(/^git@github.com\//, 'https://github.com/') + .replace(/\.git$/, ''); + + if (result.sourceUrl.startsWith('//')) { + // most likely the result of us stripping scm:, git: etc + // going with prepending https: here which should result in potential information retrival + result.sourceUrl = `https:${result.sourceUrl}`; + } } - return result; -} + const parent = pomContent.childNamed('parent'); + if (recursionLimit > 0 && parent && (!result.sourceUrl || !result.homepage)) { + // if we found a parent and are missing some information + // trying to get the scm/homepage information from it + const [parentGroupId, parentArtifactId, parentVersion] = [ + 'groupId', + 'artifactId', + 'version', + ].map((k) => parent.valueWithPath(k)?.replace(/\s+/g, '')); + if (parentGroupId && parentArtifactId && parentVersion) { + const parentDisplayId = `${parentGroupId}:${parentArtifactId}`; + const parentDependency = getDependencyParts(parentDisplayId); + const parentInformation = await getDependencyInfo( + parentDependency, + repoUrl, + parentVersion, + recursionLimit - 1 + ); + if (!result.sourceUrl && parentInformation.sourceUrl) { + result.sourceUrl = parentInformation.sourceUrl; + } + if (!result.homepage && parentInformation.homepage) { + result.homepage = parentInformation.homepage; + } + } + } -export function getDependencyParts(lookupName: string): MavenDependency { - const [group, name] = lookupName.split(':'); - const dependencyUrl = `${group.replace(/\./g, '/')}/${name}`; - return { - display: lookupName, - group, - name, - dependencyUrl, - }; + return result; }