in src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/GenerateMetadataMojo.java [1014:1073]
private Map<String, File> getEmbeddeds() throws MojoFailureException, ConfigurationException {
Map<String, File> fileMap = new HashMap<>();
for (Embedded emb : embeddeds) {
final Collection<Artifact> artifacts = emb.getMatchingArtifacts(project);
if (artifacts.isEmpty()) {
if (failOnMissingEmbed) {
throw new MojoFailureException("Embedded artifact specified " + emb + ", but no matching dependency artifact found. Add the missing dependency or fix the embed definition.");
} else {
getLog().warn("No matching artifacts for " + emb);
continue;
}
}
if (emb.getDestFileName() != null && artifacts.size() > 1) {
throw new MojoFailureException("destFileName defined but several artifacts match for " + emb);
}
String targetPath = emb.getTarget();
if (targetPath == null) {
targetPath = embeddedTarget;
if (targetPath == null) {
final String loc = (prefix.length() == 0)
? "apps/"
: prefix;
targetPath = loc + "bundles/install/";
getLog().info("No target path set on " + emb + "; assuming default " + targetPath);
}
}
targetPath = makeAbsolutePath(targetPath);
targetPath = Constants.ROOT_DIR + targetPath;
targetPath = FileUtils.normalize(targetPath);
if (!targetPath.endsWith("/")) {
targetPath += "/";
}
getLog().info("Embedding --- " + emb + " ---");
for (final Artifact artifact : artifacts) {
final File source = artifact.getFile();
String destFileName = emb.getDestFileName();
if (destFileName == null) {
// construct final name from artifact coordinates
destFileName = Text.getName(embedArtifactLayout.pathOf(artifact));
}
final String targetPathName = targetPath + destFileName;
final String targetNodePathName = targetPathName.substring(Constants.ROOT_DIR.length());
File oldSource = fileMap.put(targetPathName, source);
if (oldSource != null) {
throw new MojoFailureException(String.format("Duplicate target path %s for %s and %s", targetPathName, source, oldSource));
}
getLog().info(String.format("Embedding %s (from %s) -> %s", artifact.getId(), source.getAbsolutePath(), targetPathName));
if (emb.isFilter()) {
addEmbeddedFileToFilter(targetNodePathName, emb.isAllVersionsFilter());
}
}
}
return fileMap;
}