Visitar URL original
chore: clean up synth.py script with newer tooling (#221) · benjaminp/google-cloud-java@2dba5da · GitHub
Skip to content

Commit 2dba5da

Browse files
authored
chore: clean up synth.py script with newer tooling (googleapis#221)
* chore: clean up synth.py script with newer tooling * chore: clean up synth.py script with newer tooling * update based on review comments
1 parent 9e45349 commit 2dba5da

1 file changed

Lines changed: 12 additions & 47 deletions

File tree

‎java-bigtable/synth.py‎

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,8 @@
2727
def main():
2828
gapic = gcp.GAPICGenerator()
2929

30-
# License header
31-
license = """
32-
/*
33-
* Copyright 2019 Google LLC
34-
*
35-
* Licensed under the Apache License, Version 2.0 (the "License");
36-
* you may not use this file except in compliance with the License.
37-
* You may obtain a copy of the License at
38-
*
39-
* https://www.apache.org/licenses/LICENSE-2.0
40-
*
41-
* Unless required by applicable law or agreed to in writing, software
42-
* distributed under the License is distributed on an "AS IS" BASIS,
43-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44-
* See the License for the specific language governing permissions and
45-
* limitations under the License.
46-
*/
47-
"""
48-
49-
generate_data_api(gapic, license)
50-
generate_admin_api(gapic, license)
30+
generate_data_api(gapic)
31+
generate_admin_api(gapic)
5132

5233
java.format_code(f'./google-cloud-bigtable/src')
5334

@@ -60,10 +41,10 @@ def main():
6041
'CONTRIBUTING.md',
6142
])
6243

63-
def generate_data_api(gapic, license):
44+
def generate_data_api(gapic):
6445
library = gapic.java_library(
65-
service='bigtable',
66-
version='v2',
46+
service='bigtable',
47+
version='v2',
6748
config_path='/google/bigtable/artman_bigtable.yaml',
6849
artman_output_name='')
6950

@@ -88,16 +69,10 @@ def generate_data_api(gapic, license):
8869
"google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableCallableFactory.java",
8970
]
9071

91-
package_name = f'com.google.cloud.bigtable.v2'
72+
package_name = f'com.google.bigtable.v2'
9273
java.fix_proto_headers(library / f'proto-google-cloud-bigtable-v2')
93-
# java.fix_grpc_headers(library / f'grpc-google-cloud-bigtable-v2', package_name)
94-
95-
##todo replace with fix_grpc_headers
96-
s.replace(
97-
library / f'grpc-google-cloud-bigtable-v2/src/**/*.java',
98-
f"package com.google.bigtable.v2;",
99-
f"{license}package com.google.bigtable.v2;"
100-
)
74+
java.fix_grpc_headers(library / f'grpc-google-cloud-bigtable-v2', package_name)
75+
10176
s.copy(library / f'gapic-google-cloud-bigtable-v2', 'google-cloud-bigtable/', excludes=excludes)
10277
s.copy(library / f'grpc-google-cloud-bigtable-v2/src', f'grpc-google-cloud-bigtable-v2/src')
10378
s.copy(library / f'proto-google-cloud-bigtable-v2/src', f'proto-google-cloud-bigtable-v2/src')
@@ -107,11 +82,10 @@ def generate_data_api(gapic, license):
10782
java.format_code(f'./grpc-google-cloud-bigtable-v2/src')
10883
java.format_code(f'./proto-google-cloud-bigtable-v2/src')
10984

110-
111-
def generate_admin_api(gapic, license):
85+
def generate_admin_api(gapic):
11286
library = gapic.java_library(
113-
service='bigtable-admin',
114-
version='v2',
87+
service='bigtable-admin',
88+
version='v2',
11589
config_path='/google/bigtable/admin/artman_bigtableadmin.yaml',
11690
artman_output_name='')
11791

@@ -136,14 +110,7 @@ def generate_admin_api(gapic, license):
136110

137111
package_name = f'com.google.cloud.bigtable.admin.v2'
138112
java.fix_proto_headers(library / f'proto-google-cloud-bigtable-admin-v2')
139-
# java.fix_grpc_headers(library / f'grpc-google-cloud-bigtable-admin-v2', package_name)
140-
141-
##todo replace with fix_grpc_headers
142-
s.replace(
143-
library / f'grpc-google-cloud-bigtable-admin-v2/src/**/*.java',
144-
f"package com.google.bigtable.admin.v2;",
145-
f"{license}package com.google.bigtable.admin.v2;"
146-
)
113+
java.fix_grpc_headers(library / f'grpc-google-cloud-bigtable-admin-v2', package_name)
147114

148115
s.copy(library / f'gapic-google-cloud-bigtable-admin-v2/src', 'google-cloud-bigtable/src', excludes=excludes)
149116
s.copy(library / f'grpc-google-cloud-bigtable-admin-v2/src', f'grpc-google-cloud-bigtable-admin-v2/src')
@@ -154,7 +121,6 @@ def generate_admin_api(gapic, license):
154121
java.format_code(f'./grpc-google-cloud-bigtable-admin-v2/src')
155122
java.format_code(f'./proto-google-cloud-bigtable-admin-v2/src')
156123

157-
158124
def make_internal_only(sources):
159125
"""Annotates all toplevel classes with `@InternalOnly`"""
160126
# Insert InternalOnly import in the non-static.
@@ -166,7 +132,6 @@ def make_internal_only(sources):
166132
# Replace javadoc and annotations before every public class with InternalApi
167133
# javadoc and annotation
168134
s.replace(sources,
169-
170135
before=r'/\*\*.+?\*/\n(?:^@[^\n]*\n)*(?=public [a-zA-B ]*class)',
171136
after='/** For internal use only. */\n@Generated("by gapic-generator")\n@InternalApi\n',
172137
flags=re.MULTILINE | re.DOTALL)

0 commit comments

Comments
 (0)