You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by da...@apache.org on 2018/04/27 09:58:41 UTC

[sling-org-apache-sling-feature-karaf] branch master created (now e604ee7)

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

davidb pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-karaf.git.


      at e604ee7  Use felix utils ResourceBuilder and Parser instead of the ManifestParser and ManifestUtil. As with that the feature-support module is empty, remove it.

This branch includes the following new commits:

     new ec3240a  Move feature model to whiteboard git
     new a8449c9  Start changing start level handling to start order handling
     new b99eabf  Update to parent pom 33
     new 9c48d90  Move artifact handling to separate package
     new b789dc0  Move Sling specific constants into support module
     new c8b53f6  Rename packages
     new d24a029  [Sling Feature Model] Split off IO packages into separate module.
     new 2f0812d  [Sling Feature Model] Move ConfigurationUtil to Karaf module
     new 67dbdd6  [Feature Model] Move constants from support module to feature module
     new fa822cf  [Feature Model] Remove SlingConstants
     new e604ee7  Use felix utils ResourceBuilder and Parser instead of the ManifestParser and ManifestUtil. As with that the feature-support module is empty, remove it.

The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.

[sling-org-apache-sling-feature-karaf] 02/11: Start changing start level handling to start order handling

Posted by da...@apache.org.
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-org-apache-sling-feature-karaf.git

commit a8449c9eab887f72d418be79f669f0ba241c4fb6
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Jan 18 16:14:50 2018 +0100

    Start changing start level handling to start order handling
---
 .../sling/feature/karaf/KarafFeatureWriter.java    | 24 +++++++++++-----------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
