Aurimas Liutikas | c1250fc | 2021-02-04 16:08:34 -0800 | [diff] [blame] | 1 | #!/bin/bash |
Aurimas Liutikas | 65920d3 | 2023-02-14 18:38:24 -0800 | [diff] [blame] | 2 | |
| 3 | function echoAndDo() { |
| 4 | echo "$@" |
| 5 | eval "$@" |
| 6 | } |
| 7 | |
Aurimas Liutikas | c1250fc | 2021-02-04 16:08:34 -0800 | [diff] [blame] | 8 | # Get versions |
Aurimas Liutikas | 65920d3 | 2023-02-14 18:38:24 -0800 | [diff] [blame] | 9 | echo Getting Studio version and link |
Aurimas Liutikas | 09f5722 | 2023-05-09 20:46:57 -0700 | [diff] [blame] | 10 | AGP_VERSION=${1:-8.1.0-beta02} |
| 11 | STUDIO_VERSION_STRING=${2:-"Android Studio Giraffe | 2022.3.1 Beta 2"} |
Aurimas Liutikas | 65920d3 | 2023-02-14 18:38:24 -0800 | [diff] [blame] | 12 | STUDIO_IFRAME_LINK=`curl "https://developer.android.com/studio/archive.html" | grep "<iframe " | sed "s/.* src=\"\([^\"]*\)\".*/\1/g"` |
| 13 | echo iframe link $STUDIO_IFRAME_LINK |
| 14 | STUDIO_IFRAME_REDIRECT=`curl -s $STUDIO_IFRAME_LINK | grep href | sed 's/.*href="\([^"]*\)".*/\1/g'` |
| 15 | echo iframe redirect $STUDIO_IFRAME_REDIRECT |
| 16 | STUDIO_LINK=`curl -s $STUDIO_IFRAME_REDIRECT | grep -C30 "$STUDIO_VERSION_STRING" | grep Linux | tail -n 1 | sed 's/.*a href="\(.*\).*"/\1/g' | sed 's/>.*//'` |
| 17 | echo STUDIO_LINK: $STUDIO_LINK |
| 18 | if [ "$STUDIO_LINK" == "" ]; then |
| 19 | echo "Error: STUDIO_LINK must not be empty. Open this script and look for parsing errors. Does studio version '$STUDIO_VERSION_STRING' exist?" |
| 20 | exit 1 |
| 21 | fi |
Aurimas Liutikas | e54847d | 2021-05-19 10:58:12 -0700 | [diff] [blame] | 22 | STUDIO_VERSION=`echo $STUDIO_LINK | sed "s/.*ide-zips\/\(.*\)\/android-studio-.*/\1/g"` |
Aurimas Liutikas | c1250fc | 2021-02-04 16:08:34 -0800 | [diff] [blame] | 23 | |
| 24 | # Update AGP |
Aurimas Liutikas | 4e9ba5f | 2022-01-13 16:15:21 -0800 | [diff] [blame] | 25 | ARTIFACTS_TO_DOWNLOAD="com.android.tools.build:gradle:$AGP_VERSION," |
| 26 | ARTIFACTS_TO_DOWNLOAD+="androidx.databinding:viewbinding:$AGP_VERSION," |
Aurimas Liutikas | c1250fc | 2021-02-04 16:08:34 -0800 | [diff] [blame] | 27 | AAPT2_VERSIONS=`curl "https://dl.google.com/dl/android/maven2/com/android/tools/build/group-index.xml" | grep aapt2-proto | sed 's/.*versions="\(.*\)"\/>/\1/g'` |
| 28 | AAPT2_VERSION=`echo $AAPT2_VERSIONS | sed "s/.*\($AGP_VERSION-[0-9]*\).*/\1/g"` |
Aurimas Liutikas | 4e9ba5f | 2022-01-13 16:15:21 -0800 | [diff] [blame] | 29 | ARTIFACTS_TO_DOWNLOAD+="com.android.tools.build:aapt2:$AAPT2_VERSION:linux," |
| 30 | ARTIFACTS_TO_DOWNLOAD+="com.android.tools.build:aapt2:$AAPT2_VERSION:osx," |
| 31 | ARTIFACTS_TO_DOWNLOAD+="com.android.tools.build:aapt2:$AAPT2_VERSION," |
Aurimas Liutikas | c1250fc | 2021-02-04 16:08:34 -0800 | [diff] [blame] | 32 | LINT_VERSIONS=`curl "https://dl.google.com/dl/android/maven2/com/android/tools/lint/group-index.xml" | grep lint | sed 's/.*versions="\(.*\)"\/>/\1/g'` |
| 33 | LINT_MINOR_VERSION=`echo $AGP_VERSION | sed 's/[0-9]\+\.\(.*\)/\1/g'` |
| 34 | LINT_VERSION=`echo $LINT_VERSIONS | sed "s/.*[,| ]\([0-9]\+\.$LINT_MINOR_VERSION\).*/\1/g"` |
Aurimas Liutikas | 4e9ba5f | 2022-01-13 16:15:21 -0800 | [diff] [blame] | 35 | ARTIFACTS_TO_DOWNLOAD+="com.android.tools.lint:lint:$LINT_VERSION," |
| 36 | ARTIFACTS_TO_DOWNLOAD+="com.android.tools.lint:lint-tests:$LINT_VERSION," |
| 37 | ARTIFACTS_TO_DOWNLOAD+="com.android.tools.lint:lint-gradle:$LINT_VERSION," |
Aurimas Liutikas | 39f2226 | 2022-11-03 09:00:24 -0700 | [diff] [blame] | 38 | ARTIFACTS_TO_DOWNLOAD+="com.android.tools:ninepatch:$LINT_VERSION," |
Aurimas Liutikas | c1250fc | 2021-02-04 16:08:34 -0800 | [diff] [blame] | 39 | |
Aurimas Liutikas | 65920d3 | 2023-02-14 18:38:24 -0800 | [diff] [blame] | 40 | # Update libs.versions.toml |
| 41 | echo Updating dependency versions |
Aurimas Liutikas | 78273a3 | 2021-07-08 16:49:13 -0700 | [diff] [blame] | 42 | sed -i "s/androidGradlePlugin = .*/androidGradlePlugin = \"$AGP_VERSION\"/g" gradle/libs.versions.toml |
Jeff Gaston | a4baa26 | 2021-11-02 15:29:55 -0400 | [diff] [blame] | 43 | sed -i "s/androidLint = \".*/androidLint = \"$LINT_VERSION\"/g" gradle/libs.versions.toml |
Aurimas Liutikas | 78273a3 | 2021-07-08 16:49:13 -0700 | [diff] [blame] | 44 | sed -i "s/androidStudio = .*/androidStudio = \"$STUDIO_VERSION\"/g" gradle/libs.versions.toml |
Dustin Lam | 1ecd1f2 | 2021-07-15 15:29:45 -0700 | [diff] [blame] | 45 | |
| 46 | # Pull all UTP artifacts for ADT version |
| 47 | ADT_VERSION=${3:-$LINT_VERSION} |
Aurimas Liutikas | b0470e5 | 2022-01-31 15:09:55 -0800 | [diff] [blame] | 48 | while read line |
Dustin Lam | 1ecd1f2 | 2021-07-15 15:29:45 -0700 | [diff] [blame] | 49 | do |
| 50 | ARTIFACT=`echo $line | sed 's/<\([[:lower:]-]\+\).*/\1/g'` |
Aurimas Liutikas | 4e9ba5f | 2022-01-13 16:15:21 -0800 | [diff] [blame] | 51 | ARTIFACTS_TO_DOWNLOAD+="com.android.tools.utp:$ARTIFACT:$ADT_VERSION," |
Aurimas Liutikas | b0470e5 | 2022-01-31 15:09:55 -0800 | [diff] [blame] | 52 | done < <(curl -sL "https://dl.google.com/android/maven2/com/android/tools/utp/group-index.xml" \ |
| 53 | | tail -n +3 \ |
| 54 | | head -n -1) |
Dustin Lam | 1ecd1f2 | 2021-07-15 15:29:45 -0700 | [diff] [blame] | 55 | |
Aurimas Liutikas | 5ae47e8 | 2022-06-22 17:00:45 -0700 | [diff] [blame] | 56 | ATP_VERSION=${4:-0.0.8-alpha08} |
Aurimas Liutikas | 4e9ba5f | 2022-01-13 16:15:21 -0800 | [diff] [blame] | 57 | ARTIFACTS_TO_DOWNLOAD+="com.google.testing.platform:android-test-plugin:$ATP_VERSION," |
| 58 | ARTIFACTS_TO_DOWNLOAD+="com.google.testing.platform:launcher:$ATP_VERSION," |
| 59 | ARTIFACTS_TO_DOWNLOAD+="com.google.testing.platform:android-driver-instrumentation:$ATP_VERSION," |
| 60 | ARTIFACTS_TO_DOWNLOAD+="com.google.testing.platform:core:$ATP_VERSION" |
Dustin Lam | 1ecd1f2 | 2021-07-15 15:29:45 -0700 | [diff] [blame] | 61 | |
Aurimas Liutikas | 4e9ba5f | 2022-01-13 16:15:21 -0800 | [diff] [blame] | 62 | # Download all the artifacts |
Aurimas Liutikas | 65920d3 | 2023-02-14 18:38:24 -0800 | [diff] [blame] | 63 | echoAndDo ./development/importMaven/importMaven.sh "$ARTIFACTS_TO_DOWNLOAD" |