in indexer-core/src/main/java/org/apache/maven/index/ArtifactContext.java [84:119]
public Model getPomModel() {
// First check for local pom file
File pom = getPom();
if (pom != null && pom.isFile()) {
try (InputStream inputStream = Files.newInputStream(pom.toPath())) {
return new MavenXpp3Reader().read(inputStream, false);
} catch (IOException | XmlPullParserException e) {
LOGGER.warn("skip error reading pom: " + pom, e);
}
}
// Otherwise, check for pom contained in maven generated artifact
else if (getArtifact() != null && getArtifact().isFile()) {
boolean isZip = false;
try (ZipFile zipFile = new ZipFile(artifact)) {
isZip = true;
final String embeddedPomPath =
"META-INF/maven/" + getGav().getGroupId() + "/" + getGav().getArtifactId() + "/pom.xml";
ZipEntry zipEntry = zipFile.getEntry(embeddedPomPath);
if (zipEntry != null) {
try (InputStream inputStream = zipFile.getInputStream(zipEntry)) {
return new MavenXpp3Reader().read(inputStream, false);
}
}
} catch (IOException | XmlPullParserException e) {
if (e instanceof ZipException && !isZip) {
// ZipFile constructor threw ZipException which means this is no zip file -> ignore
} else {
LOGGER.warn("skip error reading pom within artifact:" + artifact, e);
}
}
}
return null;
}