[DOSGI-229] Optimize packaging
diff --git a/cxf-dosgi-ri-repository/pom.xml b/cxf-dosgi-ri-repository/pom.xml
new file mode 100644
index 0000000..7e12753
--- /dev/null
+++ b/cxf-dosgi-ri-repository/pom.xml
@@ -0,0 +1,85 @@
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.cxf.dosgi</groupId>
+        <artifactId>cxf-dosgi-ri-parent</artifactId>
+        <version>1.8-SNAPSHOT</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+    <artifactId>cxf-dosgi-ri-repository</artifactId>
+    <packaging>pom</packaging>
+    <properties>
+        <bnd.version>3.1.0</bnd.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <local.index.policy>ALLOWED</local.index.policy>
+    </properties>
+    <profiles>
+        <profile>
+            <id>RunningInCI</id>
+            <activation>
+                <property>
+                    <name>running.in.ci</name>
+                    <value>true</value>
+                </property>
+            </activation>
+            <properties>
+                <local.url.policy>FORBIDDEN</local.url.policy>
+            </properties>
+        </profile>
+        <profile>
+            <id>apache-release</id>
+            <properties>
+                <local.url.policy>FORBIDDEN</local.url.policy>
+            </properties>
+        </profile>
+    </profiles>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>biz.aQute.bnd</groupId>
+                <artifactId>bnd-indexer-maven-plugin</artifactId>
+                <version>${bnd.version}</version>
+                <configuration>
+                    <localURLs>${local.index.policy}</localURLs>
+                    <includeTransitive>true</includeTransitive>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>index</id>
+                        <goals>
+                            <goal>index</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.cxf.dosgi</groupId>
+            <artifactId>cxf-dosgi-ri-rsa</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf.dosgi</groupId>
+            <artifactId>cxf-dosgi-ri-tcp</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf.dosgi</groupId>
+            <artifactId>cxf-dosgi-ri-discovery-distributed</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf.dosgi</groupId>
+            <artifactId>cxf-dosgi-ri-discovery-distributed-zookeeper-server</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf.dosgi</groupId>
+            <artifactId>cxf-dosgi-ri-discovery-distributed-zookeeper-server-config</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/discovery/distributed/cxf-discovery/pom.xml b/discovery/distributed/cxf-discovery/pom.xml
index c3af833..b34a1db 100644
--- a/discovery/distributed/cxf-discovery/pom.xml
+++ b/discovery/distributed/cxf-discovery/pom.xml
@@ -40,16 +40,19 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
             <groupId>org.apache.zookeeper</groupId>
             <artifactId>zookeeper</artifactId>
             <version>${zookeeper.version}</version>
+            <scope>provided</scope>
             <exclusions>
                 <exclusion>
                     <groupId>com.sun.jdmk</groupId>
@@ -71,13 +74,13 @@
             <groupId>log4j</groupId>
             <artifactId>log4j</artifactId>
             <version>${log4j.version}</version>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
             <groupId>org.apache.cxf.dosgi</groupId>
             <artifactId>cxf-dosgi-ri-discovery-local</artifactId>
             <version>${project.version}</version>
-            <scope>provided</scope>
         </dependency>
 
         <dependency>
diff --git a/discovery/distributed/zookeeper-server-config/pom.xml b/discovery/distributed/zookeeper-server-config/pom.xml
index 1dbb4e9..83073dc 100644
--- a/discovery/distributed/zookeeper-server-config/pom.xml
+++ b/discovery/distributed/zookeeper-server-config/pom.xml
@@ -42,10 +42,12 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
diff --git a/discovery/distributed/zookeeper-server/pom.xml b/discovery/distributed/zookeeper-server/pom.xml
index 564ad6f..442210e 100644
--- a/discovery/distributed/zookeeper-server/pom.xml
+++ b/discovery/distributed/zookeeper-server/pom.xml
@@ -40,10 +40,12 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
@@ -59,15 +61,26 @@
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                 </exclusion>
+                <exclusion>
+                    <artifactId>slf4j-log4j12</artifactId>
+                    <groupId>org.slf4j</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>jline</artifactId>
+                    <groupId>jline</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>netty</artifactId>
+                    <groupId>io.netty</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>log4j</artifactId>
+                    <groupId>log4j</groupId>
+                </exclusion>
             </exclusions>
         </dependency>
 
         <!--  We need the newer log4j as the one from ZooKeeper has some ugly dependencies -->
-        <dependency>
-            <groupId>log4j</groupId>
-            <artifactId>log4j</artifactId>
-            <version>${log4j.version}</version>
-        </dependency>
 
         <dependency>
             <groupId>junit</groupId>
