Skip to content

Commit

Permalink
chore(jvm): migrate to java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisVN committed Nov 11, 2024
1 parent f6f749e commit 3531eb4
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 40 deletions.
13 changes: 7 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ buildscript {

repositories {
mavenLocal()
jcenter()
mavenCentral()
gradlePluginPortal()
}

dependencies {
classpath("com.github.jengelman.gradle.plugins:shadow:5.2.0")
classpath("com.github.johnrengelman:shadow:8.1.1")
}
}

plugins {
java
kotlin("jvm") version "1.5.30" apply false
id("com.github.johnrengelman.shadow") version "5.2.0" apply false
kotlin("jvm") version "2.0.21" apply false
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
id("com.google.cloud.tools.jib") version "2.2.0" apply false
id("com.github.ben-manes.versions") version "0.28.0"
id("com.palantir.git-version") version "0.12.3"
Expand All @@ -44,8 +45,8 @@ allprojects {

repositories {
mavenLocal()
jcenter()
mavenCentral()
gradlePluginPortal()
maven { url = URI("https://packages.confluent.io/maven/") }
}
}
Expand All @@ -55,7 +56,7 @@ subprojects {
apply(plugin = "maven-publish")

java {
sourceCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_21
}

dependencies {
Expand Down
3 changes: 2 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
plugins {
java
kotlin("jvm") version "1.5.30"
kotlin("jvm") version "2.0.21"
}

repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
Expand Down
5 changes: 3 additions & 2 deletions buildSrc/src/main/kotlin/DistributionWithRuntimeExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ open class DistributionWithRuntimeExtension @Inject constructor(objects: ObjectF
}

class RuntimeConfig(
var version: String = "11",
var version: String = "21",
var platform: Platform = Platform.Linux,
var distribution: String = "AdoptOpenJDK"
var arch: String = "x64",
var distribution: String = "Adoptium"
)

class DistributionConfig(
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/DistributionWithRuntimePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ open class DistributionWithRuntimePlugin : Plugin<Project> {
val runtimeConfig = extension.runtimeConfig.get()
runtimes
.runtimes
.find { it.platform == runtimeConfig.platform && it.version == runtimeConfig.version }
.find { it.platform == runtimeConfig.platform && it.version == runtimeConfig.version && it.arch == runtimeConfig.arch }
?.distributions
?.get(runtimeConfig.distribution)
?: throw IllegalArgumentException("distribution not found: $runtimeConfig")
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/DownloadJreTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ private fun inferArchiveType(url: String): DownloadJreTask.ArchiveType = when {
}

data class Runtimes(val runtimes: List<Runtime>)
data class Runtime(val version: String, val platform: Platform, val distributions: Map<String, String>)
data class Runtime(val version: String, val platform: Platform, val arch: String, val distributions: Map<String, String>)
enum class Platform { MacOs, Linux, Windows }
34 changes: 34 additions & 0 deletions buildSrc/src/main/resources/jre.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,50 @@
{
"version": "11",
"platform": "MacOs",
"arch": "x64",
"distributions": {
"AdoptOpenJDK": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10_openj9-0.20.0/OpenJDK11U-jre_x64_mac_openj9_11.0.7_10_openj9-0.20.0.tar.gz"
}
},
{
"version": "11",
"platform": "Linux",
"arch": "x64",
"distributions": {
"AdoptOpenJDK": "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10_openj9-0.20.0/OpenJDK11U-jre_x64_linux_openj9_11.0.7_10_openj9-0.20.0.tar.gz"
}
},
{
"version": "21",
"platform": "MacOs",
"arch": "x64",
"distributions": {
"Adoptium": "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.5%2B11/OpenJDK21U-jre_x64_mac_hotspot_21.0.5_11.tar.gz"
}
},
{
"version": "21",
"platform": "Linux",
"arch": "x64",
"distributions": {
"Adoptium": "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.5%2B11/OpenJDK21U-jre_x64_linux_hotspot_21.0.5_11.tar.gz"
}
},
{
"version": "21",
"platform": "MacOs",
"arch": "aarch64",
"distributions": {
"Adoptium": "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.5%2B11/OpenJDK21U-jre_aarch64_mac_hotspot_21.0.5_11.tar.gz"
}
},
{
"version": "21",
"platform": "Linux",
"arch": "aarch64",
"distributions": {
"Adoptium": "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.5%2B11/OpenJDK21U-jre_aarch64_linux_hotspot_21.0.5_11.tar.gz"
}
}
]
}
22 changes: 9 additions & 13 deletions zoe-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ plugins {
apply<DistributionWithRuntimePlugin>()

application {
mainClassName = "com.adevinta.oss.zoe.cli.MainKt"
mainClass.set("com.adevinta.oss.zoe.cli.MainKt")
applicationDefaultJvmArgs = listOf("-client")
applicationName = "zoe"
}

configure<DistributionWithRuntimeExtension> {

distribution {
base = "shadow"
}
Expand All @@ -43,8 +42,9 @@ configure<DistributionWithRuntimeExtension> {
}

runtime {
version = "11"
distribution = "AdoptOpenJDK"
version = "21"
distribution = "Adoptium"
arch = "x64"
platform = findProperty("runtime.os")?.let(Any::toString)?.let(Platform::valueOf) ?: Platform.Linux
}
}
Expand Down Expand Up @@ -96,7 +96,7 @@ mapOf("zip" to Zip::class, "tar" to Tar::class).forEach { (archiveType, archiveC
jib {

from {
image = "openjdk:11-jre-slim"
image = "eclipse-temurin:21-jre"
}

to {
Expand Down Expand Up @@ -140,15 +140,15 @@ tasks {
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.jvmTarget = "21"
kotlinOptions.freeCompilerArgs = listOf(
"-Xopt-in=kotlinx.coroutines.FlowPreview",
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
)
}

compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.jvmTarget = "21"
}

test {
Expand All @@ -165,16 +165,12 @@ tasks {
sourceSets {
main {
resources.srcDir("resources")
withConvention(KotlinSourceSet::class) {
kotlin.srcDir("src")
}
kotlin.srcDir("src")
}

test {
resources.srcDir("testResources")
withConvention(KotlinSourceSet::class) {
kotlin.srcDir("test")
}
kotlin.srcDir("test")
}
}

Expand Down
12 changes: 4 additions & 8 deletions zoe-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,22 @@ tasks.test {

tasks {
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.jvmTarget = "21"
}

compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.jvmTarget = "21"
}
}

sourceSets {
main {
resources.srcDir("resources")
withConvention(KotlinSourceSet::class) {
kotlin.srcDir("src")
}
kotlin.srcDir("src")
}

test {
resources.srcDir("testResources")
withConvention(KotlinSourceSet::class) {
kotlin.srcDir("test")
}
kotlin.srcDir("test")
}
}
12 changes: 4 additions & 8 deletions zoe-service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "21"
freeCompilerArgs = listOf(
"-Xopt-in=kotlinx.coroutines.FlowPreview",
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
Expand All @@ -42,22 +42,18 @@ tasks {
}

compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.jvmTarget = "21"
}
}

sourceSets {
main {
resources.srcDir("resources")
withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) {
kotlin.srcDir("src")
}
kotlin.srcDir("src")
}

test {
resources.srcDir("testResources")
withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) {
kotlin.srcDir("test")
}
kotlin.srcDir("test")
}
}

0 comments on commit 3531eb4

Please sign in to comment.