SLING-9909 : Check/minimize embedded/shaded classes
diff --git a/pom.xml b/pom.xml
index 4be7295..ebed496 100644
--- a/pom.xml
+++ b/pom.xml
@@ -56,43 +56,17 @@
                         </goals>
                         <configuration>
                           <minimizeJar>true</minimizeJar>
-                          <filters>
-                            <filter>
-                              <includes>
-                                <include>org.apache.commons:collections:*</include>
-                              </includes>
-                            </filter>
-                          </filters>
                           <relocations>
                             <relocation>
-                              <pattern>javax.jcr</pattern>
-                              <shadedPattern>shaded.javax.jcr</shadedPattern>
-                              <includes>
-                                <include>javax.jcr.**</include>
-                              </includes>
+                              <pattern>org.apache.jackrabbit</pattern>
+                              <shadedPattern>shaded.org.apache.jackrabbit</shadedPattern>
                             </relocation>
                             <relocation>
-                              <pattern>org.slf4j</pattern>
-                              <shadedPattern>shaded.org.slf4j</shadedPattern>
-                              <includes>
-                                <include>org.slf4j.**</include>
-                              </includes>
+                              <pattern>org.apache.commons</pattern>
+                              <shadedPattern>shaded.org.apache.commons</shadedPattern>
                             </relocation>
-                            <relocation>
-                              <pattern>org.osgi</pattern>
-                              <shadedPattern>shaded.org.osgi</shadedPattern>
-                              <includes>
-                                <include>org.osgi.util.**</include>
-                              </includes>
-                            </relocation>
-                            <relocation>
-                              <pattern>org.apache</pattern>
-                              <shadedPattern>shaded.org.apache</shadedPattern>
-                              <excludes>
-                                <exclude>org.apache.sling.feature.**</exclude>
-                              </excludes>
-                            </relocation>
-                            <relocation>
+			    <!-- This is required for the OSGi configuration PIDs used in the code, otherwise they get shaded as well -->
+			    <relocation>
                               <pattern>org.UNSHADE.apache</pattern>
                               <shadedPattern>org.apache</shadedPattern>
                             </relocation>
@@ -114,9 +88,14 @@
     </build>
     <dependencies>
         <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>osgi.core</artifactId>
-            <version>6.0.0</version>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.feature</artifactId>
+            <version>1.2.14</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
@@ -127,73 +106,38 @@
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.feature</artifactId>
-            <version>1.2.14</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.feature.launcher</artifactId>
             <version>1.1.10</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-nop</artifactId>
-            <version>1.7.25</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.commons.johnzon</artifactId>
-            <version>1.0.0</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.converter</artifactId>
-            <version>1.0.0</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>org.apache.sling.jcr.jcr-wrapper</artifactId>
-            <version>2.0.0</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-spi-commons</artifactId>
             <version>2.17.3</version>
-            <groupId>org.apache.jackrabbit</groupId>
             <scope>compile</scope>
         </dependency>
         <dependency>
+            <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
             <version>2.6</version>
-            <groupId>commons-io</groupId>
             <scope>compile</scope>
         </dependency>
         <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.2.2</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-jcr-commons</artifactId>
             <version>2.17.3</version>
-            <groupId>org.apache.jackrabbit</groupId>
             <scope>compile</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
             <artifactId>jackrabbit-spi</artifactId>
             <version>2.17.3</version>
-            <groupId>org.apache.jackrabbit</groupId>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>commons-cli</groupId>
-            <artifactId>commons-cli</artifactId>
-            <version>1.3.1</version>
             <scope>compile</scope>
         </dependency>
         <!-- Testing -->
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 bd7bdad..5bfe091 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,10 +18,7 @@
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URL;
 import java.nio.file.Paths;
 import java.util.ArrayList;
@@ -32,7 +29,6 @@
 import java.util.Set;
 import java.util.TreeMap;
 
-import org.apache.commons.collections.map.MultiValueMap;
 import org.apache.jackrabbit.vault.packaging.PackageId;
 import org.apache.jackrabbit.vault.packaging.SubPackageHandling;
 import org.apache.jackrabbit.vault.packaging.registry.ExecutionPlanBuilder;
