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

feat(maven): settings.xml registry extraction #13592

Merged
merged 16 commits into from
Jan 20, 2022

Conversation

Chumper
Copy link
Contributor

@Chumper Chumper commented Jan 17, 2022

Changes:

Introduces registry url extraction for maven for settings.xml
When a settings.xml resides in the repository under .mvn/settings.xml, .m2/settings.xml or settings.xml then we try to parse the file and extract registry urls from the <mirrors> and <repositories> child elements.

This is then added to the registry urls Renovate uses to look up the maven packages.

Advantage: This frees the repository owner from adding all maven registries manually to the renovate.json.
Instead they can rely on Renovate extracting them from the settings.xml if available.

Todo:

Context:

Closes #13448

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@Chumper Chumper marked this pull request as draft January 17, 2022 14:21
@Chumper
Copy link
Contributor Author

Chumper commented Jan 17, 2022

DEBUG: Matched 2 file(s) for manager maven: .mvn/settings.xml, pom.xml (repository=renovate-support/maven-registry-extract)
 INFO: found registryUrls in settings.xml (repository=renovate-support/maven-registry-extract, packageFile=.mvn/settings.xml)
       "registries": ["http://uk.maven.org/maven2"]
DEBUG: Found maven package files (repository=renovate-support/maven-registry-extract)
DEBUG: Found 1 package file(s) (repository=renovate-support/maven-registry-extract)
 INFO: Dependency extraction complete (repository=renovate-support/maven-registry-extract)
       "baseBranch": "main",
       "stats": {
         "managers": {"maven": {"fileCount": 1, "depCount": 1}},
         "total": {"fileCount": 1, "depCount": 1}
       }
DEBUG: Looking up junit:junit in repository https://repo.maven.apache.org/maven2/ (repository=renovate-support/maven-registry-extract)
DEBUG: Found 32 new releases for junit:junit in repository https://repo.maven.apache.org/maven2/ (repository=renovate-support/maven-registry-extract)
DEBUG: Looking up junit:junit in repository http://uk.maven.org/maven2/ (repository=renovate-support/maven-registry-extract)
DEBUG: Content is not found for Maven url (repository=renovate-support/maven-registry-extract)
       "url": "http://uk.maven.org/maven2/junit/junit/maven-metadata.xml",
       "statusCode": undefined

@Chumper Chumper marked this pull request as ready for review January 17, 2022 21:10
lib/manager/maven/__fixtures__/settings.xml Outdated Show resolved Hide resolved
lib/manager/maven/__snapshots__/extract.spec.ts.snap Outdated Show resolved Hide resolved
lib/manager/maven/extract.spec.ts Outdated Show resolved Hide resolved
lib/manager/maven/extract.ts Outdated Show resolved Hide resolved
lib/manager/maven/extract.ts Outdated Show resolved Hide resolved
lib/manager/maven/index.spec.ts Outdated Show resolved Hide resolved
lib/manager/maven/index.ts Outdated Show resolved Hide resolved
@viceice
Copy link
Member

viceice commented Jan 17, 2022

Needs test / coverage fixes

docs/usage/java.md Outdated Show resolved Hide resolved
lib/manager/maven/extract.ts Show resolved Hide resolved
lib/manager/maven/extract.ts Outdated Show resolved Hide resolved
lib/manager/maven/index.ts Outdated Show resolved Hide resolved
@Chumper
Copy link
Contributor Author

Chumper commented Jan 18, 2022

Needs test / coverage fixes

Any suggestion on how to test the line?
https://github.com/renovatebot/renovate/pull/13592/files#diff-3990b19c14e7ff575fa391385d04840ab70ff28c763d17c8b50d92ed949d97bdR400

The extractPackage method always sets the registryUrls so the else case can only be reached with extensive mocking as it seems to me.

Easy way out would be to annotate it.

Edit: I have added the annotation for now, let me know if you want this changed.

rarkins
rarkins previously approved these changes Jan 18, 2022
@rarkins rarkins changed the title feat: support maven registry extraction feat(maven): settings.xml registry extraction Jan 18, 2022
HonkingGoose
HonkingGoose previously approved these changes Jan 19, 2022
Copy link
Collaborator

@HonkingGoose HonkingGoose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs look good to me. 😄

@rarkins
Copy link
Collaborator

rarkins commented Jan 19, 2022

@viceice also ready for your final approval/merge

Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two all questions left

lib/manager/maven/extract.ts Outdated Show resolved Hide resolved
lib/manager/maven/extract.ts Show resolved Hide resolved
@Chumper Chumper dismissed stale reviews from HonkingGoose and rarkins via 56bab62 January 19, 2022 09:48
Copy link
Member

@viceice viceice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise LGTM

lib/manager/maven/extract.ts Outdated Show resolved Hide resolved
@rarkins rarkins requested a review from viceice January 19, 2022 12:22
@viceice viceice enabled auto-merge (squash) January 19, 2022 14:38
@viceice viceice merged commit f88e498 into renovatebot:main Jan 20, 2022
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 31.37.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect maven repositories automatically
5 participants