File tree 4 files changed +63
-1
lines changed
libraries/tools/kotlin-gradle-plugin-integration-tests
src/test/kotlin/org/jetbrains/kotlin/gradle
plugins/kapt3/kapt3-base/src/org/jetbrains/kotlin/kapt3/base/util
4 files changed +63
-1
lines changed Original file line number Diff line number Diff line change 1
1
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
2
+ import org.gradle.jvm.toolchain.internal.NoToolchainAvailableException
2
3
import org.jetbrains.kotlin.pill.PillExtension
3
4
import java.nio.file.Paths
4
5
@@ -386,6 +387,12 @@ tasks.withType<Test> {
386
387
systemProperty(" jdk11Home" , jdk11Provider.get())
387
388
systemProperty(" jdk16Home" , jdk16Provider.get())
388
389
systemProperty(" jdk17Home" , jdk17Provider.get())
390
+ // jdk21Provider.isPresent throws NoToolchainAvailableException, so, we have to check for the exception
391
+ // Storing jdk21Provider in a field leads to "Configuration cache state could not be cached" error,
392
+ // since it tries to resolve the toolchain as well.
393
+ try {
394
+ systemProperty(" jdk21Home" , project.getToolchainJdkHomeFor(JdkMajorVersion .JDK_21_0 ).get())
395
+ } catch (_: NoToolchainAvailableException ) {}
389
396
if (mavenLocalRepo != null ) {
390
397
systemProperty(" maven.repo.local" , mavenLocalRepo)
391
398
}
Original file line number Diff line number Diff line change @@ -250,6 +250,36 @@ open class Kapt3IT : Kapt3BaseIT() {
250
250
}
251
251
}
252
252
253
+ // TODO: Remove as JDK 21 is supported on Java Toolchains
254
+ @DisplayName(" Kapt is working with JDK 21" )
255
+ @GradleTest
256
+ @GradleTestVersions(minVersion = TestVersions .Gradle .G_7_3 )
257
+ @EnableOnJdk21
258
+ fun doTestSimpleWithJdk21 (
259
+ gradleVersion : GradleVersion
260
+ ) {
261
+ project(
262
+ " simple" .withPrefix,
263
+ gradleVersion
264
+ ) {
265
+ // language=Groovy
266
+ buildGradle.appendText(
267
+ """
268
+ |
269
+ |kotlin {
270
+ | jvmToolchain(21)
271
+ |}
272
+ """ .trimMargin()
273
+ )
274
+
275
+ build(" assemble" ) {
276
+ assertTasksExecuted(" :kaptGenerateStubsKotlin" , " :kaptKotlin" )
277
+ // Check added because of https://youtrack.jetbrains.com/issue/KT-33056.
278
+ assertOutputDoesNotContain(" javaslang.match.PatternsProcessor" )
279
+ }
280
+ }
281
+ }
282
+
253
283
@DisplayName(" KT-48402: Kapt worker classpath is using JRE classes from toolchain" )
254
284
@JdkVersions(versions = [JavaVersion .VERSION_16 ])
255
285
@GradleWithJdkTest
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
3
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
4
+ */
5
+
6
+ package org.jetbrains.kotlin.gradle.testbase
7
+
8
+ import org.junit.jupiter.api.extension.ConditionEvaluationResult
9
+ import org.junit.jupiter.api.extension.ExecutionCondition
10
+ import org.junit.jupiter.api.extension.ExtendWith
11
+ import org.junit.jupiter.api.extension.ExtensionContext
12
+
13
+ class EnableOnJdk21Condition : ExecutionCondition {
14
+ override fun evaluateExecutionCondition (context : ExtensionContext ? ): ConditionEvaluationResult =
15
+ if (System .getProperty(" jdk21Home" ) == null ) {
16
+ ConditionEvaluationResult .disabled(" No JDK 21 Found" )
17
+ } else {
18
+ ConditionEvaluationResult .enabled(" JDK 21 Found" )
19
+ }
20
+ }
21
+
22
+ @Target(AnnotationTarget .FUNCTION )
23
+ @Retention(AnnotationRetention .RUNTIME )
24
+ @ExtendWith(EnableOnJdk21Condition ::class )
25
+ annotation class EnableOnJdk21
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ val REQUIRED_PACKAGES_TO_TEST_CLASSES = mapOf(
15
15
" com.sun.tools.javac.util" to " Context" ,
16
16
" com.sun.tools.javac.file" to " CacheFSInfo" ,
17
17
" com.sun.tools.javac.tree" to " TreeTranslator" ,
18
- " com.sun.tools.javac.main" to " CommandLine " ,
18
+ " com.sun.tools.javac.main" to " Option " ,
19
19
" com.sun.tools.javac.jvm" to " ClassFile" ,
20
20
" com.sun.tools.javac.parser" to " Tokens\$ TokenKind" ,
21
21
" com.sun.tools.javac.code" to " Source" ,
You can’t perform that action at this time.
0 commit comments