Skip to content

Commit

Permalink
Merge pull request #1083 from Kotlin/java11
Browse files Browse the repository at this point in the history
Setting java version to 11
  • Loading branch information
Jolanrensen authored Mar 4, 2025
2 parents 34d90d6 + caa6a20 commit d8c6c4b
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 28 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ kotlin.jvmToolchain(11)
allprojects {
tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
jvmTarget = JvmTarget.JVM_11
}
}

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
sourceCompatibility = JavaVersion.VERSION_11.toString()
targetCompatibility = JavaVersion.VERSION_11.toString()
}

// Attempts to configure ktlint for each sub-project that uses the plugin
Expand Down
6 changes: 0 additions & 6 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ dependencies {
api(libs.kotlin.reflect)
implementation(libs.kotlin.stdlib)
kotlinCompilerPluginClasspathSamples(project(":plugins:expressions-converter"))
implementation(libs.kotlin.stdlib.jdk8)

api(libs.commonsCsv)
implementation(libs.commonsIo)
Expand Down Expand Up @@ -364,11 +363,6 @@ kotlin {
explicitApi()
}

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
}

tasks.withType<KotlinCompile> {
compilerOptions {
optIn.addAll("kotlin.RequiresOptIn")
Expand Down
2 changes: 1 addition & 1 deletion examples/idea-examples/json/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies {
}

tasks.withType<KotlinCompile> {
compilerOptions.jvmTarget = JvmTarget.JVM_1_8
compilerOptions.jvmTarget = JvmTarget.JVM_11
}

dataframes {
Expand Down
2 changes: 1 addition & 1 deletion examples/idea-examples/movies/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ dependencies {
}

tasks.withType<KotlinCompile> {
compilerOptions.jvmTarget = JvmTarget.JVM_1_8
compilerOptions.jvmTarget = JvmTarget.JVM_11
}
2 changes: 1 addition & 1 deletion examples/idea-examples/youtube/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ dependencies {
}

tasks.withType<KotlinCompile> {
compilerOptions.jvmTarget = JvmTarget.JVM_1_8
compilerOptions.jvmTarget = JvmTarget.JVM_11
}

1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ ksp-api = { group = "com.google.devtools.ksp", name = "symbol-processing-api", v
jupyter-api = { group = "org.jetbrains.kotlinx", name = "kotlin-jupyter-kernel", version.ref = "kotlinJupyter" }

kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib", version.ref = "kotlin" }
kotlin-stdlib-jdk8 = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlin" }

kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" }
kotlin-scriptingJvm = { group = "org.jetbrains.kotlin", name = "kotlin-scripting-jvm", version.ref = "kotlin" }
Expand Down
6 changes: 3 additions & 3 deletions plugins/dataframe-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ gradlePlugin {
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
compilerOptions.jvmTarget = JvmTarget.JVM_1_8
compilerOptions.jvmTarget = JvmTarget.JVM_11
}

tasks.withType<JavaCompile>().all {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
sourceCompatibility = JavaVersion.VERSION_11.toString()
targetCompatibility = JavaVersion.VERSION_11.toString()
}

sourceSets {
Expand Down
6 changes: 5 additions & 1 deletion plugins/expressions-converter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ dependencies {

tasks.test {
useJUnitPlatform()
// gets the path to JDK 11 either from gradle.properties or from the system property, defaulting to java.home
environment(
"JDK_11_0",
project.properties["JDK_11_0"] ?: System.getProperty("JDK_11_0", System.getProperty("java.home")),
)
doFirst {
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-stdlib", "kotlin-stdlib")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-stdlib-jdk8", "kotlin-stdlib-jdk8")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-reflect", "kotlin-reflect")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-test", "kotlin-test")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-script-runtime", "kotlin-script-runtime")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jetbrains.kotlinx.dataframe

import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.test.TestJdkKind
Expand All @@ -22,22 +23,25 @@ import org.jetbrains.kotlin.test.model.DependencyKind
import org.jetbrains.kotlin.test.model.FrontendKinds
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.RuntimeClasspathProvider
import org.jetbrains.kotlin.test.services.TemporaryDirectoryManager
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
import org.jetbrains.kotlinx.dataframe.services.TemporaryDirectoryManagerImplFixed
import java.io.File

open class AbstractExplainerBlackBoxCodegenTest : BaseTestRunner() {

override fun TestConfigurationBuilder.configuration() {
globalDefaults {
frontend = FrontendKinds.ClassicFrontend
targetPlatform = JvmPlatforms.defaultJvmPlatform
frontend = FrontendKinds.ClassicAndFIR
targetPlatform = JvmPlatforms.jvm11
dependencyKind = DependencyKind.Binary
targetBackend = TargetBackend.JVM_IR
}
defaultDirectives {
JvmEnvironmentConfigurationDirectives.JDK_KIND with TestJdkKind.FULL_JDK
JvmEnvironmentConfigurationDirectives.JDK_KIND with TestJdkKind.FULL_JDK_11
JvmEnvironmentConfigurationDirectives.JVM_TARGET with JvmTarget.JVM_11
+JvmEnvironmentConfigurationDirectives.WITH_REFLECT
}
facadeStep(::ClassicFrontendFacade)
Expand All @@ -63,6 +67,7 @@ open class AbstractExplainerBlackBoxCodegenTest : BaseTestRunner() {
useConfigurators(::JvmEnvironmentConfigurator, ::CommonEnvironmentConfigurator, ::PluginAnnotationsProvider)
useCustomRuntimeClasspathProviders(::MyClasspathProvider)
useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor)
useAdditionalService<TemporaryDirectoryManager>(::TemporaryDirectoryManagerImplFixed)
}

class MyClasspathProvider(testServices: TestServices) : RuntimeClasspathProvider(testServices) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package org.jetbrains.kotlinx.dataframe.services

import org.jetbrains.kotlin.test.services.TemporaryDirectoryManager
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.testInfo
import org.jetbrains.kotlin.test.util.KtTestUtil
import java.io.File
import java.nio.file.Paths
import java.util.Locale
import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.deleteRecursively

// Copied from org.jetbrains.kotlin.test.services.impl.TemporaryDirectoryManagerImpl
// because it uses NioFiles#deleteRecursively and throws method not found as a result.
class TemporaryDirectoryManagerImplFixed(testServices: TestServices) : TemporaryDirectoryManager(testServices) {
private val cache = mutableMapOf<String, File>()
private val rootTempDir = lazy {
val testInfo = testServices.testInfo
val className = testInfo.className
val methodName = testInfo.methodName
if (!onWindows && className.length + methodName.length < 255) {
return@lazy KtTestUtil.tmpDirForTest(className, methodName)
}

// This code will simplify directory name for windows. This is needed because there can occur errors due to long name
val lastDot = className.lastIndexOf('.')
val simplifiedClassName = className.substring(lastDot + 1).getOnlyUpperCaseSymbols()
val simplifiedMethodName = methodName.getOnlyUpperCaseSymbols()
KtTestUtil.tmpDirForTest(simplifiedClassName, simplifiedMethodName)
}

override val rootDir: File
get() = rootTempDir.value

override fun getOrCreateTempDirectory(name: String): File =
cache.getOrPut(name) {
KtTestUtil.tmpDir(rootDir, name)
}

@OptIn(ExperimentalPathApi::class)
override fun cleanupTemporaryDirectories() {
cache.clear()

if (rootTempDir.isInitialized()) {
Paths.get(rootDir.path).deleteRecursively()
}
}

companion object {
private val onWindows: Boolean =
System.getProperty("os.name").lowercase(Locale.getDefault()).contains("windows")

private fun String.getOnlyUpperCaseSymbols(): String =
this.filter { it.isUpperCase() || it == '$' }
.toList()
.joinToString(separator = "")
}
}
15 changes: 10 additions & 5 deletions plugins/kotlin-dataframe/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,14 @@ tasks.test {
useJUnitPlatform()
jvmArgs("-Xmx2G")
environment("TEST_RESOURCES", project.layout.projectDirectory)

// gets the path to JDK 11 either from gradle.properties or from the system property, defaulting to java.home
environment(
"JDK_11_0",
project.properties["JDK_11_0"] ?: System.getProperty("JDK_11_0", System.getProperty("java.home")),
)
doFirst {
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-stdlib", "kotlin-stdlib")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-stdlib-jdk8", "kotlin-stdlib-jdk8")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-reflect", "kotlin-reflect")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-test", "kotlin-test")
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-script-runtime", "kotlin-script-runtime")
Expand All @@ -83,21 +88,21 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach
}

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
sourceCompatibility = JavaVersion.VERSION_11.toString()
targetCompatibility = JavaVersion.VERSION_11.toString()
}

tasks.compileKotlin {
compilerOptions {
languageVersion = KotlinVersion.KOTLIN_2_0
jvmTarget = JvmTarget.JVM_1_8
jvmTarget = JvmTarget.JVM_11
}
}

tasks.compileTestKotlin {
compilerOptions {
languageVersion = KotlinVersion.KOTLIN_2_0
jvmTarget = JvmTarget.JVM_1_8
jvmTarget = JvmTarget.JVM_11
}
}

Expand Down
4 changes: 4 additions & 0 deletions plugins/kotlin-dataframe/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
kotlin.code.style=official
kotlinVersion=2.0.20

# Optionally, you can set this property to point to your JDK 11 installation.
# This version is used to run the box/diagnostics tests.
# JDK_11_0=/path/to/jdk_11
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.jetbrains.kotlin.fir.dataframe

import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.fir.dataframe.services.DataFramePluginAnnotationsProvider
import org.jetbrains.kotlin.fir.dataframe.services.ExperimentalExtensionRegistrarConfigurator
import org.jetbrains.kotlin.fir.dataframe.services.TemporaryDirectoryManagerImplFixed
Expand Down Expand Up @@ -40,7 +41,8 @@ open class AbstractDataFrameBlackBoxCodegenTest : AbstractFirLightTreeBlackBoxCo
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
builder.defaultDirectives {
JvmEnvironmentConfigurationDirectives.JDK_KIND with TestJdkKind.FULL_JDK
JvmEnvironmentConfigurationDirectives.JDK_KIND with TestJdkKind.FULL_JDK_11
JvmEnvironmentConfigurationDirectives.JVM_TARGET with JvmTarget.JVM_11
+JvmEnvironmentConfigurationDirectives.WITH_REFLECT
+IGNORE_DEXING
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package org.jetbrains.kotlin.fir.dataframe

import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.fir.dataframe.services.Directives
import org.jetbrains.kotlin.fir.dataframe.services.DataFramePluginAnnotationsProvider
import org.jetbrains.kotlin.fir.dataframe.services.ExperimentalExtensionRegistrarConfigurator
Expand Down Expand Up @@ -52,7 +53,8 @@ abstract class AbstractDataFrameDiagnosticTest : AbstractKotlinCompilerTest() {
+FirDiagnosticsDirectives.ENABLE_PLUGIN_PHASES
+FirDiagnosticsDirectives.FIR_DUMP
FirDiagnosticsDirectives.FIR_PARSER with FirParser.LightTree
JvmEnvironmentConfigurationDirectives.JDK_KIND with TestJdkKind.FULL_JDK
JvmEnvironmentConfigurationDirectives.JDK_KIND with TestJdkKind.FULL_JDK_11
JvmEnvironmentConfigurationDirectives.JVM_TARGET with JvmTarget.JVM_11
}

useDirectives(Directives)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal object KotlinCompilationUtil {
// workaround for https://github.com/tschuchortdev/kotlin-compile-testing/issues/105
compilation.kotlincArguments += "-Xjava-source-roots=${javaSrcRoot.absolutePath}"
compilation.jvmDefault = "all"
compilation.jvmTarget = JvmTarget.JVM_1_8.description
compilation.jvmTarget = JvmTarget.JVM_11.description
compilation.inheritClassPath = false
compilation.verbose = false
compilation.classpaths = Classpaths.inheritedClasspath + classpaths
Expand Down

0 comments on commit d8c6c4b

Please sign in to comment.