Skip to content

Commit f39bb39

Browse files
conga-aem-maven-plugin: Generate a single "all" package per environment combinding files for author/publish run modes (#12)
1 parent 7159b20 commit f39bb39

51 files changed

Lines changed: 1214 additions & 179 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

changes.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
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="2.18.0" date="not released">
27+
<action type="add" dev="sseifert">
28+
conga-aem-maven-plugin: Add parameter "runModeOptimization" to "cloudmanager-all-package" goal, set by default to OFF.
29+
When set to ELIMINATE_DUPLICATES, only one content package is built per environment, including author and publish runmodes, eliminating duplicates between those two modes as much as possible.
30+
</action>
31+
</release>
32+
2633
<release version="2.17.0" date="2022-05-11">
2734
<action type="add" dev="sseifert">
2835
conga-aem-maven-plugin: Add new parameter packageTypeValidation which controls how to handle packages with invalid or without package types.

tooling/conga-aem-maven-plugin/src/it/example/pom.xml

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,22 @@
4444
<dependency>
4545
<groupId>io.wcm</groupId>
4646
<artifactId>io.wcm.caconfig.editor.package</artifactId>
47-
<version>1.0.0</version>
47+
<version>1.12.0</version>
4848
<type>zip</type>
4949
</dependency>
5050

5151
<!-- ACS AEM Commons -->
5252
<dependency>
5353
<groupId>com.adobe.acs</groupId>
5454
<artifactId>acs-aem-commons-ui.apps</artifactId>
55-
<classifier>min</classifier>
56-
<version>5.0.10</version>
55+
<version>5.3.0</version>
5756
<type>zip</type>
5857
<scope>compile</scope>
5958
</dependency>
6059
<dependency>
6160
<groupId>com.adobe.acs</groupId>
6261
<artifactId>acs-aem-commons-ui.content</artifactId>
63-
<classifier>min</classifier>
64-
<version>5.0.10</version>
62+
<version>5.3.0</version>
6563
<type>zip</type>
6664
<scope>compile</scope>
6765
</dependency>
@@ -97,24 +95,54 @@
9795
</configuration>
9896
</plugin>
9997

100-
<!-- do not deploy this example into maven repository -->
10198
<plugin>
102-
<groupId>org.apache.maven.plugins</groupId>
103-
<artifactId>maven-deploy-plugin</artifactId>
104-
<inherited>false</inherited>
105-
<configuration>
106-
<skip>true</skip>
107-
</configuration>
108-
</plugin>
109-
110-
<!-- do not generate site for this project -->
111-
<plugin>
112-
<groupId>org.apache.maven.plugins</groupId>
113-
<artifactId>maven-site-plugin</artifactId>
114-
<configuration>
115-
<skip>true</skip>
116-
<skipDeploy>true</skipDeploy>
117-
</configuration>
99+
<groupId>io.wcm.devops.conga.plugins</groupId>
100+
<artifactId>conga-aem-maven-plugin</artifactId>
101+
<version>@project.version@</version>
102+
<executions>
103+
104+
<!-- Generate variants of "all" packages (for testing purposes) -->
105+
<execution>
106+
<id>all-default</id>
107+
<phase>generate-resources</phase>
108+
<goals>
109+
<goal>cloudmanager-all-package</goal>
110+
</goals>
111+
<configuration>
112+
<group>it</group>
113+
<packageTypeValidation>WARN</packageTypeValidation>
114+
<target>${project.build.directory}/all/default</target>
115+
</configuration>
116+
</execution>
117+
<execution>
118+
<id>all-runmode-optimization</id>
119+
<phase>generate-resources</phase>
120+
<goals>
121+
<goal>cloudmanager-all-package</goal>
122+
</goals>
123+
<configuration>
124+
<group>it</group>
125+
<runModeOptimization>ELIMINATE_DUPLICATES</runModeOptimization>
126+
<packageTypeValidation>WARN</packageTypeValidation>
127+
<target>${project.build.directory}/all/runmode-optimization</target>
128+
</configuration>
129+
</execution>
130+
<execution>
131+
<id>all-single</id>
132+
<phase>generate-resources</phase>
133+
<goals>
134+
<goal>cloudmanager-all-package</goal>
135+
</goals>
136+
<configuration>
137+
<group>it</group>
138+
<singlePackage>true</singlePackage>
139+
<runModeOptimization>ELIMINATE_DUPLICATES</runModeOptimization>
140+
<packageTypeValidation>WARN</packageTypeValidation>
141+
<target>${project.build.directory}/all/single</target>
142+
</configuration>
143+
</execution>
144+
145+
</executions>
118146
</plugin>
119147

120148
</plugins>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Defines an environment
2+
3+
nodes:
4+
5+
# Example nodes
6+
- node: aem-author
7+
roles:
8+
- role: aem
9+
variant: aem-author
10+
- node: aem-publish
11+
roles:
12+
- role: aem
13+
variant: aem-publish
14+
- node: webserver
15+
roles:
16+
- role: webserver
17+
18+
# Tenant defintions
19+
tenants:
20+
21+
# Tenant with two tenant roles (can be used for filtering file multiply)
22+
- tenant: tenant1
23+
roles:
24+
- website
25+
- application
26+
config:
27+
domain: dev.mysite.de
28+
httpd:
29+
serverPort: 8080
30+
serverPortSsl: 8443
31+
enforceSsl: true
32+
33+
# Tenant with one tenant roles
34+
- tenant: tenant2
35+
roles:
36+
- website
37+
config:
38+
domain: dev.mysite.fr
39+
40+
config:
41+
replication:
42+
author:
43+
publishTargets:
44+
- name: publish1
45+
url: http://localhost:4503
46+
transportUser: myuser
47+
transportPassword: mypassword
48+
49+
cloudManager.target:
50+
- dev

tooling/conga-aem-maven-plugin/src/it/example/src/main/environments/prod.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
nodes:
44

55
# Example nodes
6-
- node: aem
6+
- node: aem-author
77
roles:
88
- role: aem
9+
variant: aem-author
10+
- node: aem-publish
11+
roles:
12+
- role: aem
13+
variant: aem-publish
914
- node: webserver
1015
roles:
1116
- role: webserver
@@ -42,3 +47,6 @@ config:
4247
url: http://localhost:4503
4348
transportUser: myuser
4449
transportPassword: mypassword
50+
51+
cloudManager.target:
52+
- prod

tooling/conga-aem-maven-plugin/src/it/example/src/main/roles/aem.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
templateDir: aem
22

3+
variants:
4+
- variant: aem-author
5+
- variant: aem-publish
6+
37
files:
48

59
# Define a AEM content package containing OSGi configurations from a Sling Provisioning file
@@ -45,6 +49,8 @@ files:
4549
pattern: /etc/map/http/.*
4650
- rule: exclude
4751
pattern: /etc/map/http/AppMeasurementBridge
52+
variants:
53+
- aem-publish
4854

4955
# AEM Systems users with ACLs
5056
- file: aem-systemusers.json
@@ -90,7 +96,7 @@ files:
9096
- aem-contentpackage
9197
postProcessorOptions:
9298
contentPackage:
93-
name: schindler-aem-aem-cms-oak-index
99+
name: aem-aem-cms-oak-index
94100
packageType: application
95101
rootPath: /oak:index
96102
allowIndexDefinitions: true
@@ -134,10 +140,14 @@ files:
134140
custom.property2: 123
135141

136142
# ACS AEM Commons
137-
- url: mvn:com.adobe.acs/acs-aem-commons-ui.apps//zip/min
143+
- url: mvn:com.adobe.acs/acs-aem-commons-ui.apps//zip
138144
dir: packages
139-
- url: mvn:com.adobe.acs/acs-aem-commons-ui.content//zip/min
145+
postProcessorOptions:
146+
contentPackage.packageType: application
147+
- url: mvn:com.adobe.acs/acs-aem-commons-ui.content//zip
140148
dir: packages
149+
postProcessorOptions:
150+
contentPackage.packageType: content
141151

142152

143153
# Defines configuration parameters and default values

tooling/conga-aem-maven-plugin/src/it/wcmio-archetype-cloud/build-deploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ execute_deploy() {
198198
if [ -n "${MAVEN_PROFILES}" ]; then
199199
MAVEN_ARGS+="--activate-profiles=${MAVEN_PROFILES} "
200200
fi
201-
if [ -n "${CONGA_ENVIRONMENT}" ] && [ -n "${CONGA_NODE}" ]; then
202-
MAVEN_ARGS+="-Dvault.file=target/${CONGA_ENVIRONMENT}.${CONGA_NODE}.all.zip -Dvault.force=true"
201+
if [ -n "${CONGA_ENVIRONMENT}" ]; then
202+
MAVEN_ARGS+="-Dvault.file=target/${CONGA_ENVIRONMENT}.all.zip -Dvault.force=true"
203203
fi
204204
if [ -n "${SLING_URL}" ]; then
205205
MAVEN_ARGS+="-Dsling.url=${SLING_URL} "

tooling/conga-aem-maven-plugin/src/it/wcmio-archetype-cloud/config-definition/packages-upload.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919

2020

2121
CONGA_ENVIRONMENT="local"
22-
CONGA_NODE="aem-author"
2322

2423
if [[ $0 == *":\\"* ]]; then
2524
DISPLAY_PAUSE_MESSAGE=true
2625
fi
2726

28-
mvn -Pfast -Dvault.file=target/${CONGA_ENVIRONMENT}.${CONGA_NODE}.all.zip -Dvault.force=true clean install wcmio-content-package:install
27+
mvn -Pfast -Dconga.environments=${CONGA_ENVIRONMENT} -Dvault.file=target/${CONGA_ENVIRONMENT}.all.zip -Dvault.force=true clean install wcmio-content-package:install
2928

3029
if [ "$DISPLAY_PAUSE_MESSAGE" = true ]; then
3130
echo ""

tooling/conga-aem-maven-plugin/src/it/wcmio-archetype-cloud/config-definition/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@
243243
</goals>
244244
<configuration>
245245
<group>it</group>
246+
<runModeOptimization>ELIMINATE_DUPLICATES</runModeOptimization>
246247
</configuration>
247248
</execution>
248249

@@ -274,8 +275,7 @@
274275
</skipAnalyserUserTasks>
275276
<!-- Validate "all" packages generated by CONGA -->
276277
<contentPackageFiles>
277-
<file>${project.build.directory}/cloud.aem-author.all.zip</file>
278-
<file>${project.build.directory}/cloud.aem-publish.all.zip</file>
278+
<file>${project.build.directory}/cloud.all.zip</file>
279279
</contentPackageFiles>
280280
</configuration>
281281
</execution>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ abstract class AbstractCloudManagerMojo extends AbstractMojo {
6767
* @return Target directory
6868
*/
6969
protected File getTargetDir() {
70+
// create directory if it does not exist already
71+
if (!target.exists() && !target.mkdirs()) {
72+
throw new IllegalStateException("Unable to create target dir: " + getCanonicalPath(target));
73+
}
7074
return target;
7175
}
7276

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

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import java.util.List;
2727
import java.util.Map;
2828
import java.util.Set;
29+
import java.util.SortedMap;
30+
import java.util.TreeMap;
2931

3032
import org.apache.maven.plugin.MojoExecutionException;
3133
import org.apache.maven.plugin.MojoFailureException;
@@ -98,6 +100,21 @@ public final class CloudManagerAllPackageMojo extends AbstractCloudManagerMojo {
98100
@Parameter(property = "conga.cloudManager.allPackage.autoDependenciesMode")
99101
private AutoDependenciesMode autoDependenciesMode;
100102

103+
/**
104+
* How to optimize author/publish run modes in resulting "all" package.
105+
* <p>
106+
* Possible values:
107+
* </p>
108+
* <ul>
109+
* <li><code>OFF</code>: No optimization takes place. Content packages and bundles are duplicated for author/publish
110+
* run modes to ensure strict following of dependency chain defined in CONGA.</li>
111+
* <li><code>ELIMINATE_DUPLICATES</code>: Eliminates duplicates to ensure that content packages and bundles that are
112+
* installed on both author and publish instances are contained only once in the "all" package.</li>
113+
* </ul>
114+
*/
115+
@Parameter(property = "conga.cloudManager.allPackage.runModeOptimization", defaultValue = "OFF")
116+
private RunModeOptimization runModeOptimization;
117+
101118
/**
102119
* How to validate package types to be included in "all" package.
103120
* <p>
@@ -171,37 +188,57 @@ public void execute() throws MojoExecutionException, MojoFailureException {
171188
if (singlePackage) {
172189
buildSingleAllPackage();
173190
}
191+
else if (runModeOptimization == RunModeOptimization.ELIMINATE_DUPLICATES) {
192+
buildAllPackagesPerEnvironment();
193+
}
174194
else {
175-
buildAllPackagesPerEnvironmentNode();
195+
buildAllPackagesPerEnvironmentAndNode();
176196
}
177197
}
178198

179199
/**
180200
* Build an "all" package for each environment and node.
181201
*/
182-
private void buildAllPackagesPerEnvironmentNode() throws MojoExecutionException, MojoFailureException {
202+
private void buildAllPackagesPerEnvironmentAndNode() throws MojoExecutionException, MojoFailureException {
183203
visitEnvironmentsNodes((environmentDir, nodeDir, cloudManagerTarget, files) -> {
184204
String packageName = environmentDir.getName() + "." + nodeDir.getName() + "." + this.name;
185205
AllPackageBuilder builder = createBuilder(packageName);
186-
187206
try {
188207
builder.add(files, cloudManagerTarget);
189208
}
190209
catch (IllegalArgumentException ex) {
191210
throw new MojoFailureException(ex.getMessage(), ex);
192211
}
193-
194212
buildAllPackage(builder);
195213
});
196214
}
197215

216+
/**
217+
* Build an "all" package for each environment, including all nodes of that environment in a single file.
218+
*/
219+
private void buildAllPackagesPerEnvironment() throws MojoExecutionException, MojoFailureException {
220+
SortedMap<String, AllPackageBuilder> builderPerEnvironment = new TreeMap<>();
221+
visitEnvironmentsNodes((environmentDir, nodeDir, cloudManagerTarget, files) -> {
222+
String packageName = environmentDir.getName() + "." + this.name;
223+
AllPackageBuilder builder = builderPerEnvironment.computeIfAbsent(packageName, this::createBuilder);
224+
try {
225+
builder.add(files, cloudManagerTarget);
226+
}
227+
catch (IllegalArgumentException ex) {
228+
throw new MojoFailureException(ex.getMessage(), ex);
229+
}
230+
});
231+
for (AllPackageBuilder builder : builderPerEnvironment.values()) {
232+
buildAllPackage(builder);
233+
}
234+
}
235+
198236
/**
199237
* Build a single "all" package containing packages from all environments and nodes.
200238
*/
201239
private void buildSingleAllPackage() throws MojoExecutionException, MojoFailureException {
202240
String packageName = this.name;
203241
AllPackageBuilder builder = createBuilder(packageName);
204-
205242
visitEnvironmentsNodes((environmentDir, nodeDir, cloudManagerTarget, files) -> {
206243
try {
207244
builder.add(files, cloudManagerTarget);
@@ -210,7 +247,6 @@ private void buildSingleAllPackage() throws MojoExecutionException, MojoFailureE
210247
throw new MojoFailureException(ex.getMessage(), ex);
211248
}
212249
});
213-
214250
buildAllPackage(builder);
215251
}
216252

@@ -226,6 +262,7 @@ private AllPackageBuilder createBuilder(String packageName) {
226262
return new AllPackageBuilder(targetFile, this.group, packageName)
227263
.version(project.getVersion())
228264
.autoDependenciesMode(this.autoDependenciesMode)
265+
.runModeOptimization(this.runModeOptimization)
229266
.packageTypeValidation(this.packageTypeValidation)
230267
.logger(getLog());
231268
}

0 commit comments

Comments
 (0)