forked from google/jsinterop-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_jsinterop_generator.sh
executable file
·78 lines (60 loc) · 2.23 KB
/
release_jsinterop_generator.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
77
78
#!/bin/bash -i
# The script generates the open source artifacts for jsinterop generator (closure only) and
# upload them to sonatype.
set -e
lib_version=$1
if [ -z ${lib_version} ]; then
echo "Please specify the lib version."
exit 1;
fi
bazel_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
merge_jars() {
tmp_directory=$(mktemp -d)
jars=$1
cd ${tmp_directory}
for jar in ${jars[@]}; do
jar xf ${bazel_root}/bazel-bin/java/jsinterop/generator/${jar}
done
jar cf $2 .
mv $2 $3
cd -
rm -rf ${tmp_directory}
}
deploy_target='@com_google_jsinterop_base//:deploy'
license_header="--no-license"
group_id="com.google.jsinterop"
maven_artifact="closure-generator"
bazel_rules=("closure:libclosure-src.jar" "closure/helper:libhelper-src.jar" \
"closure/visitor:libvisitor-src.jar" "helper:libhelper-src.jar" \
"model:libmodel-src.jar" "visitor:libvisitor-src.jar" \
"writer:libwriter-src.jar" "closure:libclosure.jar" \
"closure/helper:libhelper.jar" "closure/visitor:libvisitor.jar" \
"helper:libhelper.jar" "model:libmodel.jar" \
"visitor:libvisitor.jar" "writer:libwriter.jar")
jars=("closure/libclosure.jar" "closure/helper/libhelper.jar" \
"closure/visitor/libvisitor.jar" "helper/libhelper.jar" \
"model/libmodel.jar" "visitor/libvisitor.jar" \
"writer/libwriter.jar")
src_jars=("closure/libclosure-src.jar" "closure/helper/libhelper-src.jar" \
"closure/visitor/libvisitor-src.jar" "helper/libhelper-src.jar" \
"model/libmodel-src.jar" "visitor/libvisitor-src.jar" \
"writer/libwriter-src.jar")
cd ${bazel_root}
for rule in ${bazel_rules[@]}; do
bazel build //java/jsinterop/generator/${rule}
done
tmp_artifact_dir=$(mktemp -d)
merge_jars ${jars} generator.jar ${tmp_artifact_dir}
merge_jars ${src_jars} generator-src.jar ${tmp_artifact_dir}
pom_template=${bazel_root}/maven/pom-closure-generator.xml
# we cannot run the script directly from Bazel as bazel doesn't allow interactive script
runcmd="$(mktemp /tmp/bazel-run.XXXXXX)"
bazel run --script_path="$runcmd" ${deploy_target} -- ${maven_artifact} \
${tmp_artifact_dir}/generator.jar \
${tmp_artifact_dir}/generator-src.jar \
${license_header} \
${pom_template} \
${lib_version} \
${group_id}
"$runcmd"
rm "$runcmd"