Add a script to fix JSR-305 dependencies 00/81200/1
authorStephen Kitt <skitt@redhat.com>
Tue, 26 Mar 2019 16:35:57 +0000 (17:35 +0100)
committerStephen Kitt <skitt@redhat.com>
Tue, 26 Mar 2019 16:50:35 +0000 (17:50 +0100)
This adds the jsr305 dependency in modules which need it but don’t yet
have it.

Change-Id: Iedc9d8350b4bea0ee9eae709c033ef35a5796658
Signed-off-by: Stephen Kitt <skitt@redhat.com>
scripts/fix-jsr305 [new file with mode: 0755]
scripts/jsr305.txt [new file with mode: 0644]

diff --git a/scripts/fix-jsr305 b/scripts/fix-jsr305
new file mode 100755 (executable)
index 0000000..921c2cb
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# Copyright © 2019 Red Hat, Inc. and others.
+#
+# This program and the accompanying materials are made available under the
+# terms of the Eclipse Public License v1.0 which accompanies this distribution,
+# and is available at http://www.eclipse.org/legal/epl-v10.html
+
+# Find modules using JSR 305
+for module in $(git grep -lf ${0%/*}/jsr305.txt |
+                awk -F/ '{ for (i = NF; i > 0; i--) { if ($i == "src") { NF = i - 1; print; next } } }' OFS="/" |
+               sort -u); do
+    # If they don't already pull in jsr305...
+    if ! grep -q jsr305 ${module}/pom.xml; then
+       # ... add the dependency
+       xmlstarlet ed -P -L -N mvn=http://maven.apache.org/POM/4.0.0 \
+                  -s /mvn:project/mvn:dependencies -t elem -n dependencyTMP -v "" \
+                  -s //dependencyTMP -t elem -n groupId -v "com.google.code.findbugs" \
+                  -s //dependencyTMP -t elem -n artifactId -v "jsr305" \
+                  -s //dependencyTMP -t elem -n optional -v "true" \
+                  -r //dependencyTMP -v dependency \
+                  ${module}/pom.xml
+    fi
+done
diff --git a/scripts/jsr305.txt b/scripts/jsr305.txt
new file mode 100644 (file)
index 0000000..b6b9d0f
--- /dev/null
@@ -0,0 +1,31 @@
+javax.annotation.CheckForNull
+javax.annotation.CheckForSigned
+javax.annotation.CheckReturnValue
+javax.annotation.concurrent.GuardedBy
+javax.annotation.concurrent.Immutable
+javax.annotation.concurrent.NotThreadSafe
+javax.annotation.concurrent.ThreadSafe
+javax.annotation.Detainted
+javax.annotation.MatchesPattern
+javax.annotation.meta.Exclusive
+javax.annotation.meta.Exhaustive
+javax.annotation.meta.TypeQualifier
+javax.annotation.meta.TypeQualifierDefault
+javax.annotation.meta.TypeQualifierNickname
+javax.annotation.meta.TypeQualifierValidator
+javax.annotation.meta.When
+javax.annotation.Nonnegative
+javax.annotation.Nonnull
+javax.annotation.Nullable
+javax.annotation.OverridingMethodsMustInvokeSuper
+javax.annotation.ParametersAreNonnullByDefault
+javax.annotation.ParametersAreNullableByDefault
+javax.annotation.PropertyKey
+javax.annotation.RegEx
+javax.annotation.Signed
+javax.annotation.Syntax
+javax.annotation.Tainted
+javax.annotation.Untainted
+javax.annotation.WillClose
+javax.annotation.WillCloseWhenClosed
+javax.annotation.WillNotClose