Do not pull in JSR305 by default 00/80800/7
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 12 Mar 2019 15:21:28 +0000 (16:21 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 13 Mar 2019 16:45:39 +0000 (17:45 +0100)
The migration to findbugs:annotations is actively hurtful to us,
as JSR305 is clashing on javax.annotation package with JEE
annotations.

This patch removes findbugs:annotations, making them a banned
dependency, and instead defines spotbugs:annotations and
findbugs:jsr305.

spotbugs:annotations replaces findbugs:annotations as the default
dependency.

JIRA: ODLPARENT-198
Change-Id: I3e113fb3af3f2cdd6e4cd6b22ffc0dcac5efbcf9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
bundles-test-lib/src/main/java/org/opendaylight/odlparent/bundlestest/lib/BundleSymbolicNameWithVersion.java
karaf-plugin/src/main/java/org/opendaylight/odlparent/FeatureUtil.java
odlparent-bundle-check/src/main/java/org/opendaylight/odlparent/bundle/SpotbugsAnnotations.java [moved from odlparent-bundle-check/src/main/java/org/opendaylight/odlparent/bundle/JavaxAnnotations.java with 58% similarity]
odlparent-dependency-check/pom.xml
odlparent/pom.xml

index 7e0aa2370497eeafeb5e4d3b53a0d36c0c70e80e..d74b1aa895e051fb168381e0fdb033e723bb1693 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.odlparent.bundlestest.lib;
 import static java.util.Objects.requireNonNull;
 
 import java.io.Serializable;
-import javax.annotation.Nonnull;
+import org.eclipse.jdt.annotation.NonNull;
 
 /**
  * Bundle's symbolic name + its version.
@@ -20,11 +20,9 @@ import javax.annotation.Nonnull;
 public final class BundleSymbolicNameWithVersion implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    @Nonnull
-    private final String symbolicName;
+    private final @NonNull String symbolicName;
 
-    @Nonnull
-    private final String version;
+    private final @NonNull String version;
 
     public BundleSymbolicNameWithVersion(String symbolicName, String version) {
         this.symbolicName = requireNonNull(symbolicName, "symbolicName");
index ff258ac86ef31a48a94d66e94cfe15c72f6f89d3..b5f6e178a953f30a15bfde9318c63d68b90cba7e 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.odlparent;
 
 import java.io.File;
@@ -20,7 +19,6 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.regex.Pattern;
-import javax.annotation.RegEx;
 import org.apache.karaf.features.BundleInfo;
 import org.apache.karaf.features.Conditional;
 import org.apache.karaf.features.internal.model.Bundle;
@@ -29,6 +27,7 @@ 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.maven.plugin.MojoExecutionException;
+import org.checkerframework.checker.regex.qual.Regex;
 import org.eclipse.aether.artifact.Artifact;
 import org.ops4j.pax.url.mvn.internal.Parser;
 import org.slf4j.Logger;
@@ -40,7 +39,7 @@ public final class FeatureUtil {
     private static final Pattern MVN_PATTERN = Pattern.compile("mvn:", Pattern.LITERAL);
     private static final Pattern WRAP_PATTERN = Pattern.compile("wrap:", Pattern.LITERAL);
 
-    @RegEx
+    @Regex
     private static final String VERSION_STRIP_PATTERN_STR = "\\$.*$";
     private static final Pattern VERSION_STRIP_PATTERN = Pattern.compile(VERSION_STRIP_PATTERN_STR);
 
similarity index 58%
rename from odlparent-bundle-check/src/main/java/org/opendaylight/odlparent/bundle/JavaxAnnotations.java
rename to odlparent-bundle-check/src/main/java/org/opendaylight/odlparent/bundle/SpotbugsAnnotations.java
index c81e9536c938d435556d62e1535bb9bc0d7ca2df..ec7f41ba34669d35d4a32462860c36af7957a8da 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.odlparent.bundle;
 
-import javax.annotation.Nonnull;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
-public interface JavaxAnnotations {
+@SuppressFBWarnings
+public interface SpotbugsAnnotations {
 
-    @Nonnull Object nonNullMethodReturn();
 }
index dc187010ec56adc3b3adffd723aa368cc039256d..6599f715ff0f4faddae9a25a410d718bc5e7b4e3 100644 (file)
             <groupId>com.fasterxml.woodstox</groupId>
             <artifactId>woodstox-core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.github.spotbugs</groupId>
+            <artifactId>spotbugs-annotations</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.google.code.findbugs</groupId>
-            <artifactId>annotations</artifactId>
+            <artifactId>jsr305</artifactId>
         </dependency>
         <dependency>
             <groupId>com.google.code.gson</groupId>
index cda70692214f6c021a83651a2bb1611135b201c3..5b60204ac1694b77dcb1c91bfdec09d616b3daca 100644 (file)
         <version>25.1-jre</version>
         <exclusions>
           <exclusion>
+            <!-- Do not leak JSR305 onto the classpath by default -->
             <groupId>com.google.code.findbugs</groupId>
-            <!-- Use com.google.code.findbugs:annotations instead of jsr305 -->
             <artifactId>jsr305</artifactId>
           </exclusion>
         </exclusions>
         <scope>test</scope>
         <exclusions>
           <exclusion>
+            <!-- Do not leak JSR305 onto the classpath by default -->
             <groupId>com.google.code.findbugs</groupId>
-            <!-- Use com.google.code.findbugs:annotations instead of jsr305 -->
             <artifactId>jsr305</artifactId>
           </exclusion>
         </exclusions>
       </dependency>
 
       <dependency>
-        <groupId>com.google.code.findbugs</groupId>
-        <artifactId>annotations</artifactId>
-        <version>3.0.0</version>
+        <groupId>com.github.spotbugs</groupId>
+        <artifactId>spotbugs-annotations</artifactId>
+        <version>3.1.9</version>
+        <scope>provided</scope>
+        <!-- Contains retention=RUNTIME annotations, which are not really needed -->
+        <optional>true</optional>
         <exclusions>
-          <!-- We'd like (have) to eventually exclude :jsr305 here as well, because
-               the types of this artifact are already shaded inside the :annotations artifact.
-               This state is a temporary solution to allow all projects to gradually switch over
-               switch their <dependency><groupId>com.google.code.findbugs from
-               <artifactId>jsr305 to <artifactId>annotations in all pom.xml.
-               The target solution is https://git.opendaylight.org/gerrit/#/c/47337/
-            -->
           <exclusion>
-            <groupId>net.jcip</groupId>
-            <!-- The types of this artifact are already shaded inside the :annotations artifact -->
-            <artifactId>jcip-annotations</artifactId>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>jsr305</artifactId>
           </exclusion>
         </exclusions>
       </dependency>
+
+      <dependency>
+        <groupId>com.google.code.findbugs</groupId>
+        <artifactId>jsr305</artifactId>
+        <version>3.0.2</version>
+        <scope>provided</scope>
+        <!-- Contains retention=RUNTIME annotations, which are not really needed -->
+        <optional>true</optional>
+      </dependency>
       <dependency>
         <groupId>org.eclipse.jdt</groupId>
         <artifactId>org.eclipse.jdt.annotation</artifactId>
           are not required at runtime.
     -->
     <dependency>
-      <groupId>com.google.code.findbugs</groupId>
-      <artifactId>annotations</artifactId>
+      <groupId>org.eclipse.jdt</groupId>
+      <artifactId>org.eclipse.jdt.annotation</artifactId>
       <scope>provided</scope>
-      <!-- Contains retention=RUNTIME annotations, which are not really needed -->
-      <optional>true</optional>
     </dependency>
     <dependency>
-      <groupId>org.eclipse.jdt</groupId>
-      <artifactId>org.eclipse.jdt.annotation</artifactId>
+      <groupId>com.github.spotbugs</groupId>
+      <artifactId>spotbugs-annotations</artifactId>
       <scope>provided</scope>
+      <optional>true</optional>
     </dependency>
 
     <!--
             <configuration>
               <rules>
                 <bannedDependencies>
-                  <message>Please always use mockito-core instead of mockito-all, and findbugs:annotations instead of findbugs:jsr305 (see https://bugs.opendaylight.org/show_bug.cgi?id=7662 &amp; https://bugs.opendaylight.org/show_bug.cgi?id=7663)</message>
+                  <message>Please always use mockito-core instead of mockito-all (see https://bugs.opendaylight.org/show_bug.cgi?id=7662), and spotbugs:annotations instead of findbugs:annotations</message>
                   <excludes>
                     <exclude>org.mockito:mockito-all</exclude>
-                    <!-- https://github.com/facebook/facebook-oss-pom/blob/master/pom.xml#L331-L336 -->
-                    <!-- Clashes with com.google.code.findbugs:annotations and having both jars -->
-                    <!-- as a dependency then clashes with the dependency checker (because it   -->
-                    <!-- is not very good at handling annotations). Use the annotations jar     -->
-                    <!-- instead which has all jsr305 annotations and the additional findbugs   -->
-                    <!-- stuff. -->
-                    <exclude>com.google.code.findbugs:jsr305</exclude>
-                    <exclude>net.jcip:jcip-annotations</exclude>
+                    <exclude>com.google.code.findbugs:annotations</exclude>
                   </excludes>
                 </bannedDependencies>
               </rules>