in indexer-core/src/main/java/org/apache/maven/index/DefaultNexusIndexer.java [269:321]
public void scan(
final IndexingContext context,
final String fromPath,
final ArtifactScanningListener listener,
final boolean update)
throws IOException {
final File repositoryDirectory = context.getRepository();
if (repositoryDirectory == null) {
// nothing to scan
return;
}
if (!repositoryDirectory.exists()) {
throw new IOException("Repository directory " + repositoryDirectory + " does not exist");
}
// always use temporary context when reindexing
final File tmpDir = Files.createTempDirectory(context.getId() + "-tmp").toFile();
IndexingContext tmpContext = null;
try {
final FSDirectory directory = FSDirectory.open(tmpDir.toPath());
if (update) {
IndexUtils.copyDirectory(context.getIndexDirectory(), directory);
}
tmpContext = new DefaultIndexingContext(
context.getId() + "-tmp", //
context.getRepositoryId(), //
context.getRepository(), //
directory, //
context.getRepositoryUrl(), //
context.getIndexUpdateUrl(), //
context.getIndexCreators(), //
true);
scanner.scan(new ScanningRequest(
tmpContext, //
new DefaultScannerListener(
tmpContext, indexerEngine,
update, listener),
fromPath));
tmpContext.updateTimestamp(true);
context.replace(tmpContext.getIndexDirectory());
} catch (Exception ex) {
throw new IOException("Error scanning context " + context.getId() + ": " + ex, ex);
} finally {
if (tmpContext != null) {
tmpContext.close(true);
}
FileUtils.deleteDirectory(tmpDir);
}
}