AlessioDP / libby

A runtime dependency management library for plugins running in Java-based Minecraft server platforms.
MIT License
76 stars 20 forks source link

Add support for snapshot libraries #20

Closed frengor closed 11 months ago

frengor commented 11 months ago

Adds support for snapshot libraries (i.e. libraries with the version ending in -SNAPSHOT).
The approach taken by this PR modifies resolveLibrary to fetch the maven-metadata.xml file from every repository (when the passed library is a snapshot) to determine the last-published artifact download url.

An issue with this approach is that if more than one repository is declared, then unnecessary downloads of the metadata files may happen, since they are all fetched before trying to download the artifacts. It would be better to try to download each artifact right after fetching each metadata file and to stop after the first successful download. This however requires inlining the resolveLibrary method into downloadLibrary(Library). I preferred not doing so in this PR and leaving it as a future improvement.
(Another way could be to make resolveLibrary return a lazy iterator which fetches the metadata file only when calling next(), essentially leaving downloadLibrary(Library) mostly untouched, but that'd be a breaking change since resolveLibrary is public)

Fixes #15