Skip to content

add a way to set the java compiler version in the gradle build#9

Open
daymonro wants to merge 1 commit intoSiliconLabsSoftware:mainfrom
daymonro:main
Open

add a way to set the java compiler version in the gradle build#9
daymonro wants to merge 1 commit intoSiliconLabsSoftware:mainfrom
daymonro:main

Conversation

@daymonro
Copy link

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

.systemProperty("javaVersion")
.orElse(providers.environmentVariable("JAVA_VERSION"))
.orElse("11") // fallback if nothing set
languageVersion = JavaLanguageVersion.of(requestedVersion.get().toInteger())
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments