From commits-return-68684-archive-asf-public=cust-asf.ponee.io@sling.apache.org Mon Jul 2 13:59:01 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id E549C180626 for ; Mon, 2 Jul 2018 13:59:00 +0200 (CEST) Received: (qmail 10000 invoked by uid 500); 2 Jul 2018 11:59:00 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 9991 invoked by uid 99); 2 Jul 2018 11:59:00 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2018 11:59:00 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 618C082A8A; Mon, 2 Jul 2018 11:58:59 +0000 (UTC) Date: Mon, 02 Jul 2018 11:58:59 +0000 To: "commits@sling.apache.org" Subject: [sling-slingfeature-maven-plugin] branch master updated: Attach all features with classifiers to the project artifacts MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <153053273935.28454.4248324037829983083@gitbox.apache.org> From: davidb@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: sling-slingfeature-maven-plugin X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 13bc840fba9ee0c5d6345b81848b9fdcae23358d X-Git-Newrev: 60c1b192ad55ce1d44dc20af59c65d7671605473 X-Git-Rev: 60c1b192ad55ce1d44dc20af59c65d7671605473 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated 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 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 @@ - osgifeature-maven-plugin - 0.01.7-SNAPSHOT + slingfeature-maven-plugin + 0.2.0-SNAPSHOT maven-plugin Apache Sling OSGi Feature Maven Plugin @@ -36,11 +36,13 @@ ${project.artifactId}-archives/${project.artifactId}-LATEST + @@ -109,14 +111,24 @@ + org.apache.felix + org.apache.felix.converter + 1.0.0 + + + org.apache.sling + org.apache.sling.commons.johnzon + 1.0.0 + + org.apache.sling org.apache.sling.feature - 0.0.1-SNAPSHOT + 0.1.2 org.apache.sling org.apache.sling.feature.io - 0.0.1-SNAPSHOT + 0.1.2 org.apache.maven 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); + } + } + } }