[DOSGI-229] Optimize packaging
Project: http://git-wip-us.apache.org/repos/asf/aries-rsa/repo Commit: http://git-wip-us.apache.org/repos/asf/aries-rsa/commit/97c2e47c Tree: http://git-wip-us.apache.org/repos/asf/aries-rsa/tree/97c2e47c Diff: http://git-wip-us.apache.org/repos/asf/aries-rsa/diff/97c2e47c Branch: refs/heads/master Commit: 97c2e47ccbbdfe3f852d4a14f1a88e5a24704af7 Parents: 0111cfd Author: Christian Schneider <[email protected]> Authored: Wed Mar 9 13:45:57 2016 +0100 Committer: Christian Schneider <[email protected]> Committed: Wed Mar 9 13:45:57 2016 +0100 ---------------------------------------------------------------------- cxf-dosgi-ri-repository/pom.xml | 85 +++++++++++++++ discovery/distributed/cxf-discovery/pom.xml | 5 +- .../distributed/zookeeper-server-config/pom.xml | 2 + discovery/distributed/zookeeper-server/pom.xml | 23 +++- .../dosgi/discovery/zookeeper/server/Utils.java | 108 +++++++++++++++++++ .../zookeeper/server/ZookeeperStarter.java | 13 ++- .../discovery/zookeeper/server/util/Utils.java | 108 ------------------- discovery/local/pom.xml | 2 + pom.xml | 1 + systests2/multi-bundle/pom.xml | 27 ++--- .../systests2/multi/TestDiscoveryExport.java | 3 +- 11 files changed, 233 insertions(+), 144 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/97c2e47c/cxf-dosgi-ri-repository/pom.xml ---------------------------------------------------------------------- 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> http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/97c2e47c/discovery/distributed/cxf-discovery/pom.xml ---------------------------------------------------------------------- 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> http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/97c2e47c/discovery/distributed/zookeeper-server-config/pom.xml ---------------------------------------------------------------------- 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> http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/97c2e47c/discovery/distributed/zookeeper-server/pom.xml ---------------------------------------------------------------------- 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> http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/97c2e47c/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Utils.java ---------------------------------------------------------------------- diff --git a/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Utils.java b/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Utils.java new file mode 100644 index 0000000..fe3c663 --- /dev/null +++ b/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/Utils.java @@ -0,0 +1,108 @@ +/** + * 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.cxf.dosgi.discovery.zookeeper.server; + +import java.util.ArrayList; +import java.util.Dictionary; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * General purpose utility methods. + */ +public final class Utils { + + private Utils() { + // prevent instantiation + } + + /** + * Remove entries whose values are empty from the given dictionary. + * + * @param dict a dictionary + */ + public static void removeEmptyValues(Dictionary<String, ?> dict) { + List<String> keysToRemove = new ArrayList<String>(); + Enumeration<String> keys = dict.keys(); + while (keys.hasMoreElements()) { + String key = keys.nextElement(); + Object value = dict.get(key); + if (value instanceof String && "".equals(value)) { + keysToRemove.add(key); + } + } + for (String key : keysToRemove) { + dict.remove(key); + } + } + + /** + * Puts the given key-value pair in the given dictionary if the key does not + * already exist in it or if its existing value is null. + * + * @param dict a dictionary + * @param key the key + * @param value the default value to set + */ + public static void setDefault(Dictionary<String, String> dict, String key, String value) { + if (dict.get(key) == null) { + dict.put(key, value); + } + } + + /** + * Converts the given Dictionary to a Map. + * + * @param dict a dictionary + * @param <K> the key type + * @param <V> the value type + * @return the converted map, or an empty map if the given dictionary is null + */ + public static <K, V> Map<K, V> toMap(Dictionary<K, V> dict) { + Map<K, V> map = new HashMap<K, V>(); + if (dict != null) { + Enumeration<K> keys = dict.keys(); + while (keys.hasMoreElements()) { + K key = keys.nextElement(); + map.put(key, dict.get(key)); + } + } + return map; + } + + /** + * Converts a Dictionary into a Properties instance. + * + * @param dict a dictionary + * @param <K> the key type + * @param <V> the value type + * @return the properties + */ + public static <K, V> Properties toProperties(Dictionary<K, V> dict) { + Properties props = new Properties(); + for (Enumeration<K> e = dict.keys(); e.hasMoreElements();) { + K key = e.nextElement(); + props.put(key, dict.get(key)); + } + return props; + } +} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/97c2e47c/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/ZookeeperStarter.java ---------------------------------------------------------------------- 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.io.IOException; 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.QuorumPeerConfig.ConfigException; 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 @@ public class ZookeeperStarter implements org.osgi.service.cm.ManagedService { 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 @@ public class ZookeeperStarter implements org.osgi.service.cm.ManagedService { private QuorumPeerConfig config; - public MyQuorumPeerMain(QuorumPeerConfig config) { + MyQuorumPeerMain(QuorumPeerConfig config) { this.config = config; } @@ -144,7 +143,7 @@ public class ZookeeperStarter implements org.osgi.service.cm.ManagedService { private QuorumPeerConfig config; - public MyZooKeeperServerMain(QuorumPeerConfig config) { + MyZooKeeperServerMain(QuorumPeerConfig config) { this.config = config; } http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/97c2e47c/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/util/Utils.java ---------------------------------------------------------------------- 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/util/Utils.java deleted file mode 100644 index f72cbb2..0000000 --- a/discovery/distributed/zookeeper-server/src/main/java/org/apache/cxf/dosgi/discovery/zookeeper/server/util/Utils.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * 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.cxf.dosgi.discovery.zookeeper.server.util; - -import java.util.ArrayList; -import java.util.Dictionary; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -/** - * General purpose utility methods. - */ -public final class Utils { - - private Utils() { - // prevent instantiation - } - - /** - * Remove entries whose values are empty from the given dictionary. - * - * @param dict a dictionary - */ - public static void removeEmptyValues(Dictionary<String, ?> dict) { - List<String> keysToRemove = new ArrayList<String>(); - Enumeration<String> keys = dict.keys(); - while (keys.hasMoreElements()) { - String key = keys.nextElement(); - Object value = dict.get(key); - if (value instanceof String && "".equals(value)) { - keysToRemove.add(key); - } - } - for (String key : keysToRemove) { - dict.remove(key); - } - } - - /** - * Puts the given key-value pair in the given dictionary if the key does not - * already exist in it or if its existing value is null. - * - * @param dict a dictionary - * @param key the key - * @param value the default value to set - */ - public static void setDefault(Dictionary<String, String> dict, String key, String value) { - if (dict.get(key) == null) { - dict.put(key, value); - } - } - - /** - * Converts the given Dictionary to a Map. - * - * @param dict a dictionary - * @param <K> the key type - * @param <V> the value type - * @return the converted map, or an empty map if the given dictionary is null - */ - public static <K, V> Map<K, V> toMap(Dictionary<K, V> dict) { - Map<K, V> map = new HashMap<K, V>(); - if (dict != null) { - Enumeration<K> keys = dict.keys(); - while (keys.hasMoreElements()) { - K key = keys.nextElement(); - map.put(key, dict.get(key)); - } - } - return map; - } - - /** - * Converts a Dictionary into a Properties instance. - * - * @param dict a dictionary - * @param <K> the key type - * @param <V> the value type - * @return the properties - */ - public static <K, V> Properties toProperties(Dictionary<K, V> dict) { - Properties props = new Properties(); - for (Enumeration<K> e = dict.keys(); e.hasMoreElements();) { - K key = e.nextElement(); - props.put(key, dict.get(key)); - } - return props; - } -} http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/97c2e47c/discovery/local/pom.xml ---------------------------------------------------------------------- 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> http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/97c2e47c/pom.xml ---------------------------------------------------------------------- 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> http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/97c2e47c/systests2/multi-bundle/pom.xml ---------------------------------------------------------------------- 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> http://git-wip-us.apache.org/repos/asf/aries-rsa/blob/97c2e47c/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestDiscoveryExport.java ---------------------------------------------------------------------- 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 java.util.Hashtable; 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;
