mavenmaven-pluginmaven-dependency

List all available versions of a dependency


I would like to list all available versions of a given dependency.

The reason: When a vulnerability is found, the dependency gets blocked by a mechanism we built upon JFrog Xray. I want to generate a list of dependencies which are still unblocked.

I know that I can ask the REST API of Artifactory, but this will only list versions which are already downloaded (cached), not every version that is available (e.g. on MavenCentral).

From what I understand the Versions Maven Plugin has such a mechanism included and uses it for their goals (like versions:use-latest-releases). So it should be possible and I would like to know how.


Solution

  • In Maven plugin you can use Resolver API

    RepositorySystem.resolveVersionRange(...)

    Example: FindAvailableVersions

    Example of Maven plugin: ResolveArtifactMojo