in src/main/java/org/apache/sling/feature/scanner/impl/ContentPackageScanner.java [379:417]
ArtifactId extractArtifactId(
final List<Properties> candidates, final String bundleFileName, final ArtifactId packageArtifactId)
throws IOException {
logger.debug("Properties candidates for {} : {}", bundleFileName, candidates);
final List<ArtifactId> idCandidates = getArtifactIds(candidates);
logger.debug("Artifact candidates for {} : {}", bundleFileName, candidates);
// single candidate? return
if (idCandidates.size() == 1) {
final ArtifactId result = adjustClassifier(idCandidates.get(0), bundleFileName);
logger.debug("Found single candidate : {}", result);
return result;
}
// more than one candidate, find matching version
final List<ArtifactId> versionIds = filterCandidatesByVersion(idCandidates, bundleFileName);
if (versionIds.size() == 1) {
final ArtifactId result = adjustClassifier(versionIds.get(0), bundleFileName);
logger.debug("Found single candidate matching version : {}", result);
return result;
}
// check parent group id
for (final ArtifactId id : versionIds.isEmpty() ? idCandidates : versionIds) {
if (id.getGroupId().equals(packageArtifactId.getGroupId())) {
final ArtifactId result = adjustClassifier(id, bundleFileName);
logger.debug("Found candidate with parent group id {} : {}", packageArtifactId.getGroupId(), result);
return result;
}
}
// randomly pick one
if (idCandidates.size() > 0) {
final ArtifactId result = adjustClassifier(idCandidates.get(0), bundleFileName);
logger.debug("Picking random candidate : {}", result);
return result;
}
throw new IOException(bundleFileName + " has no maven coordinates!");
}