Skip to content

Commit 65f8c64

Browse files
authored
chore(java): allow overriding minimum supported Java version in templates (#577)
1 parent 7ee9282 commit 65f8c64

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

synthtool/gcp/templates/java_library/.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
java: [7, 8, 11]
12+
java: [{% if metadata['min_java_version'] <= 7 %}7, {% endif %}8, 11]
1313
steps:
1414
- uses: actions/checkout@v2
1515
- uses: actions/setup-java@v1

synthtool/gcp/templates/java_library/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ To get help, follow the instructions in the [shared Troubleshooting document][tr
114114

115115
## Java Versions
116116

117-
Java 7 or above is required for using this client.
117+
Java {{ metadata['min_java_version'] }} or above is required for using this client.
118118

119119
## Versioning
120120

@@ -148,7 +148,7 @@ Apache 2.0 - See [LICENSE][license] for more information.
148148

149149
Java Version | Status
150150
------------ | ------
151-
Java 7 | [![Kokoro CI][kokoro-badge-image-1]][kokoro-badge-link-1]
151+
{% if metadata['min_java_version'] <= 7 %}Java 7 | [![Kokoro CI][kokoro-badge-image-1]][kokoro-badge-link-1]{% endif -%}
152152
Java 8 | [![Kokoro CI][kokoro-badge-image-2]][kokoro-badge-link-2]
153153
Java 8 OSX | [![Kokoro CI][kokoro-badge-image-3]][kokoro-badge-link-3]
154154
Java 8 Windows | [![Kokoro CI][kokoro-badge-image-4]][kokoro-badge-link-4]

synthtool/languages/java.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
\\* the License.
5959
\\*/
6060
"""
61+
DEFAULT_MIN_SUPPORTED_JAVA_VERSION = 7
6162

6263

6364
def format_code(
@@ -361,6 +362,10 @@ def common_templates(excludes: List[str] = [], **kwargs) -> None:
361362
metadata["snippets"] = snippets.all_snippets(
362363
["samples/**/src/main/java/**/*.java", "samples/**/pom.xml"]
363364
)
365+
if repo_metadata and "min_java_version" in repo_metadata:
366+
metadata["min_java_version"] = repo_metadata["min_java_version"]
367+
else:
368+
metadata["min_java_version"] = DEFAULT_MIN_SUPPORTED_JAVA_VERSION
364369

365370
kwargs["metadata"] = metadata
366371
templates = gcp.CommonTemplates().java_library(**kwargs)

0 commit comments

Comments
 (0)