diff --git a/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/util/Utils.java b/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Utils.java
similarity index 97%
rename from discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/util/Utils.java
rename to discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Utils.java
index f72cbb2..fe3c663 100644
--- a/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/util/Utils.java
+++ b/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Utils.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.cxf.dosgi.discovery.zookeeper.server.util;
+package org.apache.cxf.dosgi.discovery.zookeeper.server;
 
 import java.util.ArrayList;
 import java.util.Dictionary;
diff --git a/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java b/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java
index e32a3eb..bd5618f 100644
--- a/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java
+++ b/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java
@@ -23,9 +23,6 @@
 import java.util.Dictionary;
 import java.util.Map;
 
-import org.apache.cxf.dosgi.discovery.zookeeper.server.util.Utils;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
 import org.apache.zookeeper.server.ServerConfig;
 import org.apache.zookeeper.server.ZooKeeperServerMain;
 import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
@@ -33,10 +30,12 @@
 import org.apache.zookeeper.server.quorum.QuorumPeerMain;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.ConfigurationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ZookeeperStarter implements org.osgi.service.cm.ManagedService {
 
-    private static final Logger LOG = Logger.getLogger(ZookeeperStarter.class); //NOPMD - using log4j here
+    private static final Logger LOG = LoggerFactory.getLogger(ZookeeperStarter.class); //NOPMD - using log4j here
 
     protected ZookeeperServer main;
     private final BundleContext bundleContext;
@@ -56,7 +55,7 @@
                     zkMainThread.join();
                 }
             } catch (Throwable e) {
-                LOG.log(Level.ERROR, e.getMessage(), e);
+                LOG.error(e.getMessage(), e);
             }
             main = null;
             zkMainThread = null;
@@ -125,7 +124,7 @@
 
         private QuorumPeerConfig config;
 
-        public MyQuorumPeerMain(QuorumPeerConfig config) {
+        MyQuorumPeerMain(QuorumPeerConfig config) {
             this.config = config;
         }
 
@@ -144,7 +143,7 @@
 
         private QuorumPeerConfig config;
 
-        public MyZooKeeperServerMain(QuorumPeerConfig config) {
+        MyZooKeeperServerMain(QuorumPeerConfig config) {
             this.config = config;
         }
 
diff --git a/discovery/local/pom.xml b/discovery/local/pom.xml
index e89e22e..8fa118f 100644
--- a/discovery/local/pom.xml
+++ b/discovery/local/pom.xml
@@ -40,10 +40,12 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
         </dependency>
 
         <dependency>
diff --git a/pom.xml b/pom.xml
index 039c837..f109e93 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,6 +108,7 @@
         <module>samples</module>
         <module>osgi-api</module>
         <module>distribution</module>
+        <module>cxf-dosgi-ri-repository</module>
         <module>systests2</module>
     </modules>
 
diff --git a/systests2/multi-bundle/pom.xml b/systests2/multi-bundle/pom.xml
index cccb87f..baa9d01 100644
--- a/systests2/multi-bundle/pom.xml
+++ b/systests2/multi-bundle/pom.xml
@@ -127,10 +127,6 @@
                     <groupId>com.sun.jmx</groupId>
                     <artifactId>jmxri</artifactId>
                 </exclusion>
-                <exclusion>
-                    <groupId>log4j</groupId>
-                    <artifactId>log4j</artifactId>
-                </exclusion>
             </exclusions>
         </dependency>
         <dependency>
@@ -216,32 +212,21 @@
                     </execution>
                 </executions>
             </plugin>
-
-            <!-- use pax exam maven plugin -->
-
-            <!-- Note: settings and dependencies for the final osgi runtime 
-                (TESTS) are just used in TestCases that annotated with this: @RunWith( MavenConfiguredJUnit4TestRunner.class 
-                ) All other testcases will use their own settings/provisioning inside @Configure 
-                Methods. -->
+            
             <plugin>
-                <groupId>org.ops4j.pax.exam</groupId>
-                <artifactId>maven-paxexam-plugin</artifactId>
+                <groupId>org.apache.servicemix.tooling</groupId>
+                <artifactId>depends-maven-plugin</artifactId>
+                <version>1.3.1</version>
                 <executions>
                     <execution>
-                        <id>generate-config</id>
+                        <id>generate-depends-file</id>
                         <goals>
-                            <goal>generate-config</goal>
                             <goal>generate-depends-file</goal>
                         </goals>
                     </execution>
                 </executions>
-                <configuration>
-                    <options>
-                        <platform>equinox</platform>
-                        <profiles>log</profiles>
-                    </options>
-                </configuration>
             </plugin>
+
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java
index 84cf342..ab8dae8 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java
@@ -24,10 +24,9 @@
 
 import javax.inject.Inject;
 
-import junit.framework.Assert;
-
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.data.Stat;
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Configuration;