|
17 | 17 |
|
18 | 18 | 'This script is used to synthesize generated parts of this library.' |
19 | 19 | import json |
| 20 | +import os |
20 | 21 | protobuf_header = '// Generated by the protocol buffer compiler. DO NOT EDIT!' |
21 | 22 | license_header = '/*\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n' |
22 | 23 | bad_license_header = '/\\*\n \\* Copyright 2018 Google LLC\n \\*\n \\* Licensed under the Apache License, Version 2.0 \\(the "License"\\); you may not use this file except\n \\* in compliance with the License. You may obtain a copy of the License at\n \\*\n \\* http://www.apache.org/licenses/LICENSE-2.0\n \\*\n \\* Unless required by applicable law or agreed to in writing, software distributed under the License\n \\* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\n \\* or implied. See the License for the specific language governing permissions and limitations under\n \\* the License.\n \\*/\n' |
|
38 | 39 | service = 'firestore' |
39 | 40 | version = 'v1' |
40 | 41 | s.replace(f'owl-bot-staging/v1/proto-google-cloud-{service}-{version}-java/src/**/*.java', protobuf_header, f'{license_header}{protobuf_header}') |
41 | | - service == 'firestore-admin' |
| 42 | + service = 'firestore-admin' |
42 | 43 | s.replace(f'owl-bot-staging/v1/grpc-google-cloud-{service}-{version}-java/src/**/*.java', bad_license_header, license_header) |
43 | 44 | s.replace(f'owl-bot-staging/v1/proto-google-cloud-{service}-{version}-java/src/**/*.java', bad_license_header, license_header) |
44 | 45 | s.move(library) |
| 46 | + |
| 47 | + # Rename Version.java in google-cloud-firestore-admin to FirestoreAdminVersion.java |
| 48 | + admin_version_path = "google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/Version.java" |
| 49 | + if os.path.exists(admin_version_path): |
| 50 | + target_path = "google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminVersion.java" |
| 51 | + with open(admin_version_path, 'r') as f: |
| 52 | + content = f.read() |
| 53 | + content = content.replace("class Version", "class FirestoreAdminVersion") |
| 54 | + with open(target_path, 'w') as f: |
| 55 | + f.write(content) |
| 56 | + os.remove(admin_version_path) |
| 57 | + |
| 58 | + # Replace Version.VERSION with FirestoreAdminVersion.VERSION in FirestoreAdminStubSettings.java |
| 59 | + settings_path = "google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java" |
| 60 | + if os.path.exists(settings_path): |
| 61 | + with open(settings_path, 'r') as f: |
| 62 | + content = f.read() |
| 63 | + content = content.replace("Version.VERSION", "FirestoreAdminVersion.VERSION") |
| 64 | + with open(settings_path, 'w') as f: |
| 65 | + f.write(content) |
45 | 66 | s.remove_staging_dirs() |
46 | 67 | java.common_templates( |
47 | 68 | monorepo=True, |
|
0 commit comments