This is an automated email from the ASF dual-hosted git repository.
cziegeler 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 4ccb588 SLING-8064 : Support marking a feature as final - allow to
mark an aggregate as final, add descriptions to some parameters
4ccb588 is described below
commit 4ccb58850ce788a139cffb4ab061192a8b2cc6da
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Wed Oct 31 15:06:37 2018 +0100
SLING-8064 : Support marking a feature as final - allow to mark an
aggregate as final, add descriptions to some parameters
---
.../apache/sling/feature/maven/ProjectHelper.java | 23 +++++++++++---
.../feature/maven/mojos/AggregateFeaturesMojo.java | 37 +++++++++++++++++++++-
2 files changed, 55 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/maven/ProjectHelper.java
b/src/main/java/org/apache/sling/feature/maven/ProjectHelper.java
index 60795df..d19811b 100644
--- a/src/main/java/org/apache/sling/feature/maven/ProjectHelper.java
+++ b/src/main/java/org/apache/sling/feature/maven/ProjectHelper.java
@@ -299,7 +299,11 @@ public abstract class ProjectHelper {
}
if ( key.startsWith(AGGREGATE_PREFIX) ) {
sb.append("aggregate ");
- sb.append(key.substring(AGGREGATE_PREFIX.length()));
+ if (key.length() == AGGREGATE_PREFIX.length()) {
+ sb.append("main artifact (no classifier)");
+ } else {
+ sb.append(key.substring(AGGREGATE_PREFIX.length()));
+ }
} else {
sb.append(key);
}
@@ -315,7 +319,7 @@ public abstract class ProjectHelper {
}
public static String generateAggregateFeatureKey(final String classifier) {
- return AGGREGATE_PREFIX.concat(classifier);
+ return classifier != null ? AGGREGATE_PREFIX.concat(classifier) :
AGGREGATE_PREFIX;
}
private static final String NULL_KEY = ":";
@@ -335,7 +339,7 @@ public abstract class ProjectHelper {
* @param project The maven project
*/
public static void validateFeatureClassifiers(final MavenProject project) {
- validateFeatureClassifiers(project, null);
+ validateFeatureClassifiers(project, false, null);
}
/**
@@ -345,6 +349,17 @@ public abstract class ProjectHelper {
*/
public static void validateFeatureClassifiers(final MavenProject project,
final String additionalClassifier) {
+ validateFeatureClassifiers(project, true, additionalClassifier);
+ }
+
+ /**
+ * Validate the classifiers in a project
+ *
+ * @param project The maven project
+ * @param additionalClassifier Optional additional classifier
+ */
+ private static void validateFeatureClassifiers(final MavenProject project,
final boolean classifierProvided,
+ final String additionalClassifier) {
final Map<String, List<String>> classifiers = new HashMap<>();
for(final Map.Entry<String, Feature> entry :
getFeatures(project).entrySet()) {
@@ -356,7 +371,7 @@ public abstract class ProjectHelper {
}
addClassifier(classifiers,
entry.getValue().getId().getClassifier(), entry.getKey());
}
- if ( additionalClassifier != null ) {
+ if (classifierProvided) {
final String key =
ProjectHelper.generateAggregateFeatureKey(additionalClassifier);
addClassifier(classifiers, additionalClassifier, key);
}
diff --git
a/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeaturesMojo.java
b/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeaturesMojo.java
index c742173..2020b90 100644
---
a/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeaturesMojo.java
+++
b/src/main/java/org/apache/sling/feature/maven/mojos/AggregateFeaturesMojo.java
@@ -67,12 +67,37 @@ import org.codehaus.plexus.util.AbstractScanner;
)
public class AggregateFeaturesMojo extends AbstractFeatureMojo {
+ /**
+ * The definition of the features used to create the new feature.
+ */
@Parameter(required = true)
List<FeatureConfig> aggregates;
- @Parameter(required = true)
+ /**
+ * This is the classifier for the new feature. If not specified the
feature is
+ * the main artifact for the project.
+ */
+ @Parameter
String aggregateClassifier;
+ /**
+ * If this is set to {@code true} the feature is marked as final.
+ */
+ @Parameter(defaultValue = "false")
+ private boolean markAsFinal;
+
+ /**
+ * Optional title for the feature
+ */
+ @Parameter
+ private String featureTitle;
+
+ /**
+ * Optional description for the feature
+ */
+ @Parameter
+ private String featureDescription;
+
@Parameter(required = false)
Map<String,String> variables;
@@ -154,6 +179,16 @@ public class AggregateFeaturesMojo extends
AbstractFeatureMojo {
project.getVersion(), aggregateClassifier,
FeatureConstants.PACKAGING_FEATURE);
final Feature result = FeatureBuilder.assemble(newFeatureID,
builderContext, featureMap.values().toArray(new Feature[] {}));
+ if (markAsFinal) {
+ result.setFinal(true);
+ }
+ if (featureTitle != null) {
+ result.setTitle(featureTitle);
+ }
+ if (featureDescription != null) {
+ result.setDescription(featureDescription);
+ }
+
ProjectHelper.setFeatureInfo(project, result);
// Add feature to map of features