index 7402f04..d2e805a 100644
--- a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
+++ b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
@@ -16,16 +16,6 @@
  */
 package org.apache.sling.feature.karaf;
 
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Configuration;
-import org.apache.sling.feature.Configurations;
-import org.apache.sling.feature.Extension;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.support.ArtifactHandler;
-import org.apache.sling.feature.support.ArtifactManager;
-import org.apache.sling.feature.support.ConfigurationUtil;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -41,6 +31,16 @@ import java.util.Map;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
+import org.apache.sling.feature.Artifact;
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.Configuration;
+import org.apache.sling.feature.Configurations;
+import org.apache.sling.feature.Extension;
+import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.support.ArtifactHandler;
+import org.apache.sling.feature.support.ArtifactManager;
+import org.apache.sling.feature.support.ConfigurationUtil;
+
 
 /**
  * This writer writes out a Karaf feature XML.
@@ -99,7 +99,7 @@ public class KarafFeatureWriter {
 
                 jos.closeEntry();
 
-                for(final Map.Entry<Integer, List<Artifact>> entry : feature.getBundles().getBundlesByStartLevel().entrySet()) {
+                for(final Map.Entry<Integer, List<Artifact>> entry : feature.getBundles().getBundlesByStartOrder().entrySet()) {
                     for(final Artifact artifact : entry.getValue()) {
                         final ArtifactHandler handler = artifactManager.getArtifactHandler(artifact.getId().toMvnUrl());
 
@@ -180,7 +180,7 @@ public class KarafFeatureWriter {
         }
 
         // bundles
-        for(final Map.Entry<Integer, List<Artifact>> entry : feature.getBundles().getBundlesByStartLevel().entrySet()) {
+        for(final Map.Entry<Integer, List<Artifact>> entry : feature.getBundles().getBundlesByStartOrder().entrySet()) {
             for(final Artifact artifact : entry.getValue()) {
                 w.print("     <bundle start-level=\"");
                 w.print(entry.getKey().toString());

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.

[sling-org-apache-sling-feature-karaf] 11/11: Use felix utils ResourceBuilder and Parser instead of the ManifestParser and ManifestUtil. As with that the feature-support module is empty, remove it.

Posted by da...@apache.org.
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-org-apache-sling-feature-karaf.git

commit e604ee76604707684a51617192db75844a5b63ff
Author: Karl Pauls <kp...@adobe.com>
AuthorDate: Thu Apr 26 12:00:25 2018 +0200

    Use felix utils ResourceBuilder and Parser instead of the ManifestParser and ManifestUtil. As with that the feature-support module is empty, remove it.
---
 pom.xml | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/pom.xml b/pom.xml
index 315afec..6204869 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,11 +74,5 @@
             <version>0.0.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.feature.support</artifactId>
-            <version>0.0.1-SNAPSHOT</version>
-            <scope>provided</scope>
-        </dependency>
     </dependencies>
 </project>

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.

[sling-org-apache-sling-feature-karaf] 04/11: Move artifact handling to separate package

Posted by da...@apache.org.
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-org-apache-sling-feature-karaf.git

commit 9c48d9001797b5e5b936456e502bbbe63f779d10
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Apr 17 09:51:30 2018 +0200

    Move artifact handling to separate package
---
 src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
index d2e805a..38e0f74 100644
--- a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
+++ b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
@@ -37,9 +37,9 @@ import org.apache.sling.feature.Configuration;
 import org.apache.sling.feature.Configurations;
 import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.support.ArtifactHandler;
-import org.apache.sling.feature.support.ArtifactManager;
 import org.apache.sling.feature.support.ConfigurationUtil;
+import org.apache.sling.feature.support.artifact.ArtifactHandler;
+import org.apache.sling.feature.support.artifact.ArtifactManager;
 
 
 /**

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.

[sling-org-apache-sling-feature-karaf] 03/11: Update to parent pom 33

Posted by da...@apache.org.
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-org-apache-sling-feature-karaf.git

commit b99eabfe49f0bbd8a47b59868f088cdf66960c79
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Feb 26 13:24:32 2018 +0100

    Update to parent pom 33
---
 pom.xml | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4591599..450870a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,7 +17,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>32</version>
+        <version>33</version>
         <relativePath />
     </parent>
 
@@ -51,6 +51,18 @@
     </build>
     <dependencies>
         <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.annotation.versioning</artifactId>
+            <version>1.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.core</artifactId>
+            <version>6.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.feature</artifactId>
             <version>0.0.1-SNAPSHOT</version>
@@ -62,11 +74,5 @@
             <version>0.0.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>osgi.core</artifactId>
-            <version>6.0.0</version>
-            <scope>provided</scope>
-        </dependency>
     </dependencies>
 </project>

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.

[sling-org-apache-sling-feature-karaf] 08/11: [Sling Feature Model] Move ConfigurationUtil to Karaf module

Posted by da...@apache.org.
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-org-apache-sling-feature-karaf.git

commit 2f0812d035394c7b5805664910361415eb775a38
Author: David Bosschaert <da...@gmail.com>
AuthorDate: Wed Apr 25 11:02:09 2018 +0100

    [Sling Feature Model] Move ConfigurationUtil to Karaf module
    
    ConfigurationUtil is only used by the Karaf module, so move it there.
---
 .../sling/feature/karaf/ConfigurationUtil.java     | 87 ++++++++++++++++++++++
 .../sling/feature/karaf/KarafFeatureWriter.java    |  1 -
 2 files changed, 87 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/feature/karaf/ConfigurationUtil.java b/src/main/java/org/apache/sling/feature/karaf/ConfigurationUtil.java
new file mode 100644
index 0000000..e29e7a9
--- /dev/null
+++ b/src/main/java/org/apache/sling/feature/karaf/ConfigurationUtil.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.karaf;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.Map;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+import org.apache.sling.feature.Configurations;
+import org.apache.sling.feature.io.json.ConfigurationJSONWriter;
+import org.osgi.framework.Constants;
+
+
+public class ConfigurationUtil {
+
+    public static final String REQUIRE_CONFIGURATOR_CAPABILITY =
+            "osgi.extender;filter:=\"(&(osgi.extender=osgi.configurator)(version>=1.0)(!(version>=2.0)))\"";
+
+    /**
+     * Create a bundle containing the configurations to be processed the
+     * OSGi configurator
+     *
+     * @param os The output stream. The stream is not closed
+     * @param configurations The list of configurations
+     * @param symbolicName The symbolic name for the generated bundle
+     * @param version The version for the generated bundle
+     * @param additionalAttributes Optional additional attributes for the Manifest.
+     * @throws IOException If something goes wrong
+     */
+    public static void createConfiguratorBundle(final OutputStream os,
+            final Configurations configurations,
+            final String symbolicName,
+            final String version,
+            final Map<String, String> additionalAttributes)
+    throws IOException {
+
+        final Manifest mf = new Manifest();
+        mf.getMainAttributes().putValue("Manifest-Version", "1.0");
+        mf.getMainAttributes().putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
+        mf.getMainAttributes().putValue(Constants.BUNDLE_SYMBOLICNAME, symbolicName);
+        mf.getMainAttributes().putValue(Constants.BUNDLE_VERSION, version);
+        mf.getMainAttributes().putValue(Constants.BUNDLE_VENDOR, "The Apache Software Foundation");
+        mf.getMainAttributes().putValue(Constants.REQUIRE_CAPABILITY, REQUIRE_CONFIGURATOR_CAPABILITY);
+
+        if ( additionalAttributes != null ) {
+            for(final Map.Entry<String, String> entry : additionalAttributes.entrySet()) {
+                if ( Constants.REQUIRE_CAPABILITY.equals(entry.getKey())
+                    && !entry.getValue().contains("osgi.extender=osgi.configurator")) {
+                    mf.getMainAttributes().putValue(entry.getKey(), entry.getValue() + "," + REQUIRE_CONFIGURATOR_CAPABILITY);
+                } else {
+                    mf.getMainAttributes().putValue(entry.getKey(), entry.getValue());
+                }
+            }
+        }
+
+        final JarOutputStream jos = new JarOutputStream(os, mf);
+
+        final ZipEntry ze = new ZipEntry("OSGI-INF/configurator/configurations.json");
+        jos.putNextEntry(ze);
+        final Writer w = new OutputStreamWriter(jos, "UTF-8");
+        ConfigurationJSONWriter.write(w, configurations);
+        w.flush();
+        jos.closeEntry();
+
+        jos.flush();
+        jos.finish();
+    }
+}
diff --git a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
index d6e426e..990fc0c 100644
--- a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
+++ b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
@@ -39,7 +39,6 @@ import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.Feature;
 import org.apache.sling.feature.io.ArtifactHandler;
 import org.apache.sling.feature.io.ArtifactManager;
