Skip to content

Commit 4b50006

Browse files
committed
conga-aem-maven-plugin: Allow to defined custom package properties for 'cloudmanager-all-package' goal.
1 parent a6be0a7 commit 4b50006

5 files changed

Lines changed: 28 additions & 7 deletions

File tree

changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
<body>
2525

2626
<release version="1.11.2" date="not released">
27+
<action type="update" dev="sseifert">
28+
conga-aem-maven-plugin: Allow to defined custom package properties for 'cloudmanager-all-package' goal.
29+
</action>
2730
<action type="fix" dev="sseifert">
2831
Fail content package build when node or property names contains illegal characters (not following JCR standards).
2932
</action>

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.File;
2525
import java.io.IOException;
2626
import java.util.List;
27+
import java.util.Map;
2728
import java.util.Set;
2829

2930
import org.apache.maven.plugin.MojoExecutionException;
@@ -66,6 +67,12 @@ public final class CloudManagerAllPackageMojo extends AbstractCloudManagerMojo {
6667
@Parameter(property = "conga.cloudManager.allPackage.autoDependenciesSeparateMutable", defaultValue = "false")
6768
private boolean autoDependenciesSeparateMutable;
6869

70+
/**
71+
* Specifies additional properties to be set in the properties.xml file.
72+
*/
73+
@Parameter
74+
private Map<String, String> properties;
75+
6976
/**
7077
* Set this to "true" to skip installing packages to CRX although configured in the POM.
7178
*/
@@ -107,7 +114,7 @@ private void buildAllPackage(File environmentDir, File nodeDir, Set<String> clou
107114
.logger(getLog());
108115

109116
try {
110-
if (builder.build(contentPackages, cloudManagerTarget)) {
117+
if (builder.build(contentPackages, cloudManagerTarget, properties)) {
111118
getLog().info("Generated " + getCanonicalPath(targetFile));
112119
}
113120
else {

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.ArrayList;
3232
import java.util.Enumeration;
3333
import java.util.List;
34+
import java.util.Map;
3435
import java.util.Properties;
3536
import java.util.Set;
3637
import java.util.stream.Collectors;
@@ -119,10 +120,12 @@ private Log getLog() {
119120
* Build "all" content package.
120121
* @param contentPackages Content packages (invalid will be filtered out)
121122
* @param cloudManagerTarget Target environments/run modes the packages should be attached to
123+
* @param properties Specifies additional properties to be set in the properties.xml file.
122124
* @return true if "all" package was generated, false if not valid package was found.
123125
* @throws IOException I/O exception
124126
*/
125-
public boolean build(List<ContentPackageFile> contentPackages, Set<String> cloudManagerTarget) throws IOException {
127+
public boolean build(List<ContentPackageFile> contentPackages,
128+
Set<String> cloudManagerTarget, Map<String, String> properties) throws IOException {
126129

127130
// collect list of cloud manager environment run modes
128131
List<String> environmentRunmodes = new ArrayList<>();
@@ -168,6 +171,11 @@ public boolean build(List<ContentPackageFile> contentPackages, Set<String> cloud
168171
String rootPath = buildRootPath(groupName, packageName);
169172
builder.filter(new PackageFilter(rootPath));
170173

174+
// additional package properties
175+
if (properties != null) {
176+
properties.entrySet().forEach(entry -> builder.property(entry.getKey(), entry.getValue()));
177+
}
178+
171179
// build content package
172180
// if auto dependencies is active: build separate "dependency chains" between mutable and immutable packages
173181
try (ContentPackage contentPackage = builder.build(targetFile)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void testBuild() throws Exception {
6060

6161
// should fail to to "mixed" packageType
6262
assertThrows(IOException.class, () -> {
63-
builder.build(contentPackages, ImmutableSet.of());
63+
builder.build(contentPackages, ImmutableSet.of(), null);
6464
});
6565
}
6666

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.w3c.dom.Document;
4141
import org.zeroturnaround.zip.ZipUtil;
4242

43+
import com.google.common.collect.ImmutableMap;
4344
import com.google.common.collect.ImmutableSet;
4445

4546
import io.wcm.devops.conga.plugins.aem.maven.model.ContentPackageFile;
@@ -54,7 +55,9 @@ class AllPackageBuilderTest {
5455
@BeforeEach
5556
void setUp(TestInfo testInfo) throws IOException {
5657
nodeDir = new File("src/test/resources/node");
57-
targetDir = new File("target/test-" + getClass().getSimpleName() + "_" + testInfo.getDisplayName());
58+
targetDir = new File("target/test-" + getClass().getSimpleName()
59+
+ (testInfo.getTestMethod().isPresent() ? "_" + testInfo.getTestMethod().get().getName() : ":")
60+
+ "_" + testInfo.getDisplayName());
5861
targetUnpackDir = new File(targetDir, "unpack");
5962
FileUtils.deleteDirectory(targetDir);
6063
targetDir.mkdirs();
@@ -76,7 +79,7 @@ void testBuild(Set<String> cloudManagerTarget, String[] expectedEnvironmentDirs)
7679
File targetFile = new File(targetDir, "all.zip");
7780

7881
AllPackageBuilder builder = new AllPackageBuilder(targetFile, "test-group", "test-pkg");
79-
assertTrue(builder.build(contentPackages, cloudManagerTarget));
82+
assertTrue(builder.build(contentPackages, cloudManagerTarget, ImmutableMap.of("prop1", "value1")));
8083

8184
ZipUtil.unpack(targetFile, targetUnpackDir);
8285

@@ -123,7 +126,7 @@ void testBuildWithAutoDependencies(Set<String> cloudManagerTarget, String[] expe
123126

124127
AllPackageBuilder builder = new AllPackageBuilder(targetFile, "test-group", "test-pkg")
125128
.autoDependencies(true);
126-
assertTrue(builder.build(contentPackages, cloudManagerTarget));
129+
assertTrue(builder.build(contentPackages, cloudManagerTarget, null));
127130

128131
ZipUtil.unpack(targetFile, targetUnpackDir);
129132

@@ -175,7 +178,7 @@ void testBuildWithAutoDependenciesSeparateMutable(Set<String> cloudManagerTarget
175178
AllPackageBuilder builder = new AllPackageBuilder(targetFile, "test-group", "test-pkg")
176179
.autoDependencies(true)
177180
.autoDependenciesSeparateMutable(true);
178-
assertTrue(builder.build(contentPackages, cloudManagerTarget));
181+
assertTrue(builder.build(contentPackages, cloudManagerTarget, null));
179182

180183
ZipUtil.unpack(targetFile, targetUnpackDir);
181184

0 commit comments

Comments
 (0)