Assert.isNotNull(groupId, Messages.MavenPluginUtils_GroupId_Cant_Be_Null);
Assert.isNotNull(artifactId, Messages.MavenPluginUtils_ArtifactId_Cant_Be_Null);
String version = referenceVersion;
String partialKey = artifactId + " : " + groupId; //$NON-NLS-1$
try {
IIndex index = MavenPlugin.getIndexManager().getAllIndexes();
SearchExpression a = new SourcedSearchExpression(artifactId);
//For some reason, an exact search using :
//ISearchEngine searchEngine = M2EUIPluginActivator.getDefault().getSearchEngine(null)
//searchEngine.findVersions(groupId, artifactId, searchExpression, packaging)
//
//doesn't yield the expected results (the latest versions are not returned), so we rely on a fuzzier search
//and refine the results.
Map<String, IndexedArtifact> values = index.search(a, IIndex.SEARCH_PLUGIN);
if(!values.isEmpty()) {
SortedSet<ComparableVersion> versions = new TreeSet<ComparableVersion>();
ComparableVersion referenceComparableVersion = referenceVersion == null ? null : new ComparableVersion(
referenceVersion);