diff --git a/java-common-protos/codecov.yaml b/java-common-protos/codecov.yaml deleted file mode 100644 index 5724ea9478..0000000000 --- a/java-common-protos/codecov.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -codecov: - ci: - - source.cloud.google.com diff --git a/java-common-protos/owlbot.py b/java-common-protos/owlbot.py index dd6b0d767f..ffada9aa43 100644 --- a/java-common-protos/owlbot.py +++ b/java-common-protos/owlbot.py @@ -44,6 +44,7 @@ "SECURITY.md", "java.header", "license-checks.xml", + "README.md", "renovate.json", ".gitignore" ]) diff --git a/java-iam/codecov.yaml b/java-iam/codecov.yaml deleted file mode 100644 index 5724ea9478..0000000000 --- a/java-iam/codecov.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- -codecov: - ci: - - source.cloud.google.com diff --git a/library_generation/generate_repo.py b/library_generation/generate_repo.py index af70bcc1f2..214cd78648 100755 --- a/library_generation/generate_repo.py +++ b/library_generation/generate_repo.py @@ -48,7 +48,6 @@ def generate_from_yaml( for library_path, library in repo_config.libraries.items(): print(f"generating library {library.get_library_name()}") - generate_composed_library( config_path=config_path, config=config, @@ -58,8 +57,7 @@ def generate_from_yaml( versions_file=repo_config.versions_file, ) - # we skip monorepo_postprocessing if not in a monorepo - if not config.is_monorepo(): + if not config.is_monorepo() or config.contains_common_protos(): return monorepo_postprocessing( diff --git a/library_generation/model/gapic_inputs.py b/library_generation/model/gapic_inputs.py index 4bb9ce64f4..992e4c2e3c 100644 --- a/library_generation/model/gapic_inputs.py +++ b/library_generation/model/gapic_inputs.py @@ -56,7 +56,7 @@ def __init__( self, proto_only="true", additional_protos="google/cloud/common_resources.proto", - transport="", + transport="grpc", rest_numeric_enum="", gapic_yaml="", service_config="", diff --git a/library_generation/model/generation_config.py b/library_generation/model/generation_config.py index bc9c5e3f20..3557cf63d2 100644 --- a/library_generation/model/generation_config.py +++ b/library_generation/model/generation_config.py @@ -20,6 +20,7 @@ REPO_LEVEL_PARAMETER = "Repo level parameter" LIBRARY_LEVEL_PARAMETER = "Library level parameter" GAPIC_LEVEL_PARAMETER = "GAPIC level parameter" +COMMON_PROTOS_LIBRARY_NAME = "common-protos" class GenerationConfig: @@ -31,9 +32,9 @@ def __init__( self, gapic_generator_version: str, googleapis_commitish: str, - libraries_bom_version: str, template_excludes: list[str], libraries: list[LibraryConfig], + libraries_bom_version: Optional[str] = None, grpc_version: Optional[str] = None, protoc_version: Optional[str] = None, ): @@ -44,6 +45,9 @@ def __init__( self.libraries = libraries self.grpc_version = grpc_version self.protoc_version = protoc_version + # explicit set to None so that we can compute the + # value in getter. + self.__contains_common_protos = None self.__validate() def get_proto_path_to_library_name(self) -> dict[str, str]: @@ -61,6 +65,15 @@ def get_proto_path_to_library_name(self) -> dict[str, str]: def is_monorepo(self) -> bool: return len(self.libraries) > 1 + def contains_common_protos(self) -> bool: + if self.__contains_common_protos is None: + self.__contains_common_protos = False + for library in self.libraries: + if library.get_library_name() == COMMON_PROTOS_LIBRARY_NAME: + self.__contains_common_protos = True + break + return self.__contains_common_protos + def __validate(self) -> None: seen_library_names = dict() for library in self.libraries: @@ -133,15 +146,13 @@ def from_yaml(path_to_yaml: str) -> GenerationConfig: gapic_generator_version=__required( config, "gapic_generator_version", REPO_LEVEL_PARAMETER ), - grpc_version=__optional(config, "grpc_version", None), - protoc_version=__optional(config, "protoc_version", None), googleapis_commitish=__required( config, "googleapis_commitish", REPO_LEVEL_PARAMETER ), - libraries_bom_version=__required( - config, "libraries_bom_version", REPO_LEVEL_PARAMETER - ), template_excludes=__required(config, "template_excludes", REPO_LEVEL_PARAMETER), + grpc_version=__optional(config, "grpc_version", None), + protoc_version=__optional(config, "protoc_version", None), + libraries_bom_version=__optional(config, "libraries_bom_version", None), libraries=parsed_libraries, ) diff --git a/library_generation/test/cli/entry_point_unit_tests.py b/library_generation/test/cli/entry_point_unit_tests.py index ace2794684..55fb583651 100644 --- a/library_generation/test/cli/entry_point_unit_tests.py +++ b/library_generation/test/cli/entry_point_unit_tests.py @@ -22,6 +22,7 @@ class EntryPointTest(unittest.TestCase): def test_entry_point_without_config_raise_file_exception(self): + os.chdir(script_dir) runner = CliRunner() # noinspection PyTypeChecker result = runner.invoke(generate, ["--repository-path=."]) diff --git a/library_generation/test/model/gapic_inputs_unit_tests.py b/library_generation/test/model/gapic_inputs_unit_tests.py new file mode 100644 index 0000000000..210d321591 --- /dev/null +++ b/library_generation/test/model/gapic_inputs_unit_tests.py @@ -0,0 +1,132 @@ +import os +import unittest +from pathlib import Path + +from parameterized import parameterized +from library_generation.model.gapic_inputs import parse + +script_dir = os.path.dirname(os.path.realpath(__file__)) +resources_dir = os.path.join(script_dir, "..", "resources") +build_file = Path(os.path.join(resources_dir, "misc")).resolve() + + +class UtilitiesTest(unittest.TestCase): + @parameterized.expand( + [ + ("BUILD_no_additional_protos.bazel", " "), + ("BUILD_common_resources.bazel", " google/cloud/common_resources.proto"), + ("BUILD_comment_common_resources.bazel", " "), + ("BUILD_locations.bazel", " google/cloud/location/locations.proto"), + ("BUILD_comment_locations.bazel", " "), + ("BUILD_iam_policy.bazel", " google/iam/v1/iam_policy.proto"), + ("BUILD_comment_iam_policy.bazel", " "), + ( + "BUILD_iam_locations.bazel", + " google/cloud/location/locations.proto google/iam/v1/iam_policy.proto", + ), + ] + ) + def test_gapic_inputs_parse_additional_protos(self, build_name, expected): + parsed = parse(build_file, "", build_name) + self.assertEqual( + expected, + parsed.additional_protos, + ) + + def test_gapic_inputs_parse_grpc_only_succeeds(self): + parsed = parse(build_file, "", "BUILD_grpc.bazel") + self.assertEqual("grpc", parsed.transport) + + def test_gapic_inputs_parse_grpc_rest_succeeds(self): + parsed = parse(build_file, "", "BUILD_grpc_rest.bazel") + self.assertEqual("grpc+rest", parsed.transport) + + def test_gapic_inputs_parse_rest_succeeds(self): + parsed = parse(build_file, "", "BUILD_rest.bazel") + self.assertEqual("rest", parsed.transport) + + def test_gapic_inputs_parse_empty_include_samples_succeeds(self): + parsed = parse(build_file, "", "BUILD_include_samples_empty.bazel") + self.assertEqual("false", parsed.include_samples) + + def test_gapic_inputs_parse_include_samples_false_succeeds(self): + parsed = parse(build_file, "", "BUILD_include_samples_false.bazel") + self.assertEqual("false", parsed.include_samples) + + def test_gapic_inputs_parse_include_samples_true_succeeds(self): + parsed = parse(build_file, "", "BUILD_include_samples_true.bazel") + self.assertEqual("true", parsed.include_samples) + + def test_gapic_inputs_parse_empty_rest_numeric_enums_succeeds(self): + parsed = parse(build_file, "", "BUILD_rest_numeric_enums_empty.bazel") + self.assertEqual("false", parsed.rest_numeric_enum) + + def test_gapic_inputs_parse_rest_numeric_enums_false_succeeds(self): + parsed = parse(build_file, "", "BUILD_rest_numeric_enums_false.bazel") + self.assertEqual("false", parsed.rest_numeric_enum) + + def test_gapic_inputs_parse_rest_numeric_enums_true_succeeds(self): + parsed = parse(build_file, "", "BUILD_rest_numeric_enums_true.bazel") + self.assertEqual("true", parsed.rest_numeric_enum) + + def test_gapic_inputs_parse_no_gapic_library_returns_proto_only_true(self): + # include_samples_empty only has a gradle assembly rule + parsed = parse(build_file, "", "BUILD_include_samples_empty.bazel") + self.assertEqual("true", parsed.proto_only) + + def test_gapic_inputs_parse_with_gapic_library_returns_proto_only_false(self): + # rest.bazel has a java_gapic_library rule + parsed = parse(build_file, "", "BUILD_rest.bazel") + self.assertEqual("false", parsed.proto_only) + + def test_gapic_inputs_parse_gapic_yaml_succeeds(self): + parsed = parse(build_file, "test/versioned/path", "BUILD_gapic_yaml.bazel") + self.assertEqual("test/versioned/path/test_gapic_yaml.yaml", parsed.gapic_yaml) + + def test_gapic_inputs_parse_no_gapic_yaml_returns_empty_string(self): + parsed = parse(build_file, "test/versioned/path", "BUILD_no_gapic_yaml.bazel") + self.assertEqual("", parsed.gapic_yaml) + + def test_gapic_inputs_parse_service_config_succeeds(self): + parsed = parse(build_file, "test/versioned/path", "BUILD_service_config.bazel") + self.assertEqual( + "test/versioned/path/test_service_config.json", parsed.service_config + ) + + def test_gapic_inputs_parse_service_yaml_relative_target(self): + parsed = parse( + build_file, + "google/cloud/compute/v1", + "BUILD_service_config_relative_target.bazel", + ) + self.assertEqual( + "google/cloud/compute/v1/compute_grpc_service_config.json", + parsed.service_config, + ) + + def test_gapic_inputs_parse_no_service_config_returns_empty_string(self): + parsed = parse( + build_file, "test/versioned/path", "BUILD_no_service_config.bazel" + ) + self.assertEqual("", parsed.service_config) + + def test_gapic_inputs_parse_service_yaml_succeeds(self): + parsed = parse(build_file, "test/versioned/path", "BUILD_service_yaml.bazel") + self.assertEqual( + "test/versioned/path/test_service_yaml.yaml", parsed.service_yaml + ) + + def test_gapic_inputs_parse_service_yaml_absolute_target(self): + parsed = parse(build_file, "", "BUILD_service_yaml_absolute_target.bazel") + self.assertEqual( + "google/cloud/videointelligence/videointelligence_v1p3beta1.yaml", + parsed.service_yaml, + ) + + def test_gapic_inputs_parse_no_service_yaml_returns_empty_string(self): + parsed = parse(build_file, "test/versioned/path", "BUILD_no_service_yaml.bazel") + self.assertEqual("", parsed.service_yaml) + + def test_gapic_inputs_parse_proto_only_returns_grpc(self): + parsed = parse(build_file, "test/versioned/path", "BUILD_proto_only.bazel") + self.assertEqual("grpc", parsed.transport) diff --git a/library_generation/test/model/generation_config_unit_test.py b/library_generation/test/model/generation_config_unit_tests.py similarity index 90% rename from library_generation/test/model/generation_config_unit_test.py rename to library_generation/test/model/generation_config_unit_tests.py index d9efb494c0..8f94ecae1e 100644 --- a/library_generation/test/model/generation_config_unit_test.py +++ b/library_generation/test/model/generation_config_unit_tests.py @@ -35,6 +35,13 @@ product_documentation="", gapic_configs=[], ) +common_protos_library = LibraryConfig( + api_shortname="common-protos", + api_description="", + name_pretty="", + product_documentation="", + gapic_configs=[], +) class GenerationConfigTest(unittest.TestCase): @@ -123,6 +130,26 @@ def test_is_monorepo_with_two_libraries_returns_true(self): ) self.assertTrue(config.is_monorepo()) + def test_contains_common_protos_with_common_protos_returns_true(self): + config = GenerationConfig( + gapic_generator_version="", + googleapis_commitish="", + libraries_bom_version="", + template_excludes=[], + libraries=[library_1, library_2, common_protos_library], + ) + self.assertTrue(config.contains_common_protos()) + + def test_contains_common_protos_without_common_protos_returns_false(self): + config = GenerationConfig( + gapic_generator_version="", + googleapis_commitish="", + libraries_bom_version="", + template_excludes=[], + libraries=[library_1, library_2], + ) + self.assertFalse(config.contains_common_protos()) + def test_validate_with_duplicate_library_name_raise_exception(self): self.assertRaisesRegex( ValueError, @@ -131,8 +158,6 @@ def test_validate_with_duplicate_library_name_raise_exception(self): gapic_generator_version="", googleapis_commitish="", libraries_bom_version="", - owlbot_cli_image="", - synthtool_commitish="", template_excludes=[], libraries=[ LibraryConfig( @@ -169,30 +194,6 @@ def test_from_yaml_without_googleapis_commitish_raise_exception(self): f"{test_config_dir}/config_without_googleapis.yaml", ) - def test_from_yaml_without_libraries_bom_version_raise_exception(self): - self.assertRaisesRegex( - ValueError, - "Repo level parameter, libraries_bom_version", - from_yaml, - f"{test_config_dir}/config_without_libraries_bom_version.yaml", - ) - - def test_from_yaml_without_owlbot_cli_image_raise_exception(self): - self.assertRaisesRegex( - ValueError, - "Repo level parameter, owlbot_cli_image", - from_yaml, - f"{test_config_dir}/config_without_owlbot.yaml", - ) - - def test_from_yaml_without_synthtool_commitish_raise_exception(self): - self.assertRaisesRegex( - ValueError, - "Repo level parameter, synthtool_commitish", - from_yaml, - f"{test_config_dir}/config_without_synthtool.yaml", - ) - def test_from_yaml_without_template_excludes_raise_exception(self): self.assertRaisesRegex( ValueError, diff --git a/library_generation/test/resources/goldens/.repo-metadata-proto-only-golden.json b/library_generation/test/resources/goldens/.repo-metadata-proto-only-golden.json new file mode 100644 index 0000000000..995607bae4 --- /dev/null +++ b/library_generation/test/resources/goldens/.repo-metadata-proto-only-golden.json @@ -0,0 +1,17 @@ +{ + "api_shortname": "baremetalsolution", + "name_pretty": "Bare Metal Solution", + "product_documentation": "https://cloud.google.com/bare-metal/docs", + "api_description": "Bring your Oracle workloads to Google Cloud with Bare Metal Solution and jumpstart your cloud journey with minimal risk.", + "client_documentation": "https://cloud.google.com/java/docs/reference/google-cloud-bare-metal-solution/latest/overview", + "release_level": "preview", + "transport": "grpc", + "language": "java", + "repo": "googleapis/sdk-platform-java", + "repo_short": "java-bare-metal-solution", + "distribution_name": "com.google.cloud:google-cloud-bare-metal-solution", + "library_type": "OTHER", + "requires_billing": true, + "rest_documentation": "https://cloud.google.com/bare-metal/docs/reference/rest", + "rpc_documentation": "https://cloud.google.com/bare-metal/docs/reference/rpc" +} \ No newline at end of file diff --git a/library_generation/test/resources/misc/BUILD_proto_only.bazel b/library_generation/test/resources/misc/BUILD_proto_only.bazel new file mode 100644 index 0000000000..26bcea6126 --- /dev/null +++ b/library_generation/test/resources/misc/BUILD_proto_only.bazel @@ -0,0 +1,16 @@ +java_gapic_assembly_gradle_pkg( + name = "google-api-java", + transport = "grpc+rest", + deps = [ + "annotations_proto", + "auth_proto", + "backend_proto", + "billing_proto", + "client_proto", + "config_change_proto", + "consumer_proto", + "context_proto", + "control_proto", + "distribution_proto", + ], +) \ No newline at end of file diff --git a/library_generation/test/utilities_unit_tests.py b/library_generation/test/utilities_unit_tests.py index 96c03087fa..565d0063da 100644 --- a/library_generation/test/utilities_unit_tests.py +++ b/library_generation/test/utilities_unit_tests.py @@ -21,19 +21,15 @@ import io import contextlib from pathlib import Path -from parameterized import parameterized from library_generation.utils import utilities as util from library_generation.model.gapic_config import GapicConfig from library_generation.model.generation_config import GenerationConfig -from library_generation.model.gapic_inputs import parse as parse_build_file from library_generation.model.library_config import LibraryConfig from library_generation.test.test_utils import FileComparator from library_generation.test.test_utils import cleanup script_dir = os.path.dirname(os.path.realpath(__file__)) resources_dir = os.path.join(script_dir, "resources") -build_file = Path(os.path.join(resources_dir, "misc")).resolve() -test_config_dir = Path(os.path.join(resources_dir, "test-config")).resolve() file_comparator = FileComparator() library_1 = LibraryConfig( api_shortname="baremetalsolution", @@ -52,12 +48,11 @@ api_description="allows you to encrypt, store, manage, and audit infrastructure and application-level secrets.", gapic_configs=list(), ) -library_3 = LibraryConfig( - api_shortname="secret", - name_pretty="Secret Management Example", - product_documentation="https://cloud.google.com/solutions/", - api_description="allows you to encrypt, store, and audit infrastructure and application-level secrets.", - library_name="secretmanager", +common_protos = LibraryConfig( + api_shortname="common-protos", + name_pretty="Common Protos", + product_documentation="", + api_description="example description", gapic_configs=list(), ) @@ -172,138 +167,6 @@ def test_eprint_valid_input_succeeds(self): # print() appends a `\n` each time it's called self.assertEqual(test_input + "\n", result) - @parameterized.expand( - [ - ("BUILD_no_additional_protos.bazel", " "), - ("BUILD_common_resources.bazel", " google/cloud/common_resources.proto"), - ("BUILD_comment_common_resources.bazel", " "), - ("BUILD_locations.bazel", " google/cloud/location/locations.proto"), - ("BUILD_comment_locations.bazel", " "), - ("BUILD_iam_policy.bazel", " google/iam/v1/iam_policy.proto"), - ("BUILD_comment_iam_policy.bazel", " "), - ( - "BUILD_iam_locations.bazel", - " google/cloud/location/locations.proto google/iam/v1/iam_policy.proto", - ), - ] - ) - def test_gapic_inputs_parse_additional_protos(self, build_name, expected): - parsed = parse_build_file(build_file, "", build_name) - self.assertEqual( - expected, - parsed.additional_protos, - ) - - def test_gapic_inputs_parse_grpc_only_succeeds(self): - parsed = parse_build_file(build_file, "", "BUILD_grpc.bazel") - self.assertEqual("grpc", parsed.transport) - - def test_gapic_inputs_parse_grpc_rest_succeeds(self): - parsed = parse_build_file(build_file, "", "BUILD_grpc_rest.bazel") - self.assertEqual("grpc+rest", parsed.transport) - - def test_gapic_inputs_parse_rest_succeeds(self): - parsed = parse_build_file(build_file, "", "BUILD_rest.bazel") - self.assertEqual("rest", parsed.transport) - - def test_gapic_inputs_parse_empty_include_samples_succeeds(self): - parsed = parse_build_file(build_file, "", "BUILD_include_samples_empty.bazel") - self.assertEqual("false", parsed.include_samples) - - def test_gapic_inputs_parse_include_samples_false_succeeds(self): - parsed = parse_build_file(build_file, "", "BUILD_include_samples_false.bazel") - self.assertEqual("false", parsed.include_samples) - - def test_gapic_inputs_parse_include_samples_true_succeeds(self): - parsed = parse_build_file(build_file, "", "BUILD_include_samples_true.bazel") - self.assertEqual("true", parsed.include_samples) - - def test_gapic_inputs_parse_empty_rest_numeric_enums_succeeds(self): - parsed = parse_build_file( - build_file, "", "BUILD_rest_numeric_enums_empty.bazel" - ) - self.assertEqual("false", parsed.rest_numeric_enum) - - def test_gapic_inputs_parse_rest_numeric_enums_false_succeeds(self): - parsed = parse_build_file( - build_file, "", "BUILD_rest_numeric_enums_false.bazel" - ) - self.assertEqual("false", parsed.rest_numeric_enum) - - def test_gapic_inputs_parse_rest_numeric_enums_true_succeeds(self): - parsed = parse_build_file(build_file, "", "BUILD_rest_numeric_enums_true.bazel") - self.assertEqual("true", parsed.rest_numeric_enum) - - def test_gapic_inputs_parse_no_gapic_library_returns_proto_only_true(self): - # include_samples_empty only has a gradle assembly rule - parsed = parse_build_file(build_file, "", "BUILD_include_samples_empty.bazel") - self.assertEqual("true", parsed.proto_only) - - def test_gapic_inputs_parse_with_gapic_library_returns_proto_only_false(self): - # rest.bazel has a java_gapic_library rule - parsed = parse_build_file(build_file, "", "BUILD_rest.bazel") - self.assertEqual("false", parsed.proto_only) - - def test_gapic_inputs_parse_gapic_yaml_succeeds(self): - parsed = parse_build_file( - build_file, "test/versioned/path", "BUILD_gapic_yaml.bazel" - ) - self.assertEqual("test/versioned/path/test_gapic_yaml.yaml", parsed.gapic_yaml) - - def test_gapic_inputs_parse_no_gapic_yaml_returns_empty_string(self): - parsed = parse_build_file( - build_file, "test/versioned/path", "BUILD_no_gapic_yaml.bazel" - ) - self.assertEqual("", parsed.gapic_yaml) - - def test_gapic_inputs_parse_service_config_succeeds(self): - parsed = parse_build_file( - build_file, "test/versioned/path", "BUILD_service_config.bazel" - ) - self.assertEqual( - "test/versioned/path/test_service_config.json", parsed.service_config - ) - - def test_gapic_inputs_parse_service_yaml_relative_target(self): - parsed = parse_build_file( - build_file, - "google/cloud/compute/v1", - "BUILD_service_config_relative_target.bazel", - ) - self.assertEqual( - "google/cloud/compute/v1/compute_grpc_service_config.json", - parsed.service_config, - ) - - def test_gapic_inputs_parse_no_service_config_returns_empty_string(self): - parsed = parse_build_file( - build_file, "test/versioned/path", "BUILD_no_service_config.bazel" - ) - self.assertEqual("", parsed.service_config) - - def test_gapic_inputs_parse_service_yaml_succeeds(self): - parsed = parse_build_file( - build_file, "test/versioned/path", "BUILD_service_yaml.bazel" - ) - self.assertEqual( - "test/versioned/path/test_service_yaml.yaml", parsed.service_yaml - ) - - def test_gapic_inputs_parse_service_yaml_absolute_target(self): - parsed = parse_build_file( - build_file, "", "BUILD_service_yaml_absolute_target.bazel" - ) - self.assertEqual( - "google/cloud/videointelligence/videointelligence_v1p3beta1.yaml", - parsed.service_yaml, - ) - - def test_gapic_inputs_parse_no_service_yaml_returns_empty_string(self): - parsed = parse_build_file( - build_file, "test/versioned/path", "BUILD_no_service_yaml.bazel" - ) - self.assertEqual("", parsed.service_yaml) - def test_generate_prerequisite_files_non_monorepo_success(self): library_path = self.__setup_prerequisite_files( combination=1, library_type="GAPIC_COMBO" @@ -340,6 +203,24 @@ def test_generate_prerequisite_files_monorepo_success(self): ) self.__remove_prerequisite_files(path=library_path) + def test_generate_prerequisite_files_proto_only_repo_success(self): + library_path = self.__setup_prerequisite_files( + combination=3, library_type="OTHER" + ) + + file_comparator.compare_files( + f"{library_path}/.repo-metadata.json", + f"{library_path}/.repo-metadata-proto-only-golden.json", + ) + file_comparator.compare_files( + f"{library_path}/.OwlBot-hermetic.yaml", + f"{library_path}/.OwlBot-hermetic-golden.yaml", + ) + file_comparator.compare_files( + f"{library_path}/owlbot.py", f"{library_path}/owlbot-golden.py" + ) + self.__remove_prerequisite_files(path=library_path) + def test_prepare_repo_monorepo_success(self): gen_config = self.__get_a_gen_config(2) repo_config = util.prepare_repo( @@ -388,6 +269,7 @@ def __setup_prerequisite_files( f"{library_path}/owlbot.py", ] cleanup(files) + library.library_type = library_type config = self.__get_a_gen_config(combination, library_type=library_type) proto_path = "google/cloud/baremetalsolution/v2" transport = "grpc" @@ -412,12 +294,12 @@ def __get_a_gen_config( the GenerationConfig. Only support 1, 2 or 3. :return: an object of GenerationConfig """ - if combination == 2: + if combination == 1: + libraries = [library_1] + elif combination == 2: libraries = [library_1, library_2] - elif combination == 3: - libraries = [library_with_empty_api_id, library_2] else: - libraries = [library_1] + libraries = [library_1, common_protos] # update libraries with custom configuration (for now, only # library_type) diff --git a/library_generation/utils/utilities.py b/library_generation/utils/utilities.py index 71c58f0455..99673fb1bc 100755 --- a/library_generation/utils/utilities.py +++ b/library_generation/utils/utilities.py @@ -26,6 +26,7 @@ from library_generation.utils.proto_path_utils import remove_version_from script_dir = os.path.dirname(os.path.realpath(__file__)) +SDK_PLATFORM_JAVA = "googleapis/sdk-platform-java" def create_argument(arg_key: str, arg_container: object) -> List[str]: @@ -194,6 +195,7 @@ def generate_prerequisite_files( Generate prerequisite files for a library. Note that the version, if any, in the proto_path will be removed. + :param config: a GenerationConfig object representing a parsed configuration yaml :param library: the library configuration @@ -211,11 +213,12 @@ def generate_prerequisite_files( else f"{library.group_id}:google-{cloud_prefix}{library_name}" ) distribution_name_short = re.split(r"[:/]", distribution_name)[-1] - repo = ( - "googleapis/google-cloud-java" - if config.is_monorepo() - else f"googleapis/{language}-{library_name}" - ) + if config.contains_common_protos(): + repo = SDK_PLATFORM_JAVA + elif config.is_monorepo(): + repo = "googleapis/google-cloud-java" + else: + repo = f"googleapis/{language}-{library_name}" api_id = ( library.api_id if library.api_id else f"{library.api_shortname}.googleapis.com" ) @@ -251,6 +254,11 @@ def generate_prerequisite_files( "requires_billing": library.requires_billing, } + # this removal is for java-common-protos and java-iam in + # sdk-platform-java + if repo == SDK_PLATFORM_JAVA: + repo_metadata.pop("api_id") + if library.api_reference: repo_metadata["api_reference"] = library.api_reference if library.codeowner_team: