Skip to content

Commit ab6f8b0

Browse files
Content Package Post Processors: Add Option "dependencyChainIgnore" (#179)
1 parent 0d66886 commit ab6f8b0

File tree

13 files changed

+78
-8
lines changed

13 files changed

+78
-8
lines changed

changes.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
xsi:schemaLocation="http://maven.apache.org/changes/2.0.0 https://maven.apache.org/xsd/changes-2.0.0.xsd">
2525
<body>
2626

27-
<release version="2.20.4" date="not released">
27+
<release version="2.21.0" date="not released">
28+
<action type="add" dev="sseifert" issue="179">
29+
Content Package Post Processors: Add option "dependencyChainIgnore" to ignore a content package in the dependency chain, i.e. it does not play a role for this package in which order it is deployed compared to other packages.
30+
</action>
2831
<action type="update" dev="sseifert" issue="178">
2932
Omit CONGA file header in generated content packages and use single creation date.
3033
</action>

conga-aem-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/postprocessor/ContentPackageOptions.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,10 @@ private ContentPackageOptions() {
103103
*/
104104
public static final String PROPERTY_PACKAGE_ALLOW_INDEX_DEFINITIONS = "contentPackage.allowIndexDefinitions";
105105

106+
/**
107+
* Ignore this package in dependency chain, i.e. it does not play a role for this package in which order
108+
* it is deployed compared to other packages.
109+
*/
110+
public static final String PROPERTY_DEPENCY_CHAIN_IGNORE = "dependencyChainIgnore";
111+
106112
}

conga-aem-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/postprocessor/ContentPackagePropertiesPostProcessor.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package io.wcm.devops.conga.plugins.aem.postprocessor;
2121

22+
import static io.wcm.devops.conga.plugins.aem.postprocessor.ContentPackageOptions.PROPERTY_DEPENCY_CHAIN_IGNORE;
2223
import static io.wcm.devops.conga.plugins.aem.postprocessor.ContentPackageOptions.PROPERTY_PACKAGE_PACKAGE_TYPE;
2324
import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_PACKAGE_TYPE;
2425

@@ -54,6 +55,11 @@ public class ContentPackagePropertiesPostProcessor extends AbstractPostProcessor
5455
*/
5556
public static final String MODEL_OPTIONS_PROPERTY = "aemContentPackageProperties";
5657

58+
/**
59+
* Marks content package to be ignored in dependency chain.
60+
*/
61+
public static final String DEPENDENCY_CHAIN_IGNORE_PROPERTY = "aemContentPackageDepenencyChainIgnore";
62+
5763
private static final String FILE_EXTENSION = "zip";
5864
private static final String ALTERNATE_FILE_EXTENSION = "jar";
5965

@@ -94,6 +100,12 @@ public List<FileContext> apply(FileContext fileContext, PostProcessorContext con
94100
}
95101

96102
fileContext.getModelOptions().put(MODEL_OPTIONS_PROPERTY, properties);
103+
104+
boolean dependencyChainIgnore = ContentPackageUtil.getOptionalPropBoolean(context.getOptions(), PROPERTY_DEPENCY_CHAIN_IGNORE);
105+
if (dependencyChainIgnore) {
106+
fileContext.getModelOptions().put(DEPENDENCY_CHAIN_IGNORE_PROPERTY, true);
107+
}
108+
97109
logger.info("Extracted properties from AEM content package.");
98110
}
99111
}

