• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3set -eu
4
5readonly MVN_GOAL="$1"
6readonly VERSION_NAME="$2"
7shift 2
8readonly EXTRA_MAVEN_ARGS=("$@")
9
10# Builds and deploy the Gradle plugin.
11_deploy_plugin() {
12  local plugindir=java/dagger/hilt/android/plugin
13  ./$plugindir/gradlew -p $plugindir --no-daemon clean \
14    publishAllPublicationsToMavenRepository -PPublishVersion="$VERSION_NAME"
15  local outdir=$plugindir/build/repo/com/google/dagger/hilt-android-gradle-plugin/$VERSION_NAME
16  local markerOutDir=$plugindir/build/repo/com/google/dagger/hilt/android/com.google.dagger.hilt.android.gradle.plugin/$VERSION_NAME
17  # When building '-SNAPSHOT' versions in gradle, the filenames replaces
18  # '-SNAPSHOT' with timestamps, so we need to disambiguate by finding each file
19  # to deploy. See: https://stackoverflow.com/questions/54182823/
20  local suffix
21  if [[ "$VERSION_NAME" == *"-SNAPSHOT" ]]; then
22    # Gets the timestamp part out of the name to be used as suffix.
23    # Timestamp format is ########.######-#.
24    suffix=$(find $outdir -name "*.pom" | grep -Eo '[0-9]{8}\.[0-9]{6}-[0-9]{1}')
25  else
26    suffix=$VERSION_NAME
27  fi
28  mvn "$MVN_GOAL" \
29    -Dfile="$(find $outdir -name "*-$suffix.jar")" \
30    -DpomFile="$(find $outdir -name "*-$suffix.pom")" \
31    -Dsources="$(find $outdir -name "*-$suffix-sources.jar")" \
32    -Djavadoc="$(find $outdir -name "*-$suffix-javadoc.jar")" \
33    "${EXTRA_MAVEN_ARGS[@]:+${EXTRA_MAVEN_ARGS[@]}}"
34  mvn "$MVN_GOAL" \
35    -Dfile="$(find $markerOutDir -name "*-$suffix.pom")" \
36    -DpomFile="$(find $markerOutDir -name "*-$suffix.pom")" \
37    "${EXTRA_MAVEN_ARGS[@]:+${EXTRA_MAVEN_ARGS[@]}}"
38}
39
40# Gradle Plugin is built with Gradle, but still deployed via Maven (mvn)
41_deploy_plugin