Use more specific dependencies than karaf-maven-plugin 65/32265/6
authorStephen Kitt <skitt@redhat.com>
Fri, 8 Jan 2016 09:54:04 +0000 (10:54 +0100)
committerStephen Kitt <skitt@redhat.com>
Fri, 12 Feb 2016 17:03:00 +0000 (17:03 +0000)
PerRepoTestRunner currently relies on karaf-maven-plugin to provide a
URLStreamHandlerFactory. This involves pulling in all
karaf-maven-plugin's dependencies, which end up contributing to all
ODL projects' complex dependencies trees as soon as they start using
features-test.

To avoid this, copy CustomBundleURLStreamHandlerFactory from
karaf-maven-plugin; the code is trivial. This allows
karaf-maven-plugin to be removed from the dependencies, as long as the
specific deployers we need are added. I copied mvn, wrap, feature,
spring and blueprint for now. A number of other dependencies become
unnecessary as a result.

Another approach would be to exclude all the irrelevant dependencies
from karaf-maven-plugin but this feels more fragile to me. With our
own CustomBundleURLStreamHandlerFactory we get to decide what
protocols we want to support.

Change-Id: I6b660582d0fbca57d8f20c7dd53375884a982e10
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Karaf-NOTICE [new file with mode: 0644]
features-test/pom.xml
features-test/src/main/java/org/opendaylight/odlparent/featuretest/CustomBundleURLStreamHandlerFactory.java [new file with mode: 0644]
features-test/src/main/java/org/opendaylight/odlparent/featuretest/PerRepoTestRunner.java
karaf-plugin/src/it/settings.xml

diff --git a/Karaf-NOTICE b/Karaf-NOTICE
new file mode 100644 (file)
index 0000000..b70f1f9
--- /dev/null
@@ -0,0 +1,71 @@
+Apache Karaf\r
+Copyright 2010-2014 The Apache Software Foundation\r
+\r
+\r
+I. Included Software\r
+\r
+This product includes software developed at\r
+The Apache Software Foundation (http://www.apache.org/).\r
+Licensed under the Apache License 2.0.\r
+\r
+This product uses software developed at\r
+The OSGi Alliance (http://www.osgi.org/).\r
+Copyright (c) OSGi Alliance (2000, 2010).\r
+Licensed under the Apache License 2.0.\r
+\r
+This product includes software developed at\r
+OW2 (http://www.ow2.org/).\r
+Licensed under the BSD License.\r
+\r
+This product includes software developed at\r
+OPS4J (http://www.ops4j.org/).\r
+Licensed under the Apache License 2.0.\r
+\r
+This product includes software developed at\r
+Eclipse Foundation (http://www.eclipse.org/).\r
+Licensed under the EPL.\r
+\r
+This product includes software written by\r
+Antony Lesuisse.\r
+Licensed under Public Domain.\r
+\r
+\r
+II. Used Software\r
+\r
+This product uses software developed at\r
+FUSE Source (http://www.fusesource.org/).\r
+Licensed under the Apache License 2.0.\r
+\r
+This product uses software developed at\r
+AOP Alliance (http://aopalliance.sourceforge.net/).\r
+Licensed under the Public Domain.\r
+\r
+This product uses software developed at\r
+Tanuki Software (http://www.tanukisoftware.com/).\r
+Licensed under the Apache License 2.0.\r
+\r
+This product uses software developed at\r
+Jasypt (http://jasypt.sourceforge.net/).\r
+Licensed under the Apache License 2.0.\r
+\r
+This product uses software developed at\r
+JLine (http://jline.sourceforge.net).\r
+Licensed under the BSD License.\r
+\r
+This product uses software developed at\r
+SLF4J (http://www.slf4j.org/).\r
+Licensed under the MIT License.\r
+\r
+This product uses software developed at\r
+SpringSource (http://www.springsource.org/).\r
+Licensed under the Apache License 2.0.\r
+\r
+This product includes software from http://www.json.org.\r
+Copyright (c) 2002 JSON.org\r
+\r
+\r
+III. License Summary\r
+- Apache License 2.0\r
+- BSD License\r
+- EPL License\r
+- MIT License\r
index 41261737eac5ea5fe4be2dd81537b46c1afb2dd6..b93574931386aa9825c41475d3ab47a4af1c5ab6 100644 (file)
             <artifactId>pax-url-aether</artifactId>
             <scope>compile</scope>
         </dependency>
-        <dependency>
-            <groupId>javax.inject</groupId>
-            <artifactId>javax.inject</artifactId>
-            <version>1</version>
-            <scope>compile</scope>
-        </dependency>
         <dependency>
             <groupId>org.apache.karaf.features</groupId>
             <artifactId>org.apache.karaf.features.core</artifactId>
             <version>${karaf.version}</version>
             <scope>compile</scope>
         </dependency>
-        <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>org.osgi.core</artifactId>
-            <scope>compile</scope>
-        </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>compile</scope>
         </dependency>
         <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <scope>compile</scope>
+            <groupId>org.apache.karaf.deployer</groupId>
+            <artifactId>org.apache.karaf.deployer.blueprint</artifactId>
+            <version>${karaf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.karaf.deployer</groupId>
+            <artifactId>org.apache.karaf.deployer.features</artifactId>
+            <version>${karaf.version}</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.karaf.tooling</groupId>
-            <artifactId>karaf-maven-plugin</artifactId>
+            <groupId>org.apache.karaf.deployer</groupId>
+            <artifactId>org.apache.karaf.deployer.spring</artifactId>
             <version>${karaf.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-wrap</artifactId>
+            <version>${url.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
     </dependencies>
 
     <build>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
             </plugin>
+            <plugin>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <version>${checkstyle.version}</version>
+                <executions>
+                    <execution>
+                        <id>check-license</id>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                        <phase>process-sources</phase>
+                        <configuration>
+                            <configLocation>check-license.xml</configLocation>
+                            <includeResources>false</includeResources>
+                            <includeTestResources>false</includeTestResources>
+                            <sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
+                            <excludes>
+                                <!-- Skip Apache Licensed files -->
+                                org/opendaylight/odlparent/featuretest/CustomBundleURLStreamHandlerFactory.java
+                            </excludes>
+                            <failsOnError>false</failsOnError>
+                            <consoleOutput>true</consoleOutput>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 
diff --git a/features-test/src/main/java/org/opendaylight/odlparent/featuretest/CustomBundleURLStreamHandlerFactory.java b/features-test/src/main/java/org/opendaylight/odlparent/featuretest/CustomBundleURLStreamHandlerFactory.java
new file mode 100644 (file)
index 0000000..e58246f
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * The NOTICE file referred to in the license statement below is available
+ * as Karaf-NOTICE at the root of this project.
+ */
+/**
+ * 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.opendaylight.odlparent.featuretest;
+
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+
+import org.apache.karaf.deployer.blueprint.BlueprintURLHandler;
+import org.apache.karaf.deployer.features.FeatureURLHandler;
+import org.apache.karaf.deployer.spring.SpringURLHandler;
+
+public class CustomBundleURLStreamHandlerFactory implements URLStreamHandlerFactory {
+
+    private static final String MVN_URI_PREFIX = "mvn";
+    private static final String WRAP_URI_PREFIX = "wrap";
+    private static final String FEATURE_URI_PREFIX = "feature";
+    private static final String SPRING_URI_PREFIX = "spring";
+    private static final String BLUEPRINT_URI_PREFIX = "blueprint";
+
+    @Override
+    public URLStreamHandler createURLStreamHandler(String protocol) {
+        switch (protocol) {
+            case MVN_URI_PREFIX:
+                return new org.ops4j.pax.url.mvn.Handler();
+            case WRAP_URI_PREFIX:
+                return new org.ops4j.pax.url.wrap.Handler();
+            case FEATURE_URI_PREFIX:
+                return new FeatureURLHandler();
+            case SPRING_URI_PREFIX:
+                return new SpringURLHandler();
+            case BLUEPRINT_URI_PREFIX:
+                return new BlueprintURLHandler();
+            default:
+                return null;
+        }
+    }
+
+}
index 7025ea3323e7ddfc55f9a54cf5e97ef3ee4ec75a..ae08d5c7472c98c56eaa2a2ff1d21208fa1ec379 100644 (file)
@@ -18,7 +18,6 @@ import javax.xml.bind.JAXBException;
 import org.apache.karaf.features.internal.model.Feature;
 import org.apache.karaf.features.internal.model.Features;
 import org.apache.karaf.features.internal.model.JaxbUtil;
-import org.apache.karaf.tooling.url.CustomBundleURLStreamHandlerFactory;
 import org.junit.runner.Description;
 import org.junit.runner.notification.RunNotifier;
 import org.junit.runners.ParentRunner;
index c8f77f0b7db9b11c812a032e4b2c5e8bebfab443..fd7219ce9e17d414648e03a141109f120a8c2e4c 100644 (file)
@@ -1,5 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
+<!--
+ The NOTICE file referred to in the license statement below is available
+ as Karaf-NOTICE at the root of this project.
+-->
 <!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file