@@ -109,7 +105,7 @@
         File registryHome = getRegistryHomeDir(context);
         if (extension.getType() == ExtensionType.ARTIFACTS
                 && extension.getName().equals(Extension.EXTENSION_NAME_CONTENT_PACKAGES)) {
-            MultiValueMap orderedArtifacts = MultiValueMap.decorate(new TreeMap<Integer, Collection<Artifact>>());
+            Map<Integer, Collection<Artifact>> orderedArtifacts = new TreeMap<>();
             for (final Artifact a : extension.getArtifacts()) {
                 int order;
                 // content-packages without explicit start-order to be installed last
@@ -118,20 +114,19 @@
                 } else {
                     order = Integer.MAX_VALUE;
                 }
-                orderedArtifacts.put(order, a);
+                orderedArtifacts.computeIfAbsent(order, id -> new ArrayList<>()).add(a);
             }
             List<String> executionPlans = new ArrayList<String>();
             Set<PackageId> satisfiedPackages = new HashSet<>();
             for (Object key : orderedArtifacts.keySet()) {
-                @SuppressWarnings("unchecked")
-                Collection<Artifact> artifacts = orderedArtifacts.getCollection(key);
+                Collection<Artifact> artifacts = orderedArtifacts.get(key);
                 ExecutionPlanBuilder builder = buildExecutionPlan(artifacts, satisfiedPackages, context, registryHome);
                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
                 builder.save(baos);
                 executionPlans.add(baos.toString("UTF-8"));
             }
             // Workaround for too bold relocation mechanism - corresponding details at https://issues.apache.org/jira/browse/MSHADE-156
-            final Configuration initcfg = new Configuration("org.UNSHADE.apache.sling.jcr.packageinit.impl.ExecutionPlanRepoInitializer");
+            final Configuration initcfg = new Configuration("org.apache.sling.jcr.packageinit.impl.ExecutionPlanRepoInitializer");
             initcfg.getProperties().put("executionplans", executionPlans.toArray(new String[executionPlans.size()]));
             initcfg.getProperties().put("statusfilepath", registryHome.getAbsolutePath() + "/executedplans.file");
             context.addConfiguration(initcfg.getPid(), null, initcfg.getProperties());
@@ -141,8 +136,7 @@
             context.addConfiguration(registrycfg.getPid(), null, registrycfg.getProperties());
 
             return true;
-        }
-        else {
+        } else {
             return false;
         }
     }
diff --git a/src/test/java/org/apache/sling/feature/extension/content/ContentHandlerTest.java b/src/test/java/org/apache/sling/feature/extension/content/ContentHandlerTest.java
index 7e65070..e52a138 100644
--- a/src/test/java/org/apache/sling/feature/extension/content/ContentHandlerTest.java
+++ b/src/test/java/org/apache/sling/feature/extension/content/ContentHandlerTest.java
@@ -31,6 +31,7 @@
 import org.apache.sling.feature.Artifact;
 import org.apache.sling.feature.ArtifactId;
 import org.apache.sling.feature.Extension;
+import org.apache.sling.feature.ExtensionState;
 import org.apache.sling.feature.ExtensionType;
 import org.apache.sling.feature.launcher.spi.extensions.ExtensionContext;
 import org.junit.Before;
@@ -87,7 +88,7 @@
     public void testMultipleStartOrders() throws Exception {
         ContentHandler ch = new ContentHandler();
         System.setProperty(ContentHandler.PACKAGEREGISTRY_HOME, testFolder.getRoot().toString());
-        Extension ext = new Extension(ExtensionType.ARTIFACTS, "content-packages", false);
+        Extension ext = new Extension(ExtensionType.ARTIFACTS, "content-packages", ExtensionState.OPTIONAL);
         Artifact artifact_a = new Artifact(TEST_PACKAGE_AID_A_10);
         Artifact artifact_b = new Artifact(TEST_PACKAGE_AID_B_10);
         Artifact artifact_c = new Artifact(TEST_PACKAGE_AID_C_10);
@@ -101,7 +102,7 @@
         ArgumentCaptor<Dictionary<String, Object>> executionPlanCaptor = ArgumentCaptor.forClass(Dictionary.class);
 
         ch.handle(extensionContext, ext);
-        verify(extensionContext).addConfiguration(eq("org.UNSHADE.apache.sling.jcr.packageinit.impl.ExecutionPlanRepoInitializer"), any(), executionPlanCaptor.capture());
+        verify(extensionContext).addConfiguration(eq("org.apache.sling.jcr.packageinit.impl.ExecutionPlanRepoInitializer"), any(), executionPlanCaptor.capture());
         verify(extensionContext).addConfiguration(eq("org.UNSHADE.apache.jackrabbit.vault.packaging.registry.impl.FSPackageRegistry"), any(), any());
         Iterator<Dictionary<String, Object>> dictIt = executionPlanCaptor.getAllValues().iterator();
         Dictionary<String, Object> dict = dictIt.next();