本文整理匯總了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)