Splitties / refreshVersions

Life is too short to google for dependencies and versions
https://splitties.github.io/refreshVersions/
MIT License
1.65k stars 107 forks source link

Add support for local maven repository #248

Open yokeru opened 4 years ago

yokeru commented 4 years ago

Describe the bug

refreshVersions is not able to find the latest versions of artifact in local maven repository.

To Reproduce

  1. Publish any project/library that uses maven-publish plugin to local maven repository, e.g. via ./gradlew publishToMavenLocal
  2. Use it as a dependency in another project with refreshVersions, specifying the local repository via repositories { mavenLocal() } block.
  3. refreshVersions fails to find any published versions of this artifact in local maven repository.

Expected behavior

refreshVersions should find the latest version of the artifact.

Additional context

This happens due to the fact that publishing to local maven repository creates maven-metadata-local.xml and refreshVersions only checks for maven-metadata.xml (also after renaming of the metadata file, the versions could be found).

Proposed solution

It might be a good idea to use maven-metadata-local.xml as a fallback, if the maven-metadata.xml file is not found, or even better to use it as a primary location, if the repository is a local maven repository (recognizing it e.g. via repoUrl containing a file scheme and path (usually) containing .m2 substring/pattern).

Note: The generic metadata file format for non-remote repositories is maven-metadata-<repo-id>.xml for a repository with repo-id identifier, but this defaults almost always to 'local'.

LouisCAD commented 4 years ago

Thanks for the report with the precise information! That name difference explains my questioning when I didn't see the local version but it worked when adding it manually.