diff --git a/build.gradle b/build.gradle index 2fec351718b..316903567bf 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'io.spring.dependency-management' version '1.0.9.RELEASE' apply false - id 'org.jetbrains.kotlin.jvm' version '1.3.72' apply false + id 'org.jetbrains.kotlin.jvm' version '1.4-M2' apply false id 'org.jetbrains.dokka' version '0.10.1' apply false id 'org.asciidoctor.jvm.convert' version '2.4.0' id 'io.spring.nohttp' version '0.0.4.RELEASE' @@ -28,8 +28,8 @@ configure(allprojects) { project -> mavenBom "io.projectreactor:reactor-bom:2020.0.0-SNAPSHOT" mavenBom "io.rsocket:rsocket-bom:1.0.1" mavenBom "org.eclipse.jetty:jetty-bom:9.4.29.v20200521" - mavenBom "org.jetbrains.kotlin:kotlin-bom:1.3.72" - mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.5" + mavenBom "org.jetbrains.kotlin:kotlin-bom:1.4-M2" + mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.3.7-1.4-M2" mavenBom "org.junit:junit-bom:5.6.2" } dependencies { @@ -285,6 +285,8 @@ configure(allprojects) { project -> mavenCentral() maven { url "https://repo.spring.io/libs-spring-framework-build" } maven { url "https://repo.spring.io/snapshot" } // Reactor + maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // Kotlin + maven { url "https://kotlin.bintray.com/kotlinx" } // Coroutines } } configurations.all { @@ -307,9 +309,16 @@ configure([rootProject] + javaProjects) { project -> pluginManager.withPlugin("kotlin") { apply plugin: "org.jetbrains.dokka" + // Workaround for https://youtrack.jetbrains.com/issue/KT-39610 + configurations["kotlinCompilerPluginClasspath"].attributes.attribute( + org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, + objects.named(Usage.class, "java-runtime") + ) compileKotlin { kotlinOptions { jvmTarget = "1.8" + languageVersion = "1.3" + apiVersion = "1.3" freeCompilerArgs = ["-Xjsr305=strict"] allWarningsAsErrors = true } diff --git a/settings.gradle b/settings.gradle index 1d84e98f423..2d15cac3a2a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,6 +2,7 @@ pluginManagement { repositories { gradlePluginPortal() maven { url 'https://repo.spring.io/plugins-release' } + maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // Kotlin } } diff --git a/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt b/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt index eb2dfe36714..1ce7820d736 100644 --- a/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt +++ b/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors + * Copyright 2002-2020 the original author or authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,7 +53,7 @@ class JdbcOperationsExtensionsTests { @Test // gh-22682 fun `queryForObject with nullable RowMapper-like function`() { every { template.queryForObject(sql, any>(), 3) } returns null - assertThat(template.queryForObject(sql, 3) { _, _ -> null as Int? }).isNull() + assertThat(template.queryForObject(sql, 3) { _, _ -> null }).isNull() verify { template.queryForObject(eq(sql), any>(), eq(3)) } } @@ -130,7 +130,7 @@ class JdbcOperationsExtensionsTests { @Test fun `query with RowMapper-like function`() { - val list = listOf(1, 2, 3) + val list = mutableListOf(1, 2, 3) every { template.query(sql, ofType>(), 3) } returns list assertThat(template.query(sql, 3) { rs, _ -> rs.getInt(1) diff --git a/spring-messaging/spring-messaging.gradle b/spring-messaging/spring-messaging.gradle index b1e9bae989e..87f77a95a18 100644 --- a/spring-messaging/spring-messaging.gradle +++ b/spring-messaging/spring-messaging.gradle @@ -2,6 +2,12 @@ description = "Spring Messaging" apply plugin: "kotlin" +// Workaround for https://youtrack.jetbrains.com/issue/KT-39610 +configurations["optional"].attributes.attribute( + org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, + objects.named(Usage.class, "java-runtime") +) + dependencies { compile(project(":spring-beans")) compile(project(":spring-core")) diff --git a/spring-messaging/src/test/kotlin/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerKotlinTests.kt b/spring-messaging/src/test/kotlin/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerKotlinTests.kt index 9e49d6dc6ae..27c03041597 100644 --- a/spring-messaging/src/test/kotlin/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerKotlinTests.kt +++ b/spring-messaging/src/test/kotlin/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerKotlinTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -132,7 +132,7 @@ class SimpAnnotationMethodMessageHandlerKotlinTests { messageHandler.registerHandler(testController) messageHandler.handleMessage(message) assertThat(testController.exception).isNotNull() - assertThat(testController.exception).isInstanceOf(IllegalArgumentException::class.java) + assertThat(testController.exception).isInstanceOf(NullPointerException::class.java) } private fun createMessage(destination: String, headers: Map): Message { diff --git a/spring-test/spring-test.gradle b/spring-test/spring-test.gradle index e240001a1b6..ef413bc466c 100644 --- a/spring-test/spring-test.gradle +++ b/spring-test/spring-test.gradle @@ -2,6 +2,12 @@ description = "Spring TestContext Framework" apply plugin: "kotlin" +// Workaround for https://youtrack.jetbrains.com/issue/KT-39610 +configurations["optional"].attributes.attribute( + org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, + objects.named(Usage.class, "java-runtime") +) + dependencies { compile(project(":spring-core")) optional(project(":spring-aop")) diff --git a/spring-tx/spring-tx.gradle b/spring-tx/spring-tx.gradle index 99c82989264..7c5cde91f82 100644 --- a/spring-tx/spring-tx.gradle +++ b/spring-tx/spring-tx.gradle @@ -2,6 +2,12 @@ description = "Spring Transaction" apply plugin: "kotlin" +// Workaround for https://youtrack.jetbrains.com/issue/KT-39610 +configurations["optional"].attributes.attribute( + org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, + objects.named(Usage.class, "java-runtime") +) + dependencies { compile(project(":spring-beans")) compile(project(":spring-core")) diff --git a/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt b/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt index 61c32fec346..07d989bcf65 100644 --- a/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt +++ b/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -139,7 +139,7 @@ class RequestParamMethodArgumentResolverKotlinTests { @Test fun resolveNonNullableNotRequiredWithoutParameter() { - assertThatExceptionOfType(TypeCastException::class.java).isThrownBy { + assertThatExceptionOfType(NullPointerException::class.java).isThrownBy { resolver.resolveArgument(nonNullableParamNotRequired, null, webRequest, binderFactory) as String } } @@ -221,7 +221,7 @@ class RequestParamMethodArgumentResolverKotlinTests { request.method = HttpMethod.POST.name request.contentType = MediaType.MULTIPART_FORM_DATA_VALUE - assertThatExceptionOfType(TypeCastException::class.java).isThrownBy { + assertThatExceptionOfType(NullPointerException::class.java).isThrownBy { resolver.resolveArgument(nonNullableMultipartParamNotRequired, null, webRequest, binderFactory) as MultipartFile } } diff --git a/spring-webflux/spring-webflux.gradle b/spring-webflux/spring-webflux.gradle index 45c9eac256c..11e7587643c 100644 --- a/spring-webflux/spring-webflux.gradle +++ b/spring-webflux/spring-webflux.gradle @@ -2,6 +2,12 @@ description = "Spring WebFlux" apply plugin: "kotlin" +// Workaround for https://youtrack.jetbrains.com/issue/KT-39610 +configurations["optional"].attributes.attribute( + org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, + objects.named(Usage.class, "java-runtime") +) + dependencies { compile(project(":spring-beans")) compile(project(":spring-core"))