You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2019/05/02 09:02:03 UTC
[sling-slingfeature-maven-plugin] branch master updated: SLING-8382
: Add new mojo to include features in the artifact
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 2424614 SLING-8382 : Add new mojo to include features in the artifact
2424614 is described below
commit 242461461caa8e11449e88611594c75c1694d17b
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu May 2 11:01:52 2019 +0200
SLING-8382 : Add new mojo to include features in the artifact
---
...udeFeaturesMojo.java => EmbedFeaturesMojo.java} | 30 ++++++++++++++++------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/IncludeFeaturesMojo.java b/src/main/java/org/apache/sling/feature/maven/mojos/EmbedFeaturesMojo.java
similarity index 71%
rename from src/main/java/org/apache/sling/feature/maven/mojos/IncludeFeaturesMojo.java
rename to src/main/java/org/apache/sling/feature/maven/mojos/EmbedFeaturesMojo.java
index eebb8f6..8a12a42 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/IncludeFeaturesMojo.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/EmbedFeaturesMojo.java
@@ -20,6 +20,7 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
+import java.util.Map;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -32,15 +33,22 @@ import org.apache.sling.feature.io.json.FeatureJSONWriter;
import org.apache.sling.feature.maven.ProjectHelper;
/**
- * Include the features in the resources
+ * Embed the features in the resources
*/
-@Mojo(name = "include-features", defaultPhase = LifecyclePhase.PREPARE_PACKAGE,
+@Mojo(name = "embed-features", defaultPhase = LifecyclePhase.PREPARE_PACKAGE,
requiresDependencyResolution = ResolutionScope.TEST,
threadSafe = true
)
-public class IncludeFeaturesMojo extends AbstractFeatureMojo {
+public class EmbedFeaturesMojo extends AbstractIncludingFeatureMojo {
- /** Path where the features are included. */
+ /**
+ * Configuration to define the features to be embedded, by default all features
+ * are embedded.
+ */
+ @Parameter
+ private FeatureSelectionConfig embed;
+
+ /** Path where the features are embedded in the target/classes directory. */
@Parameter(defaultValue = "META-INF/features")
private String resourcesPath;
@@ -69,11 +77,17 @@ public class IncludeFeaturesMojo extends AbstractFeatureMojo {
public void execute() throws MojoExecutionException, MojoFailureException {
ProjectHelper.checkPreprocessorRun(this.project);
- getLog().info("Including features at " + this.resourcesPath);
+ final Map<String, Feature> features = embed == null ? this.selectAllFeatureFilesAndAggregates()
+ : this.getSelectedFeatures(embed);
+ if (features.isEmpty()) {
+ getLog().info("No features to embed");
+ } else {
+ getLog().info("Embedding " + features.size() + " features at " + this.resourcesPath);
- final File directory = new File(buildOutputDirectory, this.resourcesPath.replace('/', File.separatorChar));
- for (final Feature f : ProjectHelper.getFeatures(this.project).values()) {
- this.include(directory, f);
+ final File directory = new File(buildOutputDirectory, this.resourcesPath.replace('/', File.separatorChar));
+ for (final Feature f : features.values()) {
+ this.include(directory, f);
+ }
}
}
}