Search in sources :

Example 1 with LocalArtifactVersionRangeResolver

use of org.jboss.galleon.universe.maven.repo.LocalArtifactVersionRangeResolver in project galleon by wildfly.

the class AbstractMavenArtifactRepositoryManager method doGetHighestVersion.

private String doGetHighestVersion(MavenArtifact mavenArtifact, String lowestQualifier, boolean locallyAvailable, Pattern includeVersion, Pattern excludeVersion) throws MavenUniverseException {
    if (locallyAvailable) {
        if (localRangeResolver == null) {
            localRangeResolver = new LocalArtifactVersionRangeResolver(getSession().getLocalRepository().getBasedir().toPath());
        }
        return localRangeResolver.getLatestVersion(mavenArtifact, lowestQualifier, includeVersion, excludeVersion);
    }
    final VersionRangeResult rangeResult = getVersionRange(new DefaultArtifact(mavenArtifact.getGroupId(), mavenArtifact.getArtifactId(), mavenArtifact.getExtension(), mavenArtifact.getVersionRange()));
    final MavenArtifactVersion latest = rangeResult == null ? null : MavenArtifactVersion.getLatest(rangeResult.getVersions(), lowestQualifier, includeVersion, excludeVersion);
    if (latest == null) {
        throw new MavenLatestVersionNotAvailableException(MavenErrors.failedToResolveLatestVersion(mavenArtifact.getCoordsAsString()));
    }
    return latest.toString();
}
Also used : VersionRangeResult(org.eclipse.aether.resolution.VersionRangeResult) LocalArtifactVersionRangeResolver(org.jboss.galleon.universe.maven.repo.LocalArtifactVersionRangeResolver) MavenArtifactVersion(org.jboss.galleon.universe.maven.repo.MavenArtifactVersion) MavenLatestVersionNotAvailableException(org.jboss.galleon.universe.maven.MavenLatestVersionNotAvailableException) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Aggregations

DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)1 VersionRangeResult (org.eclipse.aether.resolution.VersionRangeResult)1 MavenLatestVersionNotAvailableException (org.jboss.galleon.universe.maven.MavenLatestVersionNotAvailableException)1 LocalArtifactVersionRangeResolver (org.jboss.galleon.universe.maven.repo.LocalArtifactVersionRangeResolver)1 MavenArtifactVersion (org.jboss.galleon.universe.maven.repo.MavenArtifactVersion)1