本文整理汇总了Python中synthtool.gcp.CommonTemplates方法的典型用法代码示例。如果您正苦于以下问题:Python gcp.CommonTemplates方法的具体用法?Python gcp.CommonTemplates怎么用?Python gcp.CommonTemplates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类synthtool.gcp
的用法示例。
在下文中一共展示了gcp.CommonTemplates方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: common_templates
# 需要导入模块: from synthtool import gcp [as 别名]
# 或者: from synthtool.gcp import CommonTemplates [as 别名]
def common_templates(
excludes: List[str] = [], template_path: Optional[Path] = None, **kwargs
) -> None:
"""Generate common templates for a Java Library
Fetches information about the repository from the .repo-metadata.json file,
information about the latest artifact versions and copies the files into
their expected location.
Args:
excludes (List[str], optional): List of template paths to ignore
**kwargs: Additional options for CommonTemplates.java_library()
"""
metadata = {} # type: Dict[str, Any]
repo_metadata = common._load_repo_metadata()
if repo_metadata:
metadata["repo"] = repo_metadata
group_id, artifact_id = repo_metadata["distribution_name"].split(":")
metadata["latest_version"] = latest_maven_version(
group_id=group_id, artifact_id=artifact_id
)
metadata["latest_bom_version"] = latest_maven_version(
group_id="com.google.cloud", artifact_id="libraries-bom",
)
metadata["samples"] = samples.all_samples(["samples/**/src/main/java/**/*.java"])
metadata["snippets"] = snippets.all_snippets(
["samples/**/src/main/java/**/*.java", "samples/**/pom.xml"]
)
if repo_metadata and "min_java_version" in repo_metadata:
metadata["min_java_version"] = repo_metadata["min_java_version"]
else:
metadata["min_java_version"] = DEFAULT_MIN_SUPPORTED_JAVA_VERSION
kwargs["metadata"] = metadata
templates = gcp.CommonTemplates(template_path=template_path).java_library(**kwargs)
s.copy([templates], excludes=excludes, merge=_merge_common_templates)