in indexer-core/src/main/java/org/apache/maven/index/locator/ArtifactLocator.java [50:83]
public File locate(File source, GavCalculator gavCalculator, Gav gav) {
// if we don't have this data, nothing we can do
if (source == null //
|| !source.exists() //
|| gav == null //
|| gav.getArtifactId() == null //
|| gav.getVersion() == null) {
return null;
}
try (InputStream inputStream = Files.newInputStream(source.toPath())) {
// need to read the pom model to get packaging
final Model model = new MavenXpp3Reader().read(inputStream, false);
if (model == null) {
return null;
}
// now generate the artifactname
String artifactName = gav.getArtifactId() + "-" + gav.getVersion() + "."
+ mapper.getExtensionForPackaging(model.getPackaging());
File artifact = new File(source.getParent(), artifactName);
if (!artifact.exists()) {
return null;
}
return artifact;
} catch (XmlPullParserException | IOException e) {
LOGGER.warn("skip error reading pom from file:" + source, e);
return null;
}
}