Skip to content

Commit 7ef6fb0

Browse files
committed
fix(firestore): rename internal Version class to FirestoreAdminVersion to avoid duplicate class conflict
1 parent 6ce7a49 commit 7ef6fb0

4 files changed

Lines changed: 25 additions & 4 deletions

File tree

‎java-firestore/.OwlBot-hermetic.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ deep-remove-regex:
44
- /java-firestore/google-cloud-firestore/src/.*/java/com/google/cloud/firestore/v1/
55
- /java-firestore/google-cloud-firestore-admin/src
66
deep-preserve-regex:
7-
- /java-firestore/.*google-.*/src/main/java/.*/stub/Version.java
7+
- /java-firestore/.*google-.*/src/main/java/.*/stub/(Version|FirestoreAdminVersion).java
88
- /java-firestore/google-.*/src/test/java/com/google/cloud/.*/v.*/it/IT.*Test.java
99
- /java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentPathName.java
1010
- /java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AnyPathName.java

‎java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ protected LibraryMetadata getLibraryMetadata() {
757757
return LibraryMetadata.newBuilder()
758758
.setArtifactName("com.google.cloud:google-cloud-firestore")
759759
.setRepository("googleapis/google-cloud-java")
760-
.setVersion(Version.VERSION)
760+
.setVersion(FirestoreAdminVersion.VERSION)
761761
.build();
762762
}
763763

java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/Version.java renamed to java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import com.google.api.core.InternalApi;
2020

2121
@InternalApi("For internal use only")
22-
final class Version {
22+
final class FirestoreAdminVersion {
2323
// {x-version-update-start:google-cloud-firestore:current}
2424
static final String VERSION = "3.43.0";
2525
// {x-version-update-end}

‎java-firestore/owlbot.py‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
'This script is used to synthesize generated parts of this library.'
1919
import json
20+
import os
2021
protobuf_header = '// Generated by the protocol buffer compiler. DO NOT EDIT!'
2122
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'
2223
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,10 +39,30 @@
3839
service = 'firestore'
3940
version = 'v1'
4041
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'
4243
s.replace(f'owl-bot-staging/v1/grpc-google-cloud-{service}-{version}-java/src/**/*.java', bad_license_header, license_header)
4344
s.replace(f'owl-bot-staging/v1/proto-google-cloud-{service}-{version}-java/src/**/*.java', bad_license_header, license_header)
4445
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)
4566
s.remove_staging_dirs()
4667
java.common_templates(
4768
monorepo=True,

0 commit comments

Comments
 (0)