Skip to content

Commit

Permalink
updates for java version
Browse files Browse the repository at this point in the history
  • Loading branch information
pkwarren committed Jan 17, 2024
1 parent acb2312 commit 1095507
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
20 changes: 18 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ dependencies {
testImplementation(libs.truth)
}

val targetJavaVersion = JavaVersion.VERSION_1_8
val targetKotlinVersion = "1.6"

configure<JavaPluginExtension> {
sourceCompatibility = targetJavaVersion
targetCompatibility = targetJavaVersion
Expand All @@ -60,8 +63,6 @@ gradlePlugin {
ext[GRADLE_PUBLISH_KEY] = System.getenv("GRADLE_PORTAL_PUBLISH_KEY")
ext[GRADLE_PUBLISH_SECRET] = System.getenv("GRADLE_PORTAL_PUBLISH_SECRET")

val targetJavaVersion = JavaVersion.VERSION_1_8

tasks {
named("publishPlugins") {
enabled = isRelease()
Expand All @@ -75,6 +76,21 @@ tasks {
kotlinOptions {
allWarningsAsErrors = true
jvmTarget = targetJavaVersion.toString()
languageVersion = targetKotlinVersion
apiVersion = targetKotlinVersion
if (JavaVersion.current().isJava9Compatible) {
freeCompilerArgs += "-Xjdk-release=1.8"
}
}
}

withType<JavaCompile> {
if (JavaVersion.current().isJava9Compatible) {
doFirst {
options.compilerArgs = listOf("--release", "8")
}
}
sourceCompatibility = targetJavaVersion.toString()
targetCompatibility = targetJavaVersion.toString()
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
# plugins
animalsniffer = "1.7.1"
kotlin = "1.6.20"
kotlin = "1.9.20"
pluginPublish = "1.2.1"
publishing = "0.25.3"
spotless = "6.24.0"
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/build/buf/gradle/BufSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets
const val BUF_BINARY_CONFIGURATION_NAME = "bufTool"

internal fun Project.configureBufDependency() {
val os = System.getProperty("os.name").toLowerCase()
val os = System.getProperty("os.name").lowercase()
val osPart =
when {
os.startsWith("windows") -> "windows"
Expand All @@ -31,7 +31,7 @@ internal fun Project.configureBufDependency() {
}

val archPart =
when (val arch = System.getProperty("os.arch").toLowerCase()) {
when (val arch = System.getProperty("os.arch").lowercase()) {
in setOf("x86_64", "amd64") -> "x86_64"
in setOf("arm64", "aarch64") -> "aarch_64"
else -> error("unsupported arch: $arch")
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/build/buf/gradle/OutputSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import java.io.File

const val BUF_BUILD_DIR = "bufbuild"

@Suppress("DEPRECATION") // https://docs.gradle.org/current/userguide/upgrading_version_8.html#deprecations_3
internal val Project.bufbuildDir
get() = File(buildDir, BUF_BUILD_DIR)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class AbstractBufIntegrationTest : IntegrationTest {
.replace("--", "")
.replace(" ", "_")
.replace("-", "_")
.toLowerCase(Locale.US)
.lowercase(Locale.US)
val fixture = File("src/test/resources/${testInfo.testClass.get().simpleName}/$testName")
assertWithMessage("Directory ${fixture.path} does not exist").that(fixture.exists()).isTrue()
assertWithMessage("Failed to copy test fixture files").that(fixture.copyRecursively(projectDir)).isTrue()
Expand Down

0 comments on commit 1095507

Please sign in to comment.