VersionRangeResult getVersions ( DependencyQuery query ) { Coordinate dep = query . getCoordinate ( ) ; try { String version = dep . getVersion ( ) ; if ( version == null || version . isEmpty ( ) ) { dep = CoordinateBuilder . create ( dep ) . setVersion ( "[,)" ) ; } else if ( ! version . matches ( "(\\(|\\[).*?(\\)|\\])" ) ) { dep = CoordinateBuilder . create ( dep ) . setVersion ( "[" + version + "]" ) ; } RepositorySystem maven = container . getRepositorySystem ( ) ; Settings settings = container . getSettings ( ) ; DefaultRepositorySystemSession session = container . setupRepoSession ( maven , settings ) ; Artifact artifact = MavenConvertUtils . coordinateToMavenArtifact ( dep ) ; List < RemoteRepository > remoteRepos = MavenConvertUtils . convertToMavenRepos ( query . getDependencyRepositories ( ) , settings ) ; remoteRepos . addAll ( MavenRepositories . getRemoteRepositories ( container , settings ) ) ; VersionRangeRequest rangeRequest = new VersionRangeRequest ( artifact , remoteRepos , null ) ; VersionRangeResult rangeResult = maven . resolveVersionRange ( session , rangeRequest ) ; return rangeResult ; } catch ( Exception e ) { throw new RuntimeException ( "Failed to look up versions for [" + dep + "]" , e ) ; } }
Returns the versions of a specific artifact