Add support for local maven repository
Describe the bug
refreshVersions is not able to find the latest versions of artifact in local maven repository.
To Reproduce
- Publish any project/library that uses
maven-publishplugin to local maven repository, e.g. via./gradlew publishToMavenLocal - Use it as a dependency in another project with refreshVersions, specifying the local repository via
repositories { mavenLocal() }block. - 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'.
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.