1#!/bin/bash 2# Force stop on first error. 3set -e 4if [ $# -ne 2 -a $# -ne 3 ]; then 5 echo "$0 <error prone version> <error prone javac version> [checkerframework version]" >&2 6 exit 1; 7fi 8if [ -z "$ANDROID_BUILD_TOP" ]; then 9 echo "Missing environment variables. Did you run build/envsetup.sh and lunch?" >&2 10 exit 1 11fi 12EP_VERSION="$1" 13JAVAC_VERSION="$2" 14# checkerframework 15CF_VERSION="$3" 16JAR_REPO="https://oss.sonatype.org/service/local/repositories/releases/content/com/google/errorprone" 17EP_JAR_URL="${JAR_REPO}/error_prone_core/${EP_VERSION}/error_prone_core-${EP_VERSION}-with-dependencies.jar" 18EP_ANNO_JAR_URL="${JAR_REPO}/error_prone_annotations/${EP_VERSION}/error_prone_annotations-${EP_VERSION}.jar" 19EP_TYPE_ANNO_JAR_URL="${JAR_REPO}/error_prone_type_annotations/${EP_VERSION}/error_prone_type_annotations-${EP_VERSION}.jar" 20EP_TEST_HELPERS_JAR_URL="${JAR_REPO}/error_prone_test_helpers/${EP_VERSION}/error_prone_test_helpers-${EP_VERSION}.jar" 21JAVAC_JAR_URL="${JAR_REPO}/javac/${JAVAC_VERSION}/javac-${JAVAC_VERSION}.jar" 22JAVAC_SOURCES_JAR_URL="${JAR_REPO}/javac/${JAVAC_VERSION}/javac-${JAVAC_VERSION}-sources.jar" 23CF_DATAFLOW_JAR_URL="http://repo1.maven.org/maven2/org/checkerframework/dataflow/${CF_VERSION}/dataflow-${CF_VERSION}.jar" 24CF_DATAFLOW_SOURCES_JAR_URL="http://repo1.maven.org/maven2/org/checkerframework/dataflow/${CF_VERSION}/dataflow-${CF_VERSION}-sources.jar" 25CF_JAVACUTIL_JAR_URL="http://repo1.maven.org/maven2/org/checkerframework/javacutil/${CF_VERSION}/javacutil-${CF_VERSION}.jar" 26CF_JAVACUTIL_SOURCES_JAR_URL="http://repo1.maven.org/maven2/org/checkerframework/javacutil/${CF_VERSION}/javacutil-${CF_VERSION}-sources.jar" 27TOOLS_DIR=$(dirname $0) 28 29function update_jar { 30 typeset VERSION="$1" JAR_URL="$2" DIR="$3" JAR_FILE="$4" 31 typeset JAR_URL_PREFIX=$(dirname $(dirname ${JAR_URL})) 32 33 # Update the version and binary JAR URL. 34 perl -pi -e "s|version: .*|version: \"${VERSION}\"|; s|\"${JAR_URL_PREFIX}.*\"|\"${JAR_URL}\"|" "$DIR/METADATA" 35 36 # Update the last upgrade date 37 perl -pi -e "s|last_upgrade_date.*|last_upgrade_date { year: $(date +%Y) month: $(date +%-m) day: $(date +%-d)}|" "$DIR/METADATA" 38 39 # Get the JAR. 40 wget ${JAR_URL} -O ${DIR}/$(basename ${JAR_URL}) 41 wget ${JAR_URL}.sha1 -O ${DIR}/$(basename ${JAR_URL}).sha1 42 wget ${JAR_URL}.asc -O ${DIR}/$(basename ${JAR_URL}).asc 43} 44 45rm -f error_prone/*.jar* 46rm -f javac/*.jar* 47 48update_jar "${EP_VERSION}" "${EP_JAR_URL}" "${TOOLS_DIR}/error_prone" 49update_jar "${EP_VERSION}" "${EP_ANNO_JAR_URL}" "${TOOLS_DIR}/error_prone" 50update_jar "${EP_VERSION}" "${EP_TYPE_ANNO_JAR_URL}" "${TOOLS_DIR}/error_prone" 51update_jar "${EP_VERSION}" "${EP_TEST_HELPERS_JAR_URL}" "${TOOLS_DIR}/error_prone" 52update_jar "${JAVAC_VERSION}" "${JAVAC_SOURCES_JAR_URL}" "${TOOLS_DIR}/javac" 53update_jar "${JAVAC_VERSION}" "${JAVAC_JAR_URL}" "${TOOLS_DIR}/javac" 54 55# Update the versions for soong 56perl -pi -e "\ 57 s|\"(external/error_prone/javac/javac).*\"|\"\\1-${JAVAC_VERSION}.jar\"|;\ 58 s|\"(external/error_prone/error_prone/error_prone_core).*\"|\"\\1-${EP_VERSION}-with-dependencies.jar\"|;\ 59 s|\"(external/error_prone/error_prone/error_prone_annotations).*\"|\"\\1-${EP_VERSION}.jar\"|;\ 60 s|\"(external/error_prone/error_prone/error_prone_type_annotations).*\"|\"\\1-${EP_VERSION}.jar\"|;\ 61 s|\"(external/error_prone/error_prone/error_prone_test_helpers).*\"|\"\\1-${EP_VERSION}.jar\"|;\ 62" "$TOOLS_DIR/soong/error_prone.go" 63 64if [ "${CF_VERSION}" != '' ]; then 65 rm -f checkerframework/*.jar* 66 update_jar "${CF_VERSION}" "${CF_DATAFLOW_JAR_URL}" "${TOOLS_DIR}/checkerframework" 67 update_jar "${CF_VERSION}" "${CF_DATAFLOW_SOURCES_JAR_URL}" "${TOOLS_DIR}/checkerframework" 68 update_jar "${CF_VERSION}" "${CF_JAVACUTIL_JAR_URL}" "${TOOLS_DIR}/checkerframework" 69 update_jar "${CF_VERSION}" "${CF_JAVACUTIL_SOURCES_JAR_URL}" "${TOOLS_DIR}/checkerframework" 70 perl -pi -e "\ 71 s|\"(external/error_prone/checkerframework/dataflow).*\"|\"\\1-${CF_VERSION}.jar\"|;\ 72 s|\"(external/error_prone/checkerframework/javacutil).*\"|\"\\1-${CF_VERSION}.jar\"|;\ 73 " "$TOOLS_DIR/soong/error_prone.go" 74fi 75