add a way to set the java compiler version in the gradle build#9
Open
daymonro wants to merge 1 commit intoSiliconLabsSoftware:mainfrom
Open
add a way to set the java compiler version in the gradle build#9daymonro wants to merge 1 commit intoSiliconLabsSoftware:mainfrom
daymonro wants to merge 1 commit intoSiliconLabsSoftware:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds flexibility to the Java compiler version configuration in the Gradle build system by allowing it to be set via system properties or environment variables, rather than being hardcoded to Java 11.
Key Changes:
- Introduces a configurable Java version mechanism with multiple configuration sources (system property, environment variable, or default fallback)
- Replaces the hardcoded Java 11 version with a dynamic version resolution system
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
pcap/build.gradle
Outdated
| .systemProperty("javaVersion") | ||
| .orElse(providers.environmentVariable("JAVA_VERSION")) | ||
| .orElse("11") // fallback if nothing set | ||
| languageVersion = JavaLanguageVersion.of(requestedVersion.get().toInteger()) |
There was a problem hiding this comment.
The conversion chain .get().toInteger() could fail with unclear errors if a non-numeric value is provided. Consider using .map { Integer.parseInt(it) } before the final assignment to provide better error handling, or add validation to ensure the value is numeric before conversion.
Suggested change
| languageVersion = JavaLanguageVersion.of(requestedVersion.get().toInteger()) | |
| languageVersion = JavaLanguageVersion.of(requestedVersion.map { | |
| try { | |
| Integer.parseInt(it) | |
| } catch (NumberFormatException e) { | |
| throw new GradleException("Invalid javaVersion/JAVA_VERSION: '$it' is not a valid integer") | |
| } | |
| }.get()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.