aboutsummaryrefslogtreecommitdiff
path: root/dev
diff options
context:
space:
mode:
authorPrashant Sharma <prashant.s@imaginea.com>2014-03-24 08:44:12 -0700
committerPatrick Wendell <pwendell@gmail.com>2014-03-24 08:44:20 -0700
commit21109fbab0ded4f73cf4f8816859c76f125adfea (patch)
treebd0df80d2947fff753247684ddf41719be438582 /dev
parent80c29689ae3b589254a571da3ddb5f9c866ae534 (diff)
downloadspark-21109fbab0ded4f73cf4f8816859c76f125adfea.tar.gz
spark-21109fbab0ded4f73cf4f8816859c76f125adfea.tar.bz2
spark-21109fbab0ded4f73cf4f8816859c76f125adfea.zip
SPARK-1144 Added license and RAT to check licenses.
Author: Prashant Sharma <prashant.s@imaginea.com> Closes #125 from ScrapCodes/rat-integration and squashes the following commits: 64f7c7d [Prashant Sharma] added license headers. fcf28b1 [Prashant Sharma] Review feedback. c0648db [Prashant Sharma] SPARK-1144 Added license and RAT to check licenses.
Diffstat (limited to 'dev')
-rwxr-xr-xdev/check-license81
-rwxr-xr-xdev/run-tests7
2 files changed, 87 insertions, 1 deletions
diff --git a/dev/check-license b/dev/check-license
new file mode 100755
index 0000000000..fbd2dd465b
--- /dev/null
+++ b/dev/check-license
@@ -0,0 +1,81 @@
+#!/usr/bin/env bash
+
+#
+# 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.
+#
+
+
+acquire_rat_jar () {
+
+ URL1="http://search.maven.org/remotecontent?filepath=org/apache/rat/apache-rat/${RAT_VERSION}/apache-rat-${RAT_VERSION}.jar"
+ URL2="http://repo1.maven.org/maven2/org/apache/rat/apache-rat/${RAT_VERSION}/apache-rat-${RAT_VERSION}.jar"
+
+ JAR=$rat_jar
+
+ if [[ ! -f "$rat_jar" ]]; then
+ # Download rat launch jar if it hasn't been downloaded yet
+ if [ ! -f ${JAR} ]; then
+ # Download
+ printf "Attempting to fetch rat\n"
+ JAR_DL=${JAR}.part
+ if hash curl 2>/dev/null; then
+ (curl --progress-bar ${URL1} > ${JAR_DL} || curl --progress-bar ${URL2} > ${JAR_DL}) && mv ${JAR_DL} ${JAR}
+ elif hash wget 2>/dev/null; then
+ (wget --progress=bar ${URL1} -O ${JAR_DL} || wget --progress=bar ${URL2} -O ${JAR_DL}) && mv ${JAR_DL} ${JAR}
+ else
+ printf "You do not have curl or wget installed, please install rat manually.\n"
+ exit -1
+ fi
+ fi
+ if [ ! -f ${JAR} ]; then
+ # We failed to download
+ printf "Our attempt to download rat locally to ${JAR} failed. Please install rat manually.\n"
+ exit -1
+ fi
+ printf "Launching rat from ${JAR}\n"
+ fi
+}
+
+# Go to the Spark project root directory
+FWDIR="$(cd `dirname $0`/..; pwd)"
+cd $FWDIR
+
+if test -x "$JAVA_HOME/bin/java"; then
+ declare java_cmd="$JAVA_HOME/bin/java"
+else
+ declare java_cmd=java
+fi
+
+export RAT_VERSION=0.10
+export rat_jar=$FWDIR/lib/apache-rat-${RAT_VERSION}.jar
+mkdir -p $FWDIR/lib
+
+[[ -f "$rat_jar" ]] || acquire_rat_jar || {
+ echo "Download failed. Obtain the rat jar manually and place it at $rat_jar"
+ exit 1
+}
+
+$java_cmd -jar $rat_jar -E $FWDIR/.rat-excludes -d $FWDIR > rat-results.txt
+
+ERRORS=$(cat rat-results.txt | grep -e "??")
+
+if test ! -z "$ERRORS"; then
+ echo "Could not find Apache license headers in the following files:"
+ echo "$ERRORS"
+ exit 1
+else
+ echo -e "RAT checks passed."
+fi
diff --git a/dev/run-tests b/dev/run-tests
index cf0b940c09..6e78cad995 100755
--- a/dev/run-tests
+++ b/dev/run-tests
@@ -34,8 +34,13 @@ else
fi
JAVA_VERSION=$($java_cmd -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q')
-[ "$JAVA_VERSION" -ge 18 ] && echo "" || echo "[Warn] Java 8 tests will not run, because JDK version is < 1.8."
+[ "$JAVA_VERSION" -ge 18 ] && echo "" || echo "[Warn] Java 8 tests will not run because JDK version is < 1.8."
+echo "========================================================================="
+echo "Running Apache RAT checks"
+echo "========================================================================="
+
+dev/check-license
echo "========================================================================="
echo "Running Scala style checks"