• 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 deploys the given artifacts to a configured maven goal.
11# @param {string} library the library to deploy.
12# @param {string} pomfile the pom file to deploy.
13# @param {string} srcjar the sources jar of the library. This is an optional
14# parameter, if provided then javadoc must also be provided.
15# @param {string} javadoc the java doc jar of the library. This is an optional
16# parameter, if provided then srcjar must also be provided.
17_deploy() {
18  local library=$1
19  local pomfile=$2
20  local srcjar=$3
21  local javadoc=$4
22  bash $(dirname $0)/deploy-library.sh \
23      "$library" \
24      "$pomfile" \
25      "$srcjar" \
26      "$javadoc" \
27      "$MVN_GOAL" \
28      "$VERSION_NAME" \
29      "${EXTRA_MAVEN_ARGS[@]:+${EXTRA_MAVEN_ARGS[@]}}"
30}
31
32_deploy \
33  java/dagger/hilt/android/artifact.aar \
34  java/dagger/hilt/android/pom.xml \
35  java/dagger/hilt/android/artifact-src.jar \
36  java/dagger/hilt/android/artifact-javadoc.jar
37
38_deploy \
39  java/dagger/hilt/android/testing/artifact.aar \
40  java/dagger/hilt/android/testing/pom.xml \
41  java/dagger/hilt/android/testing/artifact-src.jar \
42  java/dagger/hilt/android/testing/artifact-javadoc.jar
43
44_deploy \
45  java/dagger/hilt/processor/artifact.jar \
46  java/dagger/hilt/processor/pom.xml \
47  java/dagger/hilt/processor/artifact-src.jar \
48  java/dagger/hilt/processor/artifact-javadoc.jar
49
50_deploy \
51  java/dagger/hilt/android/processor/artifact.jar \
52  java/dagger/hilt/android/processor/pom.xml \
53  java/dagger/hilt/android/processor/artifact-src.jar \
54  java/dagger/hilt/android/processor/artifact-javadoc.jar
55
56_deploy \
57  java/dagger/hilt/artifact-core.jar \
58  java/dagger/hilt/pom.xml \
59  java/dagger/hilt/artifact-core-src.jar \
60  java/dagger/hilt/artifact-core-javadoc.jar
61
62# Builds and deploy the Gradle plugin.
63_deploy_plugin() {
64  local plugindir=java/dagger/hilt/android/plugin
65  ./$plugindir/gradlew -p $plugindir --no-daemon clean \
66    publishAllPublicationsToMavenRepository -PPublishVersion="$VERSION_NAME"
67  local outdir=$plugindir/build/repo/com/google/dagger/hilt-android-gradle-plugin/$VERSION_NAME
68  # When building '-SNAPSHOT' versions in gradle, the filenames replaces
69  # '-SNAPSHOT' with timestamps, so we need to disambiguate by finding each file
70  # to deploy. See: https://stackoverflow.com/questions/54182823/
71  local suffix
72  if [[ "$VERSION_NAME" == *"-SNAPSHOT" ]]; then
73    # Gets the timestamp part out of the name to be used as suffix.
74    # Timestamp format is ########.######-#.
75    suffix=$(find $outdir -name "*.pom" | grep -Eo '[0-9]{8}\.[0-9]{6}-[0-9]{1}')
76  else
77    suffix=$VERSION_NAME
78  fi
79  mvn "$MVN_GOAL" \
80    -Dfile="$(find $outdir -name "*-$suffix.jar")" \
81    -DpomFile="$(find $outdir -name "*-$suffix.pom")" \
82    -Dsources="$(find $outdir -name "*-$suffix-sources.jar")" \
83    -Djavadoc="$(find $outdir -name "*-$suffix-javadoc.jar")" \
84    "${EXTRA_MAVEN_ARGS[@]:+${EXTRA_MAVEN_ARGS[@]}}"
85}
86
87# Gradle Plugin is built with Gradle, but still deployed via Maven (mvn)
88_deploy_plugin
89