sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [sling-slingfeature-maven-plugin] branch master updated: Attach all features with classifiers to the project artifacts
Date Mon, 02 Jul 2018 11:58:59 GMT
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 60c1b19  Attach all features with classifiers to the project artifacts
60c1b19 is described below

commit 60c1b192ad55ce1d44dc20af59c65d7671605473
Author: David Bosschaert <bosschae@adobe.com>
AuthorDate: Mon Jul 2 12:55:01 2018 +0100

    Attach all features with classifiers to the project artifacts
---
 pom.xml                                              | 20 ++++++++++++++++----
 .../sling/feature/maven/mojos/AttachFeature.java     | 18 ++++++++++++++++++
 2 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 0d099b6..8a97156 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,8 +21,8 @@
         <relativePath />
     </parent>
 
-    <artifactId>osgifeature-maven-plugin</artifactId>
-    <version>0.01.7-SNAPSHOT</version>
+    <artifactId>slingfeature-maven-plugin</artifactId>
+    <version>0.2.0-SNAPSHOT</version>
     <packaging>maven-plugin</packaging>
 
     <name>Apache Sling OSGi Feature Maven Plugin</name>
@@ -36,11 +36,13 @@
         <maven.site.path>${project.artifactId}-archives/${project.artifactId}-LATEST</maven.site.path>
     </properties>
 
+    <!-- 
     <scm>
         <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/maven/osgifeature-maven-plugin</connection>
         <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/maven/osgifeature-maven-plugin</developerConnection>
         <url>http://svn.apache.org/viewvc/sling/trunk/tooling/maven/osgifeature-maven-plugin</url>
     </scm>
+    -->
 
     <!-- Support for publishing the mvn site. -->
     <distributionManagement>
@@ -109,14 +111,24 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.converter</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.johnzon</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.feature</artifactId>
-            <version>0.0.1-SNAPSHOT</version>
+            <version>0.1.2</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.feature.io</artifactId>
-            <version>0.0.1-SNAPSHOT</version>
+            <version>0.1.2</version>
         </dependency>
         <dependency>
             <groupId>org.apache.maven</groupId>
diff --git a/src/main/java/org/apache/sling/feature/maven/mojos/AttachFeature.java b/src/main/java/org/apache/sling/feature/maven/mojos/AttachFeature.java
index 2cf38ff..e0942db 100644
--- a/src/main/java/org/apache/sling/feature/maven/mojos/AttachFeature.java
+++ b/src/main/java/org/apache/sling/feature/maven/mojos/AttachFeature.java
@@ -22,11 +22,14 @@ import org.apache.maven.plugins.annotations.LifecyclePhase;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.io.json.FeatureJSONReader;
+import org.apache.sling.feature.io.json.FeatureJSONReader.SubstituteVariables;
 import org.apache.sling.feature.io.json.FeatureJSONWriter;
 import org.apache.sling.feature.maven.FeatureConstants;
 import org.apache.sling.feature.maven.ProjectHelper;
 
 import java.io.File;
+import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.Writer;
@@ -73,5 +76,20 @@ public class AttachFeature extends AbstractFeatureMojo {
     public void execute() throws MojoExecutionException, MojoFailureException {
         attach(ProjectHelper.getFeature(this.project), FeatureConstants.FEATURE_ARTIFACT_NAME,
FeatureConstants.CLASSIFIER_FEATURE);
         attach(ProjectHelper.getTestFeature(this.project), FeatureConstants.TEST_FEATURE_ARTIFACT_NAME,
FeatureConstants.CLASSIFIER_TEST_FEATURE);
+
+        // Find all features that have a classifier and attach each of them
+        String processedFeatures = project.getBuild().getDirectory() + "/features/processed";
+        for (File f : new File(processedFeatures).listFiles((d,f) -> f.endsWith(".json")))
{
+            try {
+                Feature feat = FeatureJSONReader.read(new FileReader(f), null, SubstituteVariables.NONE);
+                String classifier = feat.getId().getClassifier();
+                if (classifier == null || classifier.length() == 0)
+                    continue;
+                projectHelper.attachArtifact(project, FeatureConstants.PACKAGING_FEATURE,
classifier, f);
+            } catch (IOException e) {
+                throw new MojoExecutionException("Unable to attach embedded features", e);
+            }
+        }
+
     }
 }


Mime
View raw message