-import org.apache.sling.feature.support.ConfigurationUtil;
 import org.apache.sling.feature.support.SlingConstants;
 
 

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.

[sling-org-apache-sling-feature-karaf] 09/11: [Feature Model] Move constants from support module to feature module

Posted by da...@apache.org.
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-org-apache-sling-feature-karaf.git

commit 67dbdd6603eeeba86c7fc2f40585617f35c72c30
Author: David Bosschaert <da...@gmail.com>
AuthorDate: Thu Apr 26 09:50:10 2018 +0100

    [Feature Model] Move constants from support module to feature module
    
    EXTENSION_NAME_REPOINIT and EXTENSION_NAME_CONTENT_PACKAGES were moved
    from SlingConstants in feature-support to FeatureConstants in feature.
---
 .../sling/feature/karaf/KarafFeatureWriter.java    | 23 +++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
index 990fc0c..dc00bc1 100644
--- a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
+++ b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
@@ -16,6 +16,17 @@
  */
 package org.apache.sling.feature.karaf;
 
+import org.apache.sling.feature.Artifact;
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.Configuration;
+import org.apache.sling.feature.Configurations;
+import org.apache.sling.feature.Extension;
+import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.FeatureConstants;
+import org.apache.sling.feature.io.ArtifactHandler;
+import org.apache.sling.feature.io.ArtifactManager;
+import org.apache.sling.feature.support.SlingConstants;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -31,16 +42,6 @@ import java.util.Map;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Configuration;
-import org.apache.sling.feature.Configurations;
-import org.apache.sling.feature.Extension;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.io.ArtifactHandler;
-import org.apache.sling.feature.io.ArtifactManager;
-import org.apache.sling.feature.support.SlingConstants;
-
 
 /**
  * This writer writes out a Karaf feature XML.
@@ -53,7 +54,7 @@ public class KarafFeatureWriter {
             final ArtifactManager artifactManager)
     throws IOException {
         // check for repoinit extension
-        final Extension repoinitExt = feature.getExtensions().getByName(SlingConstants.EXTENSION_NAME_REPOINIT);
+        final Extension repoinitExt = feature.getExtensions().getByName(FeatureConstants.EXTENSION_NAME_REPOINIT);
         File configurationBundleFile = null;
         Artifact configuratorBundle = null;
         try {

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.

[sling-org-apache-sling-feature-karaf] 07/11: [Sling Feature Model] Split off IO packages into separate module.

Posted by da...@apache.org.
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-org-apache-sling-feature-karaf.git

commit d24a02991892c8793132e1ca847a051c6317f0ee
Author: David Bosschaert <da...@gmail.com>
AuthorDate: Wed Apr 25 10:58:43 2018 +0100

    [Sling Feature Model] Split off IO packages into separate module.
---
 pom.xml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pom.xml b/pom.xml
index 450870a..315afec 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,6 +70,12 @@
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.feature.io</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.feature.support</artifactId>
             <version>0.0.1-SNAPSHOT</version>
             <scope>provided</scope>

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.

[sling-org-apache-sling-feature-karaf] 01/11: Move feature model to whiteboard git

Posted by da...@apache.org.
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-org-apache-sling-feature-karaf.git

commit ec3240adcf8df0dce4044e90968dffb10cc70194
Author: Carsten Ziegeler <cz...@adobe.com>
AuthorDate: Fri Nov 3 15:06:50 2017 +0100

    Move feature model to whiteboard git
---
 pom.xml                                            |  72 ++++++++
 .../sling/feature/karaf/KarafFeatureWriter.java    | 195 +++++++++++++++++++++
 .../apache/sling/feature/karaf/package-info.java   |  23 +++
 3 files changed, 290 insertions(+)

diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..4591599
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+    <!--
+        Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+        agreements. See the NOTICE file distributed with this work for additional information
+        regarding copyright ownership. The ASF licenses this file to you under the Apache License,
+        Version 2.0 (the "License"); you may not use this file except in compliance with the
+        License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+
+        Unless required by applicable law or agreed to in writing, software distributed under the
+        License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+        either express or implied. See the License for the specific language governing permissions
+        and limitations under the License.
+    -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>32</version>
+        <relativePath />
+    </parent>
+
+    <artifactId>org.apache.sling.feature.karaf</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <name>Apache Sling Feature Karaf</name>
+    <description>
+        A feature describes an OSGi system
+    </description>
+
+    <properties>
+        <sling.java.version>8</sling.java.version>
+    </properties>
+
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/tooling/support/feature-karaf</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/tooling/support/feature-karaf</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/tooling/support/feature-karaf</url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.feature</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.feature.support</artifactId>
+            <version>0.0.1-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.core</artifactId>
+            <version>6.0.0</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
new file mode 100644
index 0000000..7402f04
--- /dev/null
+++ b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
@@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.karaf;
+
+import org.apache.sling.feature.Artifact;
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.Configuration;
+import org.apache.sling.feature.Configurations;
+import org.apache.sling.feature.Extension;
+import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.support.ArtifactHandler;
+import org.apache.sling.feature.support.ArtifactManager;
+import org.apache.sling.feature.support.ConfigurationUtil;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+
+/**
+ * This writer writes out a Karaf feature XML.
+ *
+ */
+public class KarafFeatureWriter {
+
+    public static void writeKAR(final OutputStream os,
+            final Feature feature,
+            final ArtifactManager artifactManager)
+    throws IOException {
+        // check for repoinit extension
+        final Extension repoinitExt = feature.getExtensions().getByName(Extension.NAME_REPOINIT);
+        File configurationBundleFile = null;
+        Artifact configuratorBundle = null;
+        try {
+            final Configurations configs = new Configurations();
+            configs.addAll(feature.getConfigurations());
+            if ( repoinitExt != null ) {
+                final Configuration cfg = new Configuration("org.apache.sling.jcr.repoinit.RepositoryInitializer",
+                        "feature-" + feature.getId().getArtifactId());
+                cfg.getProperties().put("scripts", repoinitExt.getText());
+                configs.add(cfg);
+            }
+            if ( !configs.isEmpty() ) {
+                configurationBundleFile = Files.createTempFile(null, null).toFile();
+
+                try ( final FileOutputStream fos = new FileOutputStream(configurationBundleFile)) {
+                    final Map<String, String> map;
+                    if ( repoinitExt == null ) {
+                        map = null;
+                    } else {
+                        map = Collections.singletonMap("Require-Capability",
+                                ConfigurationUtil.REQUIRE_REPOINIT_CAPABILITY);
+                    }
+                    ConfigurationUtil.createConfiguratorBundle(os,
+                            configs,
+                            feature.getId().getGroupId() + "." + feature.getId().getArtifactId(),
+                            feature.getId().getOSGiVersion().toString(),
+                            map);
+                    configuratorBundle = new Artifact(new ArtifactId(feature.getId().getGroupId(),
+                            feature.getId().getArtifactId(),
+                            feature.getId().getVersion(), "configurator", null));
+                }
+            }
+
+            try ( final ZipOutputStream jos = new ZipOutputStream(os) ) {
+                // repository/features.xml
+                // repository/{maven-path-to-bundle}
+                final ZipEntry xmlEntry = new ZipEntry("repository/features.xml");
+                jos.putNextEntry(xmlEntry);
+
+                final Writer writer = new OutputStreamWriter(jos);
+                writeFeaturesXML(writer, feature, configuratorBundle);
+                writer.flush();
+
+                jos.closeEntry();
+
+                for(final Map.Entry<Integer, List<Artifact>> entry : feature.getBundles().getBundlesByStartLevel().entrySet()) {
+                    for(final Artifact artifact : entry.getValue()) {
+                        final ArtifactHandler handler = artifactManager.getArtifactHandler(artifact.getId().toMvnUrl());
+
+                        addEntry(jos, artifact, handler.getFile());
+                    }
+                }
+
+                if ( configuratorBundle != null ) {
+                    addEntry(jos, configuratorBundle, configurationBundleFile);
+                }
+            }
+        } finally {
+            if ( configurationBundleFile != null ) {
+                configurationBundleFile.delete();
+            }
+        }
+    }
+
+    private static void addEntry(final ZipOutputStream jos, final Artifact artifact, final File file)
+    throws IOException {
+        final ZipEntry bundleEntry = new ZipEntry("repository/" + artifact.getId().toMvnPath());
+        jos.putNextEntry(bundleEntry);
+
+        final byte[] buffer = new byte[16384];
+        try ( final FileInputStream fis = new FileInputStream(file)) {
+            int l = 0;
+            while ( (l = fis.read(buffer)) > 0 ) {
+                jos.write(buffer, 0, l);
+            }
+        }
+
+        jos.closeEntry();
+    }
+
+    /**
+     * Writes the feature XML to the writer.
+     * The writer is not closed.
+     * @param writer Writer
+     * @param model Model
+     * @throws IOException
+     */
+    private static void writeFeaturesXML(final Writer writer,
+            final Feature feature,
+            final Artifact configuratorBundle)
+    throws IOException {
+        final PrintWriter w = new PrintWriter(writer);
+
+        w.print("<features name=\"");
+        w.print(feature.getId().getArtifactId());
+        w.print("-repo-");
+        w.print(feature.getId().getVersion());
+        w.println("\" xmlns=\"http://karaf.apache.org/xmlns/features/v1.4.0\">");
+
+        write(w, feature, configuratorBundle);
+
+        w.println("</features>");
+        w.flush();
+    }
+
+    private static void write(final PrintWriter w, final Feature feature, final Artifact configuratorBundle)
+    throws IOException {
+        w.print("  <feature name=\"");
+        w.print(feature.getId().getGroupId());
+        w.print('.');
+        w.print(feature.getId().getArtifactId());
+        if ( feature.getId().getClassifier() != null ) {
+            w.print('.');
+            w.print(feature.getId().getClassifier());
+        }
+        w.print("\" version=\"");
+        w.print(feature.getId().getVersion());
+        w.println("\">");
+
+        if ( configuratorBundle != null ) {
+            w.print("     <bundle start-level=\"1\">");
+            w.print(configuratorBundle.getId().toMvnUrl());
+            w.println("</bundle>");
+        }
+
+        // bundles
+        for(final Map.Entry<Integer, List<Artifact>> entry : feature.getBundles().getBundlesByStartLevel().entrySet()) {
+            for(final Artifact artifact : entry.getValue()) {
+                w.print("     <bundle start-level=\"");
+                w.print(entry.getKey().toString());
+                w.print("\">");
+                w.print(artifact.getId().toMvnUrl());
+                w.println("</bundle>");
+            }
+        }
+
+        w.println("  </feature>");
+    }
+}
diff --git a/src/main/java/org/apache/sling/feature/karaf/package-info.java b/src/main/java/org/apache/sling/feature/karaf/package-info.java
new file mode 100644
index 0000000..76136a3
--- /dev/null
+++ b/src/main/java/org/apache/sling/feature/karaf/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+@org.osgi.annotation.versioning.Version("1.0.0")
+package org.apache.sling.feature.karaf;
+
+

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.

