Skip to content

Commit

Permalink
Bump Kotlin, Gradle, fix deprecations (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-bader authored Sep 10, 2023
1 parent fc094d2 commit 8371641
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pre-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
jvm-version: [8, 17]
jvm-version: [17]
os: [ubuntu-latest, windows-latest]
env:
JDK_VERSION: ${{ matrix.jvm-version }}
Expand Down
1 change: 1 addition & 0 deletions build-src/src/main/kotlin/com/microsoft/thrifty/Plugins.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package com.microsoft.thrifty

object Plugins {
const val JAVA = "java-library"
const val TEST_SUITE = "jvm-test-suite"
const val IDEA = "idea"
const val JACOCO = "jacoco"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ package com.microsoft.thrifty
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.plugins.jvm.JvmTestSuite
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.gradle.testing.base.TestingExtension

class ThriftyJavaPlugin : Plugin<Project> {
override fun apply(project: Project) {
Expand All @@ -40,6 +42,7 @@ class ThriftyJavaPlugin : Plugin<Project> {
private fun applyBasePlugins(project: Project) {
with(project.plugins) {
apply(Plugins.JAVA)
apply(Plugins.TEST_SUITE)
apply(Plugins.IDEA)
apply(Plugins.JACOCO)
}
Expand All @@ -63,15 +66,31 @@ class ThriftyJavaPlugin : Plugin<Project> {
}
}

@Suppress("UnstableApiUsage")
private fun configureTestTasks(project: Project) {
project.tasks.withType<Test>().configureEach { task ->
task.useJUnitPlatform()
task.testLogging { logging ->
logging.events(TestLogEvent.FAILED)
logging.exceptionFormat = TestExceptionFormat.FULL
logging.showStackTraces = true
logging.showExceptions = true
logging.showCauses = true
val catalogs = project.extensions.findByType<VersionCatalogsExtension>()!!
val catalog = catalogs.named("libs")
val maybeJunitVersion = catalog.findVersion("junit")
check(maybeJunitVersion.isPresent) { "No junit version found" }

val junitVersion = maybeJunitVersion.get()

project.extensions.configure(TestingExtension::class.java) { ext ->
ext.suites.named("test") {
val suite = it as JvmTestSuite

suite.useJUnitJupiter("$junitVersion")
suite.targets.configureEach { target ->
target.testTask.configure { task ->
task.testLogging { logging ->
logging.events(TestLogEvent.FAILED)
logging.exceptionFormat = TestExceptionFormat.FULL
logging.showStackTraces = true
logging.showExceptions = true
logging.showCauses = true
}
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ tasks.register("codeCoverageReport", JacocoReport) { t ->
}

wrapper {
gradleVersion = "8.0"
gradleVersion = "8.3"
distributionType = Wrapper.DistributionType.BIN
}
11 changes: 5 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
junit = "5.8.2"
junit = "5.10.0"
kotest = "5.5.4"
kotlin = "1.8.10"
kotlin = "1.9.10"
okio = "3.3.0"

[libraries]
Expand All @@ -17,7 +17,7 @@ kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.re
kotlin-stdlibCommon = { module = "org.jetbrains.kotlin:kotlin-stdlib-common", version.ref = "kotlin" }
kotlinx-coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
kotlinPoet = "com.squareup:kotlinpoet:1.12.0"
mavenPublishPlugin = "com.vanniktech:gradle-maven-publish-plugin:0.22.0"
mavenPublishPlugin = "com.vanniktech:gradle-maven-publish-plugin:0.25.3"
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }

junit = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
Expand All @@ -38,8 +38,7 @@ testing = ["junit", "hamcrest", "kotest-assertions-core", "kotest-assertions-cor

[plugins]
dokka = "org.jetbrains.dokka:1.7.20"
gradlePluginPublish = "com.gradle.plugin-publish:0.21.0"
gradlePluginPublish = "com.gradle.plugin-publish:1.2.1"
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-mpp = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
mavenPublish = "com.vanniktech.maven.publish:0.22.0"
shadow = "com.github.johnrengelman.shadow:7.1.2"
shadow = "com.github.johnrengelman.shadow:8.1.1"
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 2 additions & 4 deletions thrifty-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,17 @@ plugins {
alias libs.plugins.gradlePluginPublish
}

pluginBundle {
gradlePlugin {
website = 'https://github.com/microsoft/thrifty'
vcsUrl = 'https://github.com/microsoft/thrifty.git'
tags = ['thrift', 'code-generation', 'thrifty']
}

gradlePlugin {
plugins {
thriftyPlugin {
id = 'com.microsoft.thrifty'
displayName = 'Thrifty Gradle Plugin'
description = 'Generates Java and/or Kotlin sources from .thrift files'
implementationClass = 'com.microsoft.thrifty.gradle.ThriftyGradlePlugin'
tags.set(['thrift', 'code-generation', 'thrifty'])
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
* The name styles supported by Thrifty.
*
* <table>
* <caption>Name styles supported by Thrifty.</caption>
* <thead>
* <tr>
* <th>Name</th>
* <th>Description</th>
* </tr>
* </thead>
* <tbody>
* <tr>
Expand Down
4 changes: 3 additions & 1 deletion thrifty-integration-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ shadowJar {
}
}

mainClassName = 'com.microsoft.thrifty.compiler.ThriftyCompiler'
application {
mainClass = 'com.microsoft.thrifty.compiler.ThriftyCompiler'
}

def compileTestThrift = tasks.register("compileTestThrift", JavaExec) { t ->
t.inputs.file("$projectDir/ClientThriftTest.thrift")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package com.microsoft.thrifty.internal
actual class AtomicBoolean actual constructor(
initialValue: Boolean
) {
private val actualAtomicBool = kotlin.native.concurrent.AtomicInt(if (initialValue) 1 else 0)
private val actualAtomicBool = kotlin.concurrent.AtomicInt(if (initialValue) 1 else 0)

actual fun get(): Boolean {
return actualAtomicBool.value == 1
Expand All @@ -39,9 +39,9 @@ actual class AtomicBoolean actual constructor(
actual class AtomicInteger actual constructor(
initialValue: Int
) {
private val actualAtomicInt = kotlin.native.concurrent.AtomicInt(initialValue)
private val actualAtomicInt = kotlin.concurrent.AtomicInt(initialValue)

actual fun get(): Int = actualAtomicInt.value

actual fun incrementAndGet(): Int = actualAtomicInt.addAndGet(1)
actual fun incrementAndGet(): Int = actualAtomicInt.incrementAndGet()
}
2 changes: 1 addition & 1 deletion thrifty-schema/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ tasks.named('compileTestKotlin').configure {

// antlr doesn't hook up nicely with javaSourcesJar, so Gradle complains about
// it unless we manually specify the dependency between the two
tasks.matching { it.name == 'javaSourcesJar' }.configureEach {
tasks.matching { it.name == 'javaSourcesJar' || it.name == 'kotlinSourcesJar' }.configureEach {
dependsOn 'generateGrammarSource'
}

0 comments on commit 8371641

Please sign in to comment.