in src/main/java/org/apache/jackrabbit/filevault/maven/packaging/mojo/VaultMojo.java [604:658]
private Map<File, File> addSourceDirectory(MavenResourcesExecution mavenResourcesExecution, ContentPackageArchiver contentPackageArchiver, File jcrSourceDirectory, Filters filters,
Map<String, File> embeddedFiles) throws MavenFilteringException {
Map<File, File> duplicateFiles = new HashMap<>();
// See GRANITE-16348
// we want to build a list of all the root directories in the order they were specified in the filter
// but ignore the roots that don't point to a directory
List<PathFilterSet> filterSets = filters.getFilterSets();
if (filterSets.isEmpty()) {
DefaultFileSet fileSet = createFileSet(jcrSourceDirectory, Constants.ROOT_DIR + prefix);
duplicateFiles.putAll(getOverwrittenProtectedFiles(fileSet, false));
addFileSetToArchive(mavenResourcesExecution, contentPackageArchiver, fileSet);
} else {
for (PathFilterSet filterSet : filterSets) {
String relPath = PlatformNameFormat.getPlatformPath(filterSet.getRoot());
String destPath = FileUtils.normalize(Constants.ROOT_DIR + prefix + relPath);
// CQ-4204625 skip embedded files, they have been added already
if (embeddedFiles.containsKey(destPath)) {
continue;
}
// check for full coverage aggregate
File sourceFile = new File(jcrSourceDirectory, relPath + ".xml");
if (sourceFile.isFile()) {
destPath = FileUtils.normalize(Constants.ROOT_DIR + prefix + relPath + ".xml");
if (isOverwritingProtectedFile(new File(destPath), sourceFile, false)) {
duplicateFiles.put(new File(destPath), sourceFile);
}
addFileToArchive(mavenResourcesExecution, contentPackageArchiver, sourceFile, destPath);
// similar to AbstractExporter all ancestors should be contained as well (see AggregateImpl.prepare(...))
addAncestors(contentPackageArchiver, sourceFile, jcrSourceDirectory, destPath);
} else {
// root path for ancestors is in one of the parent directories?
sourceFile = new File(jcrSourceDirectory, relPath);
// traverse the ancestors until we find a existing directory (see CQ-4204625)
while ((!sourceFile.exists() || !sourceFile.isDirectory())
&& !jcrSourceDirectory.equals(sourceFile)) {
sourceFile = sourceFile.getParentFile();
relPath = StringUtils.chomp(relPath, "/");
}
if (!jcrSourceDirectory.equals(sourceFile)) {
destPath = FileUtils.normalize(Constants.ROOT_DIR + prefix + relPath);
DefaultFileSet fileSet = createFileSet(sourceFile, destPath + "/");
duplicateFiles.putAll(getOverwrittenProtectedFiles(fileSet, false));
addFileSetToArchive(mavenResourcesExecution, contentPackageArchiver, fileSet);
// similar to AbstractExporter all ancestors should be contained as well (see AggregateImpl.prepare(...))
addAncestors(contentPackageArchiver, sourceFile, jcrSourceDirectory, destPath);
}
}
}
}
return duplicateFiles;
}