conga-aem-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/util/ContentPackageUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ else if (value != null) {
264264
* @param key Key
265265
* @return Option value or false
266266
*/
267-
private static boolean getOptionalPropBoolean(Map<String, Object> options, String key) {
267+
public static boolean getOptionalPropBoolean(Map<String, Object> options, String key) {
268268
Object value = getOptionalProp(options, key);
269269
if (value instanceof Boolean) {
270270
return (Boolean)value;

conga-aem-plugin/src/test/java/io/wcm/devops/conga/plugins/aem/postprocessor/ContentPackagePropertiesPostProcessorTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ void testContentPackage() {
6262
assertEquals(false, props.get("requiresRoot"));
6363
assertEquals(2, props.get("packageFormatVersion"));
6464
assertNull(props.get("packageType"));
65+
66+
assertNull(fileContext.getModelOptions().get(ContentPackagePropertiesPostProcessor.DEPENDENCY_CHAIN_IGNORE_PROPERTY));
67+
}
68+
69+
@Test
70+
void testContentPackageIgnoreDependencyChain() {
71+
72+
FileContext fileContext = new FileContext()
73+
.file(new File("src/test/resources/package/example.zip"));
74+
75+
// post-process
76+
applyPlugin(fileContext, Map.of(ContentPackageOptions.PROPERTY_DEPENCY_CHAIN_IGNORE, true));
77+
78+
// validate
79+
assertEquals(true, fileContext.getModelOptions().get(ContentPackagePropertiesPostProcessor.DEPENDENCY_CHAIN_IGNORE_PROPERTY));
6580
}
6681

6782
@SuppressWarnings("unchecked")

src/site/markdown/extensions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Both post processor plugins support a set of options that allow further configur
4545
| `contentPackage.requiresRoot` | Package requires root.
4646
| `contentPackage.requiresRestart`| Package requires restart.
4747
| `contentPackage.allowIndexDefinitions` | Package allows index definitions.
48+
| `dependencyChainIgnore` | Ignore this package in dependency chain, i.e. it does not play a role for this package in which order it is deployed compared to other packages.
4849

4950

5051
Example for defining package properties with a set of filters:

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ private void buildAddContentPackages(ContentPackage contentPackage, String rootP
416416
.filter(item -> isAuthorAndPublish(item)
417417
|| (isOnlyAuthor(item) && isOnlyAuthor(currentPackage))
418418
|| (isOnlyPublish(item) && isOnlyPublish(currentPackage)))
419+
// ignore packages that are marked as dependency chain ignore
420+
.filter(item -> !item.isDependencyChainIgnore())
419421
// get last in list
420422
.reduce((first, second) -> second).orElse(null);
421423
}
@@ -602,7 +604,7 @@ private List<TemporaryContentPackageFile> processContentPackage(ContentPackageFi
602604

603605
// update package dependencies
604606
ContentPackageFile dependencyFile = previousPkg;
605-
if (autoDependenciesMode == AutoDependenciesMode.OFF) {
607+
if (autoDependenciesMode == AutoDependenciesMode.OFF || pkg.isDependencyChainIgnore()) {
606608
dependencyFile = null;
607609
}
608610
updateDependencies(pkg, props, dependencyFile, environmentRunMode, allPackagesFromFileSets);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,9 @@ public String getPackageInfoWithDependencies() {
8888
return sb.toString();
8989
}
9090

91+
@Override
92+
public boolean isDependencyChainIgnore() {
93+
return false;
94+
}
95+
9196
}

tooling/conga-aem-maven-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/maven/model/ContentPackageFile.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public interface ContentPackageFile extends InstallableFile {
5252
@Nullable
5353
String getPackageType();
5454

55+
/**
56+
* @return Ignore in dependency chain
57+
*/
58+
boolean isDependencyChainIgnore();
59+
5560
default String getPackageInfo() {
5661
return StringUtils.defaultString(getGroup())
5762
+ ":" + StringUtils.defaultString(getName())

tooling/conga-aem-maven-plugin/src/main/java/io/wcm/devops/conga/plugins/aem/maven/model/ModelContentPackageFile.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
*/
2020
package io.wcm.devops.conga.plugins.aem.maven.model;
2121

22+
import static io.wcm.devops.conga.plugins.aem.postprocessor.ContentPackagePropertiesPostProcessor.DEPENDENCY_CHAIN_IGNORE_PROPERTY;
23+
import static io.wcm.devops.conga.plugins.aem.postprocessor.ContentPackagePropertiesPostProcessor.MODEL_OPTIONS_PROPERTY;
2224
import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_GROUP;
2325
import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_NAME;
2426
import static org.apache.jackrabbit.vault.packaging.PackageProperties.NAME_PACKAGE_TYPE;
@@ -31,8 +33,6 @@
3133

3234
import org.jetbrains.annotations.Nullable;
3335

34-
import io.wcm.devops.conga.plugins.aem.postprocessor.ContentPackagePropertiesPostProcessor;
35-
3636
/**
3737
* Represents a content package file generated or referenced by CONGA.
3838
*/
@@ -43,6 +43,7 @@ public final class ModelContentPackageFile extends AbstractInstallableFile imple
4343
private final Boolean recursive;
4444
private final Integer delayAfterInstallSec;
4545
private final Integer httpSocketTimeoutSec;
46+
private final Boolean dependencyChainIgnore;
4647

4748
private final String name;
4849
private final String group;
@@ -63,11 +64,11 @@ public ModelContentPackageFile(File file, Map<String, Object> fileData, List<Str
6364
this.recursive = (Boolean)fileData.get("recursive");
6465
this.delayAfterInstallSec = (Integer)fileData.get("delayAfterInstallSec");
6566
this.httpSocketTimeoutSec = (Integer)fileData.get("httpSocketTimeoutSec");
67+
this.dependencyChainIgnore = (Boolean)fileData.get(DEPENDENCY_CHAIN_IGNORE_PROPERTY);
6668

67-
Map<String, Object> contentPackageProperties = (Map<String, Object>)fileData.get(
68-
ContentPackagePropertiesPostProcessor.MODEL_OPTIONS_PROPERTY);
69+
Map<String, Object> contentPackageProperties = (Map<String, Object>)fileData.get(MODEL_OPTIONS_PROPERTY);
6970
if (contentPackageProperties == null) {
70-
throw new IllegalArgumentException(ContentPackagePropertiesPostProcessor.MODEL_OPTIONS_PROPERTY + " missing.");
71+
throw new IllegalArgumentException(MODEL_OPTIONS_PROPERTY + " missing.");
7172
}
7273
this.name = Objects.toString(contentPackageProperties.get(NAME_NAME), null);
7374
this.group = Objects.toString(contentPackageProperties.get(NAME_GROUP), null);
@@ -119,4 +120,9 @@ public String getPackageType() {
119120
return this.packageType;
120121
}
121122

123+
@Override
124+
public boolean isDependencyChainIgnore() {
125+
return dependencyChainIgnore != null && dependencyChainIgnore;
126+
}
127+
122128
}

0 commit comments

Comments
 (0)