in src/main/java/org/apache/sling/feature/cpconverter/ContentPackage2FeatureModelConverter.java [411:452]
public void processSubPackage(@NotNull String path, @Nullable String runMode, @NotNull VaultPackage vaultPackage, boolean isEmbeddedPackage) throws IOException, ConverterException {
requireNonNull(path, "Impossible to process a null vault package");
requireNonNull(vaultPackage, "Impossible to process a null vault package");
if (!isSubContentPackageIncluded(path)) {
logger.info("Sub content-package {} is filtered out, so it won't be processed.", path);
return;
}
emitters.stream().forEach(e -> e.startSubPackage(path, vaultPackage));
VaultPackageAssembler clonedPackage = VaultPackageAssembler.create(this.getTempDirectory(), vaultPackage, removeInstallHooks,disablePackageTypeRecalculation);
// Please note: THIS IS A HACK to meet the new requirement without drastically change the original design
// temporary swap the main handler to collect stuff
VaultPackageAssembler handler = getMainPackageAssembler();
Properties parentProps = handler.getPackageProperties();
String parentTypeStr = (String)parentProps.get(PackageProperties.NAME_PACKAGE_TYPE);
boolean isContainerPackage = StringUtils.isNotBlank(parentTypeStr) ? PackageType.CONTAINER.equals(PackageType.valueOf(parentTypeStr.toUpperCase(Locale.ENGLISH))) : false;
setMainPackageAssembler(clonedPackage);
assemblers.add(clonedPackage);
// scan the detected package, first
traverse(vaultPackage, runMode);
//set dependency to parent package if the parent package is an application package & subpackage is embedded
if (isEmbeddedPackage && !isContainerPackage) {
PackageId parentId = new PackageId((String) parentProps.get(PackageProperties.NAME_GROUP),
(String) parentProps.get(PackageProperties.NAME_NAME),
(String) parentProps.get(PackageProperties.NAME_VERSION));
clonedPackage.addDependency(new Dependency(parentId));
}
// deploy the new content-package to the local mvn bundles dir and attach it to the feature
try (VaultPackage result = processContentPackageArchive(clonedPackage, runMode)) {
emitters.stream().forEach(e -> e.endSubPackage(path, vaultPackage.getId(), result));
}
// restore the previous assembler
setMainPackageAssembler(handler);
}