-
Notifications
You must be signed in to change notification settings - Fork 53
/
update.sh
executable file
·76 lines (67 loc) · 2.39 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
# This script is executed by ../BUILD.bazel as a final post-generation step.
set -o errexit
BAZEL_ROOT=$PWD
clear_existing() {
cd "$BUILD_WORKSPACE_DIRECTORY/showcase/$1"
find . -name '*.java' -not -path '*/it/*' -delete
find . -name 'gapic_metadata.json' -delete
cd -
}
create_unpack_dir() {
cd "$BAZEL_ROOT"
rm -rf "$1"
mkdir "$1"
cd "$1"
}
delete_unneeded() {
find . -name '.DS_Store' -delete
find . -name 'PlaceholderFile.java' -delete
find . -type d -empty -delete
}
case $1 in
proto)
PROTO_PROJECT_DIR=proto-gapic-showcase-v1beta1
PROTO_ARCHIVE=$(find . -name 'proto-google-cloud-showcase-v1beta1-java.tar.gz')
clear_existing $PROTO_PROJECT_DIR
create_unpack_dir proto_unpacked
PROTO_UNPACK_DIR=$PWD
tar -xzf "$BAZEL_ROOT/$PROTO_ARCHIVE"
delete_unneeded
cd "$BUILD_WORKSPACE_DIRECTORY/showcase/$PROTO_PROJECT_DIR"
mkdir -p ./src
cp -r "$PROTO_UNPACK_DIR"/proto-google-cloud-showcase-v1beta1-java/src/* ./src
# when bazel references external repositories, the output of proto java
# libraries will store the source protos using the full bazel reference path
# (i.e. @com_google_gapic_showcase as "external" repo). This is a surface
# modification to have the proto structure matching the output of the
# hermetic build script
mv ./src/main/proto/external/com_google_gapic_showcase/schema ./src/main/proto
rm -rd ./src/main/proto/external
;;
grpc)
GRPC_PROJECT_DIR=grpc-gapic-showcase-v1beta1
GRPC_JAR=$(find . -name 'libshowcase_java_grpc-src.jar')
# GRPC_JAR_EXTENDED=$(find . -name 'libshowcase_java_grpc_extended-src.jar')
clear_existing $GRPC_PROJECT_DIR
create_unpack_dir grpc_unpacked
GRPC_UNPACK_DIR=$PWD
jar xf "$BAZEL_ROOT/$GRPC_JAR"
# jar xf "$BAZEL_ROOT/$GRPC_JAR_EXTENDED"
cd "$BUILD_WORKSPACE_DIRECTORY/showcase/$GRPC_PROJECT_DIR"
mkdir -p ./src/main/java/com
cp -r "$GRPC_UNPACK_DIR"/com/* ./src/main/java/com
;;
gapic)
GAPIC_PROJECT_DIR=gapic-showcase
GAPIC_JAR=$(find . -name 'showcase_java_gapic_srcjar_raw.srcjar')
clear_existing $GAPIC_PROJECT_DIR
create_unpack_dir gapic_unpacked
GAPIC_UNPACK_DIR=$PWD
unzip -q -c "$BAZEL_ROOT/$GAPIC_JAR" temp-codegen.srcjar | jar x
cd "$BUILD_WORKSPACE_DIRECTORY/showcase/$GAPIC_PROJECT_DIR"
cp -r "$GAPIC_UNPACK_DIR"/* ./
;;
esac
cd "${BUILD_WORKSPACE_DIRECTORY}/showcase"
delete_unneeded