[sling-org-apache-sling-feature-karaf] 10/11: [Feature Model] Remove SlingConstants

Posted by da...@apache.org.
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-org-apache-sling-feature-karaf.git

commit fa822cf72d7414e1762531111c95d143eca0c557
Author: David Bosschaert <da...@gmail.com>
AuthorDate: Thu Apr 26 09:54:15 2018 +0100

    [Feature Model] Remove SlingConstants
    
    The 2 constants left in SlingConstants were only used once. Moved them
    to the place they were used. With this the
    org.apache.sling.feature.support package is now empty. I removed the
    pacakge-info.java as well.
---
 .../java/org/apache/sling/feature/karaf/KarafFeatureWriter.java    | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
index dc00bc1..6bea0f7 100644
--- a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
+++ b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
@@ -25,7 +25,6 @@ import org.apache.sling.feature.Feature;
 import org.apache.sling.feature.FeatureConstants;
 import org.apache.sling.feature.io.ArtifactHandler;
 import org.apache.sling.feature.io.ArtifactManager;
-import org.apache.sling.feature.support.SlingConstants;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -48,6 +47,9 @@ import java.util.zip.ZipOutputStream;
  *
  */
 public class KarafFeatureWriter {
+    private static final String REQUIRE_REPOINIT_CAPABILITY =
+            "osgi.implementation;filter:=\"(&(osgi.implementation=org.apache.sling.jcr.repoinit)(version>=1.0)(!(version>=2.0)))\"";
+
 
     public static void writeKAR(final OutputStream os,
             final Feature feature,
@@ -74,8 +76,7 @@ public class KarafFeatureWriter {
                     if ( repoinitExt == null ) {
                         map = null;
                     } else {
-                        map = Collections.singletonMap("Require-Capability",
-                                SlingConstants.REQUIRE_REPOINIT_CAPABILITY);
+                        map = Collections.singletonMap("Require-Capability", REQUIRE_REPOINIT_CAPABILITY);
                     }
                     ConfigurationUtil.createConfiguratorBundle(os,
                             configs,

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.

[sling-org-apache-sling-feature-karaf] 06/11: Rename packages

Posted by da...@apache.org.
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-org-apache-sling-feature-karaf.git

commit c8b53f65edea3752ca841788202b777fed24ed00
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Apr 18 10:26:45 2018 +0200

    Rename packages
---
 src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
index 14f8000..d6e426e 100644
--- a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
+++ b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
@@ -37,10 +37,10 @@ import org.apache.sling.feature.Configuration;
 import org.apache.sling.feature.Configurations;
 import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.io.ArtifactHandler;
+import org.apache.sling.feature.io.ArtifactManager;
 import org.apache.sling.feature.support.ConfigurationUtil;
 import org.apache.sling.feature.support.SlingConstants;
-import org.apache.sling.feature.support.artifact.ArtifactHandler;
-import org.apache.sling.feature.support.artifact.ArtifactManager;
 
 
 /**

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.

[sling-org-apache-sling-feature-karaf] 05/11: Move Sling specific constants into support module

Posted by da...@apache.org.
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-org-apache-sling-feature-karaf.git

commit b789dc03c5d2b3abd76f6e107e8c7885705838aa
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Apr 17 10:31:04 2018 +0200

    Move Sling specific constants into support module
---
 src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
index 38e0f74..14f8000 100644
--- a/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
+++ b/src/main/java/org/apache/sling/feature/karaf/KarafFeatureWriter.java
@@ -38,6 +38,7 @@ import org.apache.sling.feature.Configurations;
 import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.Feature;
 import org.apache.sling.feature.support.ConfigurationUtil;
+import org.apache.sling.feature.support.SlingConstants;
 import org.apache.sling.feature.support.artifact.ArtifactHandler;
 import org.apache.sling.feature.support.artifact.ArtifactManager;
 
@@ -53,7 +54,7 @@ public class KarafFeatureWriter {
             final ArtifactManager artifactManager)
     throws IOException {
         // check for repoinit extension
-        final Extension repoinitExt = feature.getExtensions().getByName(Extension.NAME_REPOINIT);
+        final Extension repoinitExt = feature.getExtensions().getByName(SlingConstants.EXTENSION_NAME_REPOINIT);
         File configurationBundleFile = null;
         Artifact configuratorBundle = null;
         try {
@@ -74,7 +75,7 @@ public class KarafFeatureWriter {
                         map = null;
                     } else {
                         map = Collections.singletonMap("Require-Capability",
-                                ConfigurationUtil.REQUIRE_REPOINIT_CAPABILITY);
+                                SlingConstants.REQUIRE_REPOINIT_CAPABILITY);
                     }
                     ConfigurationUtil.createConfiguratorBundle(os,
                             configs,

-- 
To stop receiving notification emails like this one, please contact
davidb@apache.org.