1#!/bin/bash
2# Expected arguments:
3# $1 = out_dir
4# $2 = dist_dir
5# $3 = build_number
6
7# exit on error
8set -e
9
10if [ $# -ne 3 ]
11then
12  echo "Usage: $0 <out_dir> <dest_dir> <build_number>" > /dev/stderr
13  echo "Given arguments: $*" > /dev/stderr
14  exit 1
15fi
16
17PROG_DIR=$(dirname "$0")
18
19cd "$PROG_DIR"/../../..
20ANDROID_SRC="$PWD"
21
22OUT="$1"
23DIST="$2"
24BNUM="$3"
25
26echo "ANDROID_SRC=$ANDROID_SRC"
27echo "OUT=$OUT"
28echo "DIST=$DIST"
29echo "BNUM=$BNUM"
30
31# Steps to build Eclipse
32# 1. Generate Maven repository containing all tools
33echo Running gradle to build tools libraries...
34cd "$ANDROID_SRC"/tools
35./gradlew --no-daemon publishLocal
36
37# 2. Copy dependent jars into the libs folder of each plugin
38echo Copying jars to be embedded inside the ADT plugins
39cd "$ANDROID_SRC"
40./tools/gradlew -i -b sdk/eclipse/build.gradle --no-daemon copydeps
41
42# 3. Launch Tycho build
43echo Launching Tycho to build ADT plugins and bundle
44( set -x ; BUILD_NUMBER="$BNUM" ./tools/gradlew -i -b sdk/eclipse/build.gradle --no-daemon buildEclipse)
45
46echo Copying ADT plugins and bundle into destination folder
47cd "$ANDROID_SRC"
48cp -rv out/host/maven/bundles-*/products/*.zip "$DIST"/
49cp -rv out/host/maven/p2repo-*/p2repo-*.zip "$DIST"/p2repo-$BNUM.zip
50