sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [sling-org-apache-sling-feature-analyser] 04/28: SLING-7512 Order features based on their dependencies.
Date Fri, 27 Apr 2018 09:53:20 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-org-apache-sling-feature-analyser.git

commit af9e5d5fd72e210b6eadc985fd3fdeac5a6ef4a6
Author: David Bosschaert <bosschae@adobe.com>
AuthorDate: Fri Feb 23 13:42:28 2018 +0000

    SLING-7512 Order features based on their dependencies.
    
    Very initial implementation which contains the refactoring of
    Requirements and Capabilities to use the OSGi ones.
---
 pom.xml                                             | 14 +++++++-------
 .../apache/sling/feature/analyser/Descriptor.java   |  4 ++--
 .../feature/analyser/impl/BundleDescriptorImpl.java |  4 ++--
 .../task/impl/CheckRequirementsCapabilities.java    |  2 +-
 .../feature/scanner/impl/FelixFrameworkScanner.java |  2 +-
 .../sling/feature/scanner/impl/RepoInitScanner.java |  9 +++++----
 .../apache/sling/feature/analyser/AnalyserTest.java | 21 +++++++++++++++++++--
 7 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/pom.xml b/pom.xml
index 75533a8..735290e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -129,17 +129,17 @@
 		    <version>0.1.0-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
-      <!-- Testing -->
-        <dependency>
-        	<groupId>junit</groupId>
-        	<artifactId>junit</artifactId>
-        </dependency>
-
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.configurator</artifactId>
             <version>0.0.1-SNAPSHOT</version>
-            <scope>test</scope>
+            <scope>provided</scope>
+        </dependency>
+        
+        <!-- Testing -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
         </dependency>
     </dependencies>
 </project>
diff --git a/src/main/java/org/apache/sling/feature/analyser/Descriptor.java b/src/main/java/org/apache/sling/feature/analyser/Descriptor.java
index 145344d..d6237f8 100644
--- a/src/main/java/org/apache/sling/feature/analyser/Descriptor.java
+++ b/src/main/java/org/apache/sling/feature/analyser/Descriptor.java
@@ -20,9 +20,9 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.sling.feature.Capability;
-import org.apache.sling.feature.Requirement;
 import org.apache.sling.feature.support.util.PackageInfo;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Requirement;
 
 /**
  * A descriptor holds information about requirements and capabilities
diff --git a/src/main/java/org/apache/sling/feature/analyser/impl/BundleDescriptorImpl.java
b/src/main/java/org/apache/sling/feature/analyser/impl/BundleDescriptorImpl.java
index 1ed0ce2..abe2a97 100644
--- a/src/main/java/org/apache/sling/feature/analyser/impl/BundleDescriptorImpl.java
+++ b/src/main/java/org/apache/sling/feature/analyser/impl/BundleDescriptorImpl.java
@@ -22,13 +22,13 @@ import java.util.Set;
 import java.util.jar.Manifest;
 
 import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.Capability;
-import org.apache.sling.feature.Requirement;
 import org.apache.sling.feature.analyser.BundleDescriptor;
 import org.apache.sling.feature.support.util.ManifestParser;
 import org.apache.sling.feature.support.util.ManifestUtil;
 import org.apache.sling.feature.support.util.PackageInfo;
 import org.osgi.framework.Constants;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Requirement;
 
 /**
  * Information about a bundle
diff --git a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckRequirementsCapabilities.java
b/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckRequirementsCapabilities.java
index 0ea2799..6029a13 100644
--- a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckRequirementsCapabilities.java
+++ b/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckRequirementsCapabilities.java
@@ -23,12 +23,12 @@ import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.stream.Collectors;
 
-import org.apache.sling.feature.Requirement;
 import org.apache.sling.feature.analyser.ArtifactDescriptor;
 import org.apache.sling.feature.analyser.BundleDescriptor;
 import org.apache.sling.feature.analyser.task.AnalyserTask;
 import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
 import org.apache.sling.feature.support.util.CapabilityMatcher;
+import org.osgi.resource.Requirement;
 
 public class CheckRequirementsCapabilities implements AnalyserTask {
     private final String format = "Artifact %s:%s requires %s in start level %d but %s";
diff --git a/src/main/java/org/apache/sling/feature/scanner/impl/FelixFrameworkScanner.java
b/src/main/java/org/apache/sling/feature/scanner/impl/FelixFrameworkScanner.java
index eb2124a..ac8afa1 100644
--- a/src/main/java/org/apache/sling/feature/scanner/impl/FelixFrameworkScanner.java
+++ b/src/main/java/org/apache/sling/feature/scanner/impl/FelixFrameworkScanner.java
@@ -39,13 +39,13 @@ import java.util.zip.ZipInputStream;
 import org.apache.sling.commons.osgi.ManifestHeader;
 import org.apache.sling.feature.Artifact;
 import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Capability;
 import org.apache.sling.feature.KeyValueMap;
 import org.apache.sling.feature.analyser.BundleDescriptor;
 import org.apache.sling.feature.scanner.FrameworkScanner;
 import org.apache.sling.feature.support.util.PackageInfo;
 import org.apache.sling.feature.support.util.SubstVarUtil;
 import org.osgi.framework.Constants;
+import org.osgi.resource.Capability;
 
 public class FelixFrameworkScanner implements FrameworkScanner {
 
diff --git a/src/main/java/org/apache/sling/feature/scanner/impl/RepoInitScanner.java b/src/main/java/org/apache/sling/feature/scanner/impl/RepoInitScanner.java
index 7b4e221..d3cf11c 100644
--- a/src/main/java/org/apache/sling/feature/scanner/impl/RepoInitScanner.java
+++ b/src/main/java/org/apache/sling/feature/scanner/impl/RepoInitScanner.java
@@ -17,13 +17,15 @@
 package org.apache.sling.feature.scanner.impl;
 
 import java.io.IOException;
+import java.util.Collections;
 
 import org.apache.sling.feature.Extension;
 import org.apache.sling.feature.ExtensionType;
-import org.apache.sling.feature.Requirement;
+import org.apache.sling.feature.OSGiRequirement;
 import org.apache.sling.feature.analyser.ContainerDescriptor;
 import org.apache.sling.feature.scanner.ExtensionScanner;
 import org.apache.sling.feature.support.ArtifactManager;
+import org.osgi.resource.Requirement;
 
 public class RepoInitScanner implements ExtensionScanner {
 
@@ -50,9 +52,8 @@ public class RepoInitScanner implements ExtensionScanner {
 
         final ContainerDescriptor cd = new ContainerDescriptor() {};
 
-        final Requirement req = new Requirement("osgi.implementation");
-        req.getDirectives().put("filter",
-                "(&(osgi.implementation=org.apache.sling.jcr.repoinit)(version>=1.0)(!(version>=2.0)))");
+        final Requirement req = new OSGiRequirement("osgi.implementation", Collections.emptyMap(),
+            Collections.singletonMap("filter", "(&(osgi.implementation=org.apache.sling.jcr.repoinit)(version>=1.0)(!(version>=2.0)))"));
         cd.getRequirements().add(req);
 
         cd.lock();
diff --git a/src/test/java/org/apache/sling/feature/analyser/AnalyserTest.java b/src/test/java/org/apache/sling/feature/analyser/AnalyserTest.java
index 872ec3c..d92398a 100644
--- a/src/test/java/org/apache/sling/feature/analyser/AnalyserTest.java
+++ b/src/test/java/org/apache/sling/feature/analyser/AnalyserTest.java
@@ -20,6 +20,7 @@ import org.apache.sling.feature.Application;
 import org.apache.sling.feature.Feature;
 import org.apache.sling.feature.analyser.service.Analyser;
 import org.apache.sling.feature.analyser.service.Scanner;
+import org.apache.sling.feature.process.FeatureResolver;
 import org.apache.sling.feature.support.ArtifactManager;
 import org.apache.sling.feature.support.ArtifactManagerConfig;
 import org.apache.sling.feature.support.FeatureUtil;
@@ -28,6 +29,7 @@ import org.junit.Test;
 
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.util.List;
 
 import static junit.framework.TestCase.fail;
 
@@ -40,7 +42,8 @@ public class AnalyserTest {
                 "UTF-8") ) {
             Feature feature = FeatureJSONReader.read(reader, "feature");
 
-            Application app = FeatureUtil.assembleApplication(null, ArtifactManager.getArtifactManager(new
ArtifactManagerConfig()), feature);
+            Application app = FeatureUtil.assembleApplication(null, ArtifactManager.getArtifactManager(new
ArtifactManagerConfig()),
+                    getTestResolver(), feature);
 
             analyser.analyse(app);
         }
@@ -54,7 +57,8 @@ public class AnalyserTest {
                 "UTF-8") ) {
             Feature feature = FeatureJSONReader.read(reader, "feature");
 
-            Application app = FeatureUtil.assembleApplication(null, ArtifactManager.getArtifactManager(new
ArtifactManagerConfig()), feature);
+            Application app = FeatureUtil.assembleApplication(null, ArtifactManager.getArtifactManager(new
ArtifactManagerConfig()),
+                    getTestResolver(), feature);
 
             try {
                 analyser.analyse(app);
@@ -66,4 +70,17 @@ public class AnalyserTest {
             }
         }
     }
+
+    private FeatureResolver getTestResolver() {
+        return new FeatureResolver() {
+            @Override
+            public void close() throws Exception {
+            }
+
+            @Override
+            public List<Feature> orderFeatures(List<Feature> features) {
+                return features;
+            }
+        };
+    }
 }

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

Mime
View raw message