1#!/bin/bash
2
3set -eu
4
5echo -e "Installing maven snapshot locally...\n"
6
7bash $(dirname $0)/deploy-dagger.sh \
8  "install:install-file" \
9  "LOCAL-SNAPSHOT"
10
11bash $(dirname $0)/deploy-hilt.sh \
12  "install:install-file" \
13  "LOCAL-SNAPSHOT"
14
15echo -e "Installed local snapshot"
16
17verify_version_file() {
18  local m2_repo=$(mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout)
19  local group_path=com/google/dagger
20  local artifact_id=$1
21  local type=$2
22  local version="LOCAL-SNAPSHOT"
23  local temp_dir=$(mktemp -d)
24  local content
25  if [ $type = "jar" ]; then
26    unzip $m2_repo/$group_path/$artifact_id/$version/$artifact_id-$version.jar \
27      META-INF/com.google.dagger_$artifact_id.version \
28      -d $temp_dir
29  elif [ $type = "aar" ]; then
30    unzip $m2_repo/$group_path/$artifact_id/$version/$artifact_id-$version.aar \
31      classes.jar \
32      -d $temp_dir
33    unzip $temp_dir/classes.jar \
34      META-INF/com.google.dagger_$artifact_id.version \
35      -d $temp_dir
36  fi
37  local content=$(cat $temp_dir/META-INF/com.google.dagger_${artifact_id}.version)
38  if [[ $content != $version ]]; then
39    echo "Version file failed verification for artifact: $artifact_id"
40    exit 1
41  fi
42}
43
44# Verify tracking version file in Dagger and Dagger Android
45verify_version_file "dagger" "jar"
46verify_version_file "dagger-android" "aar"
47