-
Notifications
You must be signed in to change notification settings - Fork 390
Expand file tree
/
Copy pathutils.sh
More file actions
42 lines (34 loc) · 1.49 KB
/
utils.sh
File metadata and controls
42 lines (34 loc) · 1.49 KB
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
#!/bin/bash
generate_from_discovery() {
discovery=$1
variant=$2
compile=$3
if [[ -z "${compile}" ]]; then
compile="false"
fi
service=$(basename ${discovery} | cut -d. -f1)
version=$(basename ${discovery} | sed 's/\.json//' | cut -d. -f2-)
target_dir=${root_dir}/google-api-java-client-services/clients/google-api-services-${service}/${version}/${variant}
output_dir=$(mktemp -d)
python3 -m googleapis.codegen \
--output_dir=${output_dir} \
--input=${discovery} \
--language=java \
--language_variant=${variant} \
--package_path=api/services
# for new libraries, we create the destination folder
mkdir -p "${target_dir}"
# transfer generated source into the wiped-out service's source folder
rm -rdf ${target_dir}/*
cp -r ${output_dir}/* "${target_dir}"
# Copy the latest variant's README to the main service location
# Generation of libraries with older variants should not update the root README
cp ${root_dir}/google-api-java-client-services/clients/google-api-services-${service}/${version}/${variant}/README.md ${root_dir}/google-api-java-client-services/clients/google-api-services-${service}/${version}/README.md
if [[ "${compile}" == "true" ]];then
pushd ${root_dir}/google-api-java-client-services/clients/google-api-services-${service}/${version}/${variant}
# failed_libs should be exported from the calling script
mvn compile || basename "${discovery}" >> "${failed_libs}"
popd
fi
}
export -f generate_from_discovery