in indexer-core/src/main/java/org/apache/maven/index/DefaultArtifactContextProducer.java [61:122]
public ArtifactContext getArtifactContext(IndexingContext context, File file) {
// TODO shouldn't this use repository layout instead?
String repositoryPath = context.getRepository().getAbsolutePath();
String artifactPath = file.getAbsolutePath();
// protection from IndexOutOfBounds
if (artifactPath.length() <= repositoryPath.length()) {
return null; // not an artifact
}
if (!isIndexable(file)) {
return null; // skipped
}
Gav gav = getGavFromPath(context, repositoryPath, artifactPath);
if (gav == null) {
return null; // not an artifact, but rather metadata
}
File pom;
File artifact;
if (file.getName().endsWith(".pom")) {
ArtifactLocator al = new ArtifactLocator(mapper);
artifact = al.locate(file, context.getGavCalculator(), gav);
// If we found the matching artifact, switch over to indexing that, instead of the pom
if (artifact != null) {
gav = getGavFromPath(context, repositoryPath, artifact.getAbsolutePath());
}
pom = file;
} else {
artifact = file;
pom = pl.locate(file, context.getGavCalculator(), gav);
}
String groupId = gav.getGroupId();
String artifactId = gav.getArtifactId();
String version = gav.getBaseVersion();
String classifier = gav.getClassifier();
ArtifactInfo ai = new ArtifactInfo(
context.getRepositoryId(), groupId, artifactId, version, classifier, gav.getExtension());
// store extension if classifier is not empty
if (!StringUtils.isEmpty(ai.getClassifier())) {
ai.setPackaging(gav.getExtension());
}
ai.setFileName(file.getName());
ai.setFileExtension(gav.getExtension());
File metadata = ml.locate(pom);
return new ArtifactContext(pom, artifact, metadata, ai, gav);
}