Skip to content

Commit a9cde6f

Browse files
committed
revert: conga-aem-maven-plugin: Fix problem with container packages contained in "all" package that contain nested sub packages - add sub packages in the dependency chain instead of the container package which get's eliminated in the cp2fm process.
but keep the additional test packages for unit tests
1 parent 0cab29f commit a9cde6f

3 files changed

Lines changed: 11 additions & 89 deletions

File tree

changes.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@
2323
xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 https://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
2424
<body>
2525

26-
<release version="1.14.6" date="not released">
27-
<action type="fix" dev="sseifert">
28-
conga-aem-maven-plugin: Fix problem with container packages contained in "all" package that contain nested sub packages - add sub packages in the dependency chain instead of the container package which get's eliminated in the cp2fm process.
29-
</action>
30-
</release>
31-
3226
<release version="1.14.4" date="2021-06-08">
3327
<action type="update" dev="sseifert">
3428
Update to latest AEM Content Package Builder.

tooling/conga-aem-maven-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/maven/allpackage/AllPackageBuilder.java

Lines changed: 8 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.io.FileOutputStream;
3030
import java.io.IOException;
3131
import java.io.InputStream;
32-
import java.nio.file.Files;
3332
import java.util.ArrayList;
3433
import java.util.Arrays;
3534
import java.util.Enumeration;
@@ -53,18 +52,14 @@
5352
import org.apache.jackrabbit.vault.packaging.VersionRange;
5453
import org.apache.maven.plugin.logging.Log;
5554
import org.apache.maven.plugin.logging.SystemStreamLog;
56-
import org.jetbrains.annotations.NotNull;
5755

58-
import com.google.common.collect.ImmutableMap;
5956
import com.google.common.collect.ImmutableSet;
6057

6158
import io.wcm.devops.conga.plugins.aem.maven.AutoDependenciesMode;
6259
import io.wcm.devops.conga.plugins.aem.maven.model.ContentPackageFile;
63-
import io.wcm.devops.conga.plugins.aem.postprocessor.ContentPackagePropertiesPostProcessor;
6460
import io.wcm.tooling.commons.contentpackagebuilder.ContentPackage;
6561
import io.wcm.tooling.commons.contentpackagebuilder.ContentPackageBuilder;
6662
import io.wcm.tooling.commons.contentpackagebuilder.PackageFilter;
67-
import io.wcm.tooling.commons.packmgr.util.ContentPackageProperties;
6863

6964
/**
7065
* Builds "all" package based on given set of content packages.
@@ -404,34 +399,16 @@ private static String updateDependencies(Properties props, ContentPackageFile de
404399
existingDeps = removeReferencesToManagedPackages(existingDeps, allPackagesFromFileSets);
405400
}
406401

407-
Dependency[] deps = null;
408-
if (dependencyFile == null) {
409-
deps = existingDeps;
402+
Dependency[] deps;
403+
if (dependencyFile != null) {
404+
String runModeSuffix = buildRunModeSuffix(dependencyFile, environmentRunMode);
405+
Dependency newDependency = new Dependency(dependencyFile.getGroup(),
406+
dependencyFile.getName() + runModeSuffix,
407+
VersionRange.fromString(dependencyFile.getVersion()));
408+
deps = addDependency(existingDeps, newDependency);
410409
}
411410
else {
412-
// if package is container package: check for embedded sub packages
413-
List<ContentPackageFile> containerSubPackageFiles = null;
414-
if (isContainerPackage(dependencyFile)) {
415-
containerSubPackageFiles = getContainerSubPackageFiles(dependencyFile);
416-
}
417-
// if sub packages are present: add dependencies to sub packages instead of the container package
418-
// nested sub packages are referenced without any runmode suffix
419-
if (containerSubPackageFiles != null) {
420-
for (ContentPackageFile subPackageFileItem : containerSubPackageFiles) {
421-
Dependency newDependency = new Dependency(subPackageFileItem.getGroup(),
422-
subPackageFileItem.getName(),
423-
VersionRange.fromString(subPackageFileItem.getVersion()));
424-
deps = addDependency(existingDeps, newDependency);
425-
}
426-
}
427-
// otherwise add dependency to package itself
428-
else {
429-
String runModeSuffix = buildRunModeSuffix(dependencyFile, environmentRunMode);
430-
Dependency newDependency = new Dependency(dependencyFile.getGroup(),
431-
dependencyFile.getName() + runModeSuffix,
432-
VersionRange.fromString(dependencyFile.getVersion()));
433-
deps = addDependency(existingDeps, newDependency);
434-
}
411+
deps = existingDeps;
435412
}
436413

437414
if (deps != null) {
@@ -453,55 +430,6 @@ private static Dependency[] addDependency(Dependency[] existingDeps, Dependency
453430
}
454431
}
455432

456-
/**
457-
* If the content package is a container package that contains sub packages (that are sub packages in sub packages),
458-
* the cp2fm conversion eliminates the nested package container "in the middle", leading to unresolveable
459-
* dependencies. So, if the dependency content package contains sub packages, we add dependencies
460-
* to the contained sub packages instead.
461-
* @param dependencyFile Dependency package
462-
* @return List of dependency packages or null if none exist
463-
* @throws IOException I/O exception
464-
*/
465-
private static List<ContentPackageFile> getContainerSubPackageFiles(@NotNull ContentPackageFile dependencyFile) throws IOException {
466-
// introspect container package file - check for sub packages
467-
List<ContentPackageFile> dependencyFiles = new ArrayList<>();
468-
try (ZipFile zipFileIn = new ZipFile(dependencyFile.getFile())) {
469-
Enumeration<? extends ZipEntry> zipInEntries = zipFileIn.entries();
470-
while (zipInEntries.hasMoreElements()) {
471-
ZipEntry zipInEntry = zipInEntries.nextElement();
472-
if (StringUtils.equals("zip", FilenameUtils.getExtension(zipInEntry.getName()))) {
473-
File tempFile = File.createTempFile(zipInEntry.getName() + "-subpackage-", ".zip");
474-
try {
475-
try (FileOutputStream fos = new FileOutputStream(tempFile);
476-
InputStream zis = zipFileIn.getInputStream(zipInEntry)) {
477-
IOUtils.copy(zis, fos);
478-
}
479-
Map<String, Object> props = ContentPackageProperties.get(tempFile);
480-
ContentPackageFile subPackageFile = new ContentPackageFile(tempFile,
481-
ImmutableMap.of(ContentPackagePropertiesPostProcessor.MODEL_OPTIONS_PROPERTY, props),
482-
ImmutableMap.of("variants", dependencyFile.getVariants()));
483-
if (StringUtils.isNoneBlank(subPackageFile.getGroup(), subPackageFile.getName(), subPackageFile.getVersion())) {
484-
dependencyFiles.add(subPackageFile);
485-
}
486-
}
487-
finally {
488-
Files.delete(tempFile.toPath());
489-
}
490-
}
491-
}
492-
}
493-
if (dependencyFiles.isEmpty()) {
494-
return null;
495-
}
496-
else {
497-
return dependencyFiles;
498-
}
499-
}
500-
501-
private static boolean isContainerPackage(@NotNull ContentPackageFile packageFile) {
502-
return StringUtils.equals(packageFile.getPackageType(), PackageType.CONTAINER.name().toLowerCase());
503-
}
504-
505433
private static void addSuffixToPackageName(Properties props, ContentPackageFile pkg, String environmentRunMode) {
506434
String runModeSuffix = buildRunModeSuffix(pkg, environmentRunMode);
507435
String packageName = props.getProperty(NAME_NAME) + runModeSuffix;

tooling/conga-aem-maven-plugin/src/test/java/io/wcm/devops/conga/plugins/aem/maven/allpackage/AllPackageBuilderTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void testBuild_IMMUTABLE_MUTABLE_COMBINED(Set<String> cloudManagerTarget, List<S
164164
"aem-cms-system-config" + runmodeSuffix + ".zip");
165165
assertNameDependencies(applicationInstallDir, "accesscontroltool-oakindex-package" + runmodeSuffix + "-3.0.0.zip",
166166
"accesscontroltool-oakindex-package" + runmodeSuffix,
167-
"Netcentric:accesscontroltool-apps-package:3.0.0");
167+
"Netcentric:accesscontroltool-package" + runmodeSuffix + ":3.0.0");
168168
assertNameDependencies(applicationInstallDir, "acs-aem-commons-ui.apps" + runmodeSuffix + "-4.10.0.zip",
169169
"acs-aem-commons-ui.apps" + runmodeSuffix,
170170
"day/cq60/product:cq-content:6.3.64");
@@ -240,7 +240,7 @@ void testBuild_IMMUTABLE_MUTABLE_SEPARATE(Set<String> cloudManagerTarget, List<S
240240
"aem-cms-system-config" + runmodeSuffix + ".zip");
241241
assertNameDependencies(applicationInstallDir, "accesscontroltool-oakindex-package" + runmodeSuffix + "-3.0.0.zip",
242242
"accesscontroltool-oakindex-package" + runmodeSuffix,
243-
"Netcentric:accesscontroltool-apps-package:3.0.0");
243+
"Netcentric:accesscontroltool-package" + runmodeSuffix + ":3.0.0");
244244
assertNameDependencies(applicationInstallDir, "acs-aem-commons-ui.apps" + runmodeSuffix + "-4.10.0.zip",
245245
"acs-aem-commons-ui.apps" + runmodeSuffix,
246246
"day/cq60/product:cq-content:6.3.64");
@@ -315,7 +315,7 @@ void testBuild_IMMUTABLE_ONLY(Set<String> cloudManagerTarget, List<String> runmo
315315
"aem-cms-system-config" + runmodeSuffix + ".zip");
316316
assertNameDependencies(applicationInstallDir, "accesscontroltool-oakindex-package" + runmodeSuffix + "-3.0.0.zip",
317317
"accesscontroltool-oakindex-package" + runmodeSuffix,
318-
"Netcentric:accesscontroltool-apps-package:3.0.0");
318+
"Netcentric:accesscontroltool-package" + runmodeSuffix + ":3.0.0");
319319
assertNameDependencies(applicationInstallDir, "acs-aem-commons-ui.apps" + runmodeSuffix + "-4.10.0.zip",
320320
"acs-aem-commons-ui.apps" + runmodeSuffix,
321321
"day/cq60/product:cq-content:6.3.64");

0 commit comments

Comments
 (0)