Skip to content

Commit d8c6c4b

Browse files
authored
Merge pull request #1083 from Kotlin/java11
Setting java version to 11
2 parents 34d90d6 + caa6a20 commit d8c6c4b

File tree

15 files changed

+101
-28
lines changed

15 files changed

+101
-28
lines changed

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ kotlin.jvmToolchain(11)
144144
allprojects {
145145
tasks.withType<KotlinCompile> {
146146
compilerOptions {
147-
jvmTarget = JvmTarget.JVM_1_8
147+
jvmTarget = JvmTarget.JVM_11
148148
}
149149
}
150150

151151
tasks.withType<JavaCompile> {
152-
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
153-
targetCompatibility = JavaVersion.VERSION_1_8.toString()
152+
sourceCompatibility = JavaVersion.VERSION_11.toString()
153+
targetCompatibility = JavaVersion.VERSION_11.toString()
154154
}
155155

156156
// Attempts to configure ktlint for each sub-project that uses the plugin

core/build.gradle.kts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ dependencies {
6565
api(libs.kotlin.reflect)
6666
implementation(libs.kotlin.stdlib)
6767
kotlinCompilerPluginClasspathSamples(project(":plugins:expressions-converter"))
68-
implementation(libs.kotlin.stdlib.jdk8)
6968

7069
api(libs.commonsCsv)
7170
implementation(libs.commonsIo)
@@ -364,11 +363,6 @@ kotlin {
364363
explicitApi()
365364
}
366365

367-
tasks.withType<JavaCompile> {
368-
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
369-
targetCompatibility = JavaVersion.VERSION_1_8.toString()
370-
}
371-
372366
tasks.withType<KotlinCompile> {
373367
compilerOptions {
374368
optIn.addAll("kotlin.RequiresOptIn")

examples/idea-examples/json/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dependencies {
2323
}
2424

2525
tasks.withType<KotlinCompile> {
26-
compilerOptions.jvmTarget = JvmTarget.JVM_1_8
26+
compilerOptions.jvmTarget = JvmTarget.JVM_11
2727
}
2828

2929
dataframes {

examples/idea-examples/movies/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ dependencies {
2424
}
2525

2626
tasks.withType<KotlinCompile> {
27-
compilerOptions.jvmTarget = JvmTarget.JVM_1_8
27+
compilerOptions.jvmTarget = JvmTarget.JVM_11
2828
}

examples/idea-examples/youtube/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ dependencies {
2525
}
2626

2727
tasks.withType<KotlinCompile> {
28-
compilerOptions.jvmTarget = JvmTarget.JVM_1_8
28+
compilerOptions.jvmTarget = JvmTarget.JVM_11
2929
}
3030

gradle/libs.versions.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ ksp-api = { group = "com.google.devtools.ksp", name = "symbol-processing-api", v
6868
jupyter-api = { group = "org.jetbrains.kotlinx", name = "kotlin-jupyter-kernel", version.ref = "kotlinJupyter" }
6969

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

7372
kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlin" }
7473
kotlin-scriptingJvm = { group = "org.jetbrains.kotlin", name = "kotlin-scripting-jvm", version.ref = "kotlin" }

plugins/dataframe-gradle-plugin/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ gradlePlugin {
9191
}
9292

9393
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
94-
compilerOptions.jvmTarget = JvmTarget.JVM_1_8
94+
compilerOptions.jvmTarget = JvmTarget.JVM_11
9595
}
9696

9797
tasks.withType<JavaCompile>().all {
98-
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
99-
targetCompatibility = JavaVersion.VERSION_1_8.toString()
98+
sourceCompatibility = JavaVersion.VERSION_11.toString()
99+
targetCompatibility = JavaVersion.VERSION_11.toString()
100100
}
101101

102102
sourceSets {

plugins/expressions-converter/build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ dependencies {
3838

3939
tasks.test {
4040
useJUnitPlatform()
41+
// gets the path to JDK 11 either from gradle.properties or from the system property, defaulting to java.home
42+
environment(
43+
"JDK_11_0",
44+
project.properties["JDK_11_0"] ?: System.getProperty("JDK_11_0", System.getProperty("java.home")),
45+
)
4146
doFirst {
4247
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-stdlib", "kotlin-stdlib")
43-
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-stdlib-jdk8", "kotlin-stdlib-jdk8")
4448
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-reflect", "kotlin-reflect")
4549
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-test", "kotlin-test")
4650
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-script-runtime", "kotlin-script-runtime")

plugins/expressions-converter/tests/org/jetbrains/kotlinx/dataframe/AbstractExplainerBlackBoxCodegenTest.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jetbrains.kotlinx.dataframe
22

3+
import org.jetbrains.kotlin.config.JvmTarget
34
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
45
import org.jetbrains.kotlin.test.TargetBackend
56
import org.jetbrains.kotlin.test.TestJdkKind
@@ -22,22 +23,25 @@ import org.jetbrains.kotlin.test.model.DependencyKind
2223
import org.jetbrains.kotlin.test.model.FrontendKinds
2324
import org.jetbrains.kotlin.test.model.TestModule
2425
import org.jetbrains.kotlin.test.services.RuntimeClasspathProvider
26+
import org.jetbrains.kotlin.test.services.TemporaryDirectoryManager
2527
import org.jetbrains.kotlin.test.services.TestServices
2628
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
2729
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
30+
import org.jetbrains.kotlinx.dataframe.services.TemporaryDirectoryManagerImplFixed
2831
import java.io.File
2932

3033
open class AbstractExplainerBlackBoxCodegenTest : BaseTestRunner() {
3134

3235
override fun TestConfigurationBuilder.configuration() {
3336
globalDefaults {
34-
frontend = FrontendKinds.ClassicFrontend
35-
targetPlatform = JvmPlatforms.defaultJvmPlatform
37+
frontend = FrontendKinds.ClassicAndFIR
38+
targetPlatform = JvmPlatforms.jvm11
3639
dependencyKind = DependencyKind.Binary
3740
targetBackend = TargetBackend.JVM_IR
3841
}
3942
defaultDirectives {
40-
JvmEnvironmentConfigurationDirectives.JDK_KIND with TestJdkKind.FULL_JDK
43+
JvmEnvironmentConfigurationDirectives.JDK_KIND with TestJdkKind.FULL_JDK_11
44+
JvmEnvironmentConfigurationDirectives.JVM_TARGET with JvmTarget.JVM_11
4145
+JvmEnvironmentConfigurationDirectives.WITH_REFLECT
4246
}
4347
facadeStep(::ClassicFrontendFacade)
@@ -63,6 +67,7 @@ open class AbstractExplainerBlackBoxCodegenTest : BaseTestRunner() {
6367
useConfigurators(::JvmEnvironmentConfigurator, ::CommonEnvironmentConfigurator, ::PluginAnnotationsProvider)
6468
useCustomRuntimeClasspathProviders(::MyClasspathProvider)
6569
useAfterAnalysisCheckers(::BlackBoxCodegenSuppressor)
70+
useAdditionalService<TemporaryDirectoryManager>(::TemporaryDirectoryManagerImplFixed)
6671
}
6772

6873
class MyClasspathProvider(testServices: TestServices) : RuntimeClasspathProvider(testServices) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.jetbrains.kotlinx.dataframe.services
2+
3+
import org.jetbrains.kotlin.test.services.TemporaryDirectoryManager
4+
import org.jetbrains.kotlin.test.services.TestServices
5+
import org.jetbrains.kotlin.test.services.testInfo
6+
import org.jetbrains.kotlin.test.util.KtTestUtil
7+
import java.io.File
8+
import java.nio.file.Paths
9+
import java.util.Locale
10+
import kotlin.io.path.ExperimentalPathApi
11+
import kotlin.io.path.deleteRecursively
12+
13+
// Copied from org.jetbrains.kotlin.test.services.impl.TemporaryDirectoryManagerImpl
14+
// because it uses NioFiles#deleteRecursively and throws method not found as a result.
15+
class TemporaryDirectoryManagerImplFixed(testServices: TestServices) : TemporaryDirectoryManager(testServices) {
16+
private val cache = mutableMapOf<String, File>()
17+
private val rootTempDir = lazy {
18+
val testInfo = testServices.testInfo
19+
val className = testInfo.className
20+
val methodName = testInfo.methodName
21+
if (!onWindows && className.length + methodName.length < 255) {
22+
return@lazy KtTestUtil.tmpDirForTest(className, methodName)
23+
}
24+
25+
// This code will simplify directory name for windows. This is needed because there can occur errors due to long name
26+
val lastDot = className.lastIndexOf('.')
27+
val simplifiedClassName = className.substring(lastDot + 1).getOnlyUpperCaseSymbols()
28+
val simplifiedMethodName = methodName.getOnlyUpperCaseSymbols()
29+
KtTestUtil.tmpDirForTest(simplifiedClassName, simplifiedMethodName)
30+
}
31+
32+
override val rootDir: File
33+
get() = rootTempDir.value
34+
35+
override fun getOrCreateTempDirectory(name: String): File =
36+
cache.getOrPut(name) {
37+
KtTestUtil.tmpDir(rootDir, name)
38+
}
39+
40+
@OptIn(ExperimentalPathApi::class)
41+
override fun cleanupTemporaryDirectories() {
42+
cache.clear()
43+
44+
if (rootTempDir.isInitialized()) {
45+
Paths.get(rootDir.path).deleteRecursively()
46+
}
47+
}
48+
49+
companion object {
50+
private val onWindows: Boolean =
51+
System.getProperty("os.name").lowercase(Locale.getDefault()).contains("windows")
52+
53+
private fun String.getOnlyUpperCaseSymbols(): String =
54+
this.filter { it.isUpperCase() || it == '$' }
55+
.toList()
56+
.joinToString(separator = "")
57+
}
58+
}

plugins/kotlin-dataframe/build.gradle.kts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,14 @@ tasks.test {
6060
useJUnitPlatform()
6161
jvmArgs("-Xmx2G")
6262
environment("TEST_RESOURCES", project.layout.projectDirectory)
63+
64+
// gets the path to JDK 11 either from gradle.properties or from the system property, defaulting to java.home
65+
environment(
66+
"JDK_11_0",
67+
project.properties["JDK_11_0"] ?: System.getProperty("JDK_11_0", System.getProperty("java.home")),
68+
)
6369
doFirst {
6470
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-stdlib", "kotlin-stdlib")
65-
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-stdlib-jdk8", "kotlin-stdlib-jdk8")
6671
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-reflect", "kotlin-reflect")
6772
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-test", "kotlin-test")
6873
setLibraryProperty("org.jetbrains.kotlin.test.kotlin-script-runtime", "kotlin-script-runtime")
@@ -83,21 +88,21 @@ tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach
8388
}
8489

8590
tasks.withType<JavaCompile> {
86-
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
87-
targetCompatibility = JavaVersion.VERSION_1_8.toString()
91+
sourceCompatibility = JavaVersion.VERSION_11.toString()
92+
targetCompatibility = JavaVersion.VERSION_11.toString()
8893
}
8994

9095
tasks.compileKotlin {
9196
compilerOptions {
9297
languageVersion = KotlinVersion.KOTLIN_2_0
93-
jvmTarget = JvmTarget.JVM_1_8
98+
jvmTarget = JvmTarget.JVM_11
9499
}
95100
}
96101

97102
tasks.compileTestKotlin {
98103
compilerOptions {
99104
languageVersion = KotlinVersion.KOTLIN_2_0
100-
jvmTarget = JvmTarget.JVM_1_8
105+
jvmTarget = JvmTarget.JVM_11
101106
}
102107
}
103108

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
kotlin.code.style=official
22
kotlinVersion=2.0.20
3+
4+
# Optionally, you can set this property to point to your JDK 11 installation.
5+
# This version is used to run the box/diagnostics tests.
6+
# JDK_11_0=/path/to/jdk_11

plugins/kotlin-dataframe/tests/org/jetbrains/kotlin/fir/dataframe/AbstractDataFrameBlackBoxCodegenTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package org.jetbrains.kotlin.fir.dataframe
77

8+
import org.jetbrains.kotlin.config.JvmTarget
89
import org.jetbrains.kotlin.fir.dataframe.services.DataFramePluginAnnotationsProvider
910
import org.jetbrains.kotlin.fir.dataframe.services.ExperimentalExtensionRegistrarConfigurator
1011
import org.jetbrains.kotlin.fir.dataframe.services.TemporaryDirectoryManagerImplFixed
@@ -40,7 +41,8 @@ open class AbstractDataFrameBlackBoxCodegenTest : AbstractFirLightTreeBlackBoxCo
4041
override fun configure(builder: TestConfigurationBuilder) {
4142
super.configure(builder)
4243
builder.defaultDirectives {
43-
JvmEnvironmentConfigurationDirectives.JDK_KIND with TestJdkKind.FULL_JDK
44+
JvmEnvironmentConfigurationDirectives.JDK_KIND with TestJdkKind.FULL_JDK_11
45+
JvmEnvironmentConfigurationDirectives.JVM_TARGET with JvmTarget.JVM_11
4446
+JvmEnvironmentConfigurationDirectives.WITH_REFLECT
4547
+IGNORE_DEXING
4648
}

plugins/kotlin-dataframe/tests/org/jetbrains/kotlin/fir/dataframe/AbstractDataFrameDiagnosticTest.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
package org.jetbrains.kotlin.fir.dataframe
77

8+
import org.jetbrains.kotlin.config.JvmTarget
89
import org.jetbrains.kotlin.fir.dataframe.services.Directives
910
import org.jetbrains.kotlin.fir.dataframe.services.DataFramePluginAnnotationsProvider
1011
import org.jetbrains.kotlin.fir.dataframe.services.ExperimentalExtensionRegistrarConfigurator
@@ -52,7 +53,8 @@ abstract class AbstractDataFrameDiagnosticTest : AbstractKotlinCompilerTest() {
5253
+FirDiagnosticsDirectives.ENABLE_PLUGIN_PHASES
5354
+FirDiagnosticsDirectives.FIR_DUMP
5455
FirDiagnosticsDirectives.FIR_PARSER with FirParser.LightTree
55-
JvmEnvironmentConfigurationDirectives.JDK_KIND with TestJdkKind.FULL_JDK
56+
JvmEnvironmentConfigurationDirectives.JDK_KIND with TestJdkKind.FULL_JDK_11
57+
JvmEnvironmentConfigurationDirectives.JVM_TARGET with JvmTarget.JVM_11
5658
}
5759

5860
useDirectives(Directives)

plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/runner/KotlinCompilationUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal object KotlinCompilationUtil {
2626
// workaround for https://github.com/tschuchortdev/kotlin-compile-testing/issues/105
2727
compilation.kotlincArguments += "-Xjava-source-roots=${javaSrcRoot.absolutePath}"
2828
compilation.jvmDefault = "all"
29-
compilation.jvmTarget = JvmTarget.JVM_1_8.description
29+
compilation.jvmTarget = JvmTarget.JVM_11.description
3030
compilation.inheritClassPath = false
3131
compilation.verbose = false
3232
compilation.classpaths = Classpaths.inheritedClasspath + classpaths

0 commit comments

Comments
 (0)