This is an automated email from the ASF dual-hosted git repository.

davidb pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-slingfeature-maven-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 002c9ef  Allow variables to be overridden/specified when aggregation.
002c9ef is described below

commit 002c9ef2a844b88c2fe63223fe58f65658092c3a
Author: David Bosschaert <[email protected]>
AuthorDate: Thu Sep 6 13:40:54 2018 +0100

    Allow variables to be overridden/specified when aggregation.
---
 README.md                                              | 15 +++++++++++++++
 .../sling/feature/maven/mojos/AggregateFeatures.java   | 18 ++++++++++++++++--
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index d894000..35a8a2b 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,15 @@ Sample configuration:
               <classifier>someclassifier</classifier>
             </artifact>
           </features>
+          <variables>
+            <!-- Feature variables can be specified/overridden here -->
+            <https.port>8443</https.port>
+            <some.variable/> <!-- set some.variable to null -->
+          </variables>
+          <frameworkProperties>
+            <!-- Framework property overrides go here -->
+            
<org.osgi.framework.bootdelegation>sun.*,com.sun.*</org.osgi.framework.bootdelegation>
+          </frameworkProperties>
         </configuration>
       </execution>
     </executions>
@@ -59,6 +68,12 @@ The merged feature will have the same `groupId`, 
`artifactId` and `version` as t
 the aggregation is configured. It will have type `slingfeature` and as 
classifier the one specified 
 in the configuration.
 
+Variables and framework properties can be overridden using the `<variables>` 
and 
+`<fraweworkProperties>` sections. If multiple definitions of the same 
variables are found
+in the feature that are to be aggregated and the values for these variables 
are different,
+they *must* be overridden, otherwise the aggregation will generate an error.
+
+
 #### Extension merging
 
 Merging of extensions is specific to the extension being merged. Handlers can 
be provided to implement the logic of extension merging. A handler needs to 
implement the `org.apache.sling.feature.builder.FeatureExtensionHandler` and is 
looked up via the Java ServiceLoader mechanism.
diff --git 
a/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeatures.java 
b/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeatures.java
index ca4f6cb..e97a3d1 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeatures.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeatures.java
@@ -30,6 +30,7 @@ import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.repository.RepositorySystem;
 import org.apache.sling.feature.ArtifactId;
 import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.KeyValueMap;
 import org.apache.sling.feature.builder.BuilderContext;
 import org.apache.sling.feature.builder.FeatureBuilder;
 import org.apache.sling.feature.builder.FeatureExtensionHandler;
@@ -70,6 +71,12 @@ public class AggregateFeatures extends AbstractFeatureMojo {
     @Parameter(required = true)
     List<FeatureConfig> features;
 
+    @Parameter(required = false)
+    Map<String,String> variables;
+
+    @Parameter(required = false)
+    Map<String,String> frameworkProperties;
+
     @Parameter(property = "project.remoteArtifactRepositories", readonly = 
true, required = true)
     List<ArtifactRepository> remoteRepositories;
 
@@ -90,6 +97,12 @@ public class AggregateFeatures extends AbstractFeatureMojo {
 
         Map<ArtifactId, Feature> featureMap = readFeatures(features, 
contextFeatures);
 
+        KeyValueMap variableOverrides = new KeyValueMap();
+        if (variables != null) {
+            for (Map.Entry<String, String> entry : variables.entrySet()) {
+                variableOverrides.put(entry.getKey(), entry.getValue());
+            }
+        }
         BuilderContext builderContext = new BuilderContext(new 
FeatureProvider() {
             @Override
             public Feature provide(ArtifactId id) {
@@ -110,9 +123,10 @@ public class AggregateFeatures extends AbstractFeatureMojo 
{
                     throw new RuntimeException("Cannot find feature: " + id, 
e);
                 }
             }
-        }).add(StreamSupport.stream(Spliterators.spliteratorUnknownSize(
+        }, variableOverrides, frameworkProperties)
+            .add(StreamSupport.stream(Spliterators.spliteratorUnknownSize(
                 ServiceLoader.load(FeatureExtensionHandler.class).iterator(), 
Spliterator.ORDERED), false)
-                .toArray(FeatureExtensionHandler[]::new));
+            .toArray(FeatureExtensionHandler[]::new));
 
         ArtifactId newFeatureID = new ArtifactId(project.getGroupId(), 
project.getArtifactId(),
                 project.getVersion(), classifier, 
FeatureConstants.PACKAGING_FEATURE);

Reply via email to