use of org.sonatype.nexus.index.context.IndexingContext in project intellij-community by JetBrains.
the class Maven2ServerIndexerImpl method createIndex.
public int createIndex(@NotNull String indexId, @NotNull String repositoryId, @Nullable File file, @Nullable String url, @NotNull File indexDir) throws MavenServerIndexerException {
try {
IndexingContext context = myIndexer.addIndexingContextForced(indexId, repositoryId, file, indexDir, url, // repo update url
null, NexusIndexer.FULL_INDEX);
int id = System.identityHashCode(context);
myIndices.put(id, context);
return id;
} catch (Exception e) {
throw new MavenServerIndexerException(wrapException(e));
}
}
use of org.sonatype.nexus.index.context.IndexingContext in project intellij-community by JetBrains.
the class NexusIndexerTest method _testUpdatingLocal.
public void _testUpdatingLocal() throws Exception {
IndexingContext c = addContext("local1", myIndexDir, new File(myRepositoryHelper.getTestDataPath("local1")), null);
myIndexer.scan(c, new NullScanningListener());
assertSearchWorks();
}
use of org.sonatype.nexus.index.context.IndexingContext in project intellij-community by JetBrains.
the class NexusIndexerTest method tearDown.
@Override
protected void tearDown() throws Exception {
for (IndexingContext c : myIndexer.getIndexingContexts().values()) {
myIndexer.removeIndexingContext(c, false);
}
myEmbedder.release();
super.tearDown();
}
use of org.sonatype.nexus.index.context.IndexingContext in project intellij-community by JetBrains.
the class NexusIndexerTest method _testAddingArtifacts.
public void _testAddingArtifacts() throws Exception {
IndexingContext c = addContext("virtual", myIndexDir, null, null);
createProjectPom("");
ArtifactInfo ai = new ArtifactInfo(c.getRepositoryId(), "group", "id", "version", null);
ArtifactContext a = new ArtifactContext(new File(myProjectPom.getPath()), null, null, ai, null);
Maven2ServerIndexerImpl.addArtifact(myIndexer, c, a);
Query q = new TermQuery(new Term(ArtifactInfo.GROUP_ID, "group"));
FlatSearchRequest request = new FlatSearchRequest(q, ArtifactInfo.VERSION_COMPARATOR);
FlatSearchResponse response = myIndexer.searchFlat(request);
Set<ArtifactInfo> result = response.getResults();
assertSize(1, result);
ArtifactInfo found = new ArrayList<ArtifactInfo>(result).get(0);
assertEquals("group", found.groupId);
assertEquals("id", found.artifactId);
assertEquals("version", found.version);
IndexReader r = c.getIndexReader();
for (int i = 0; i < r.numDocs(); i++) {
Document d = r.document(i);
}
}
Aggregations