SLING-8215 - adding the missing support for multilevel nesting of subpackages
diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
index 5859c0a..5c9b2a8 100644
--- a/dependency-reduced-pom.xml
+++ b/dependency-reduced-pom.xml
@@ -148,6 +148,7 @@
     </dependency>

   </dependencies>

   <properties>

+    <surefire.plugin.version>3.0.0-M3</surefire.plugin.version>

     <jdk.version>8</jdk.version>

   </properties>

 </project>

diff --git a/pom.xml b/pom.xml
index 47c96a7..713db08 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,6 +40,7 @@
 
     <properties>
         <jdk.version>8</jdk.version>
+        <surefire.plugin.version>3.0.0-M3</surefire.plugin.version>
     </properties>
 
 
diff --git a/src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java b/src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java
index 673d626..8c2cd40 100644
--- a/src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java
+++ b/src/main/java/org/apache/sling/feature/extension/content/ContentHandler.java
@@ -18,6 +18,7 @@
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.IOException;
 import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -71,15 +72,7 @@
 
         for (File pkgFile : packageReferences) {
             PackageId pid = registry.registerExternal(pkgFile, true);
-            Map<PackageId, SubPackageHandling.Option> subPkgs = registry.getInstallState(pid).getSubPackages();
-            if (!subPkgs.isEmpty()) {
-                for (PackageId subId : subPkgs.keySet()) {
-                    SubPackageHandling.Option opt = subPkgs.get(subId);
-                    if (opt != SubPackageHandling.Option.IGNORE) {
-                        builder.addTask().with(subId).with(Type.EXTRACT);
-                    }
-                }
-            }
+            extractSubPackages(registry, builder, pid);
 
             builder.addTask().with(pid).with(Type.EXTRACT);
         }
@@ -89,6 +82,20 @@
 
     }
 
+    private static void extractSubPackages(FSPackageRegistry registry, ExecutionPlanBuilder builder, PackageId pid)
+            throws IOException {
+        Map<PackageId, SubPackageHandling.Option> subPkgs = registry.getInstallState(pid).getSubPackages();
+        if (!subPkgs.isEmpty()) {
+            for (PackageId subId : subPkgs.keySet()) {
+                SubPackageHandling.Option opt = subPkgs.get(subId);
+                if (opt != SubPackageHandling.Option.IGNORE) {
+                    builder.addTask().with(subId).with(Type.EXTRACT);
+                    extractSubPackages(registry, builder, subId);
+                }
+            }
+        }
+    }
+
     @Override
     public boolean handle(Extension extension, LauncherPrepareContext prepareContext,
             ExtensionInstallationContext installationContext) throws Exception {