From cc8ed1a82c41b37a864041f6f311c045308c9354 Mon Sep 17 00:00:00 2001 From: Sergei Kuchin Date: Wed, 29 Nov 2023 18:55:53 +0100 Subject: [PATCH] Main dependencies updated: - gradle wrapper to 8.1 - kotlin to 1.9.20 - mockito-core to version 5.7.0 - few other related changes --- gradle/publishing.gradle | 10 ++--- gradle/wrapper/gradle-wrapper.properties | 2 +- mockito-kotlin/build.gradle | 39 ++++++++++--------- .../main/kotlin/org/mockito/kotlin/Mocking.kt | 2 +- tests/build.gradle | 22 +++++++---- .../test/kotlin/test/OngoingStubbingTest.kt | 26 ++++++++----- 6 files changed, 58 insertions(+), 43 deletions(-) diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle index 177c9732..e29a1b9e 100644 --- a/gradle/publishing.gradle +++ b/gradle/publishing.gradle @@ -2,11 +2,12 @@ apply plugin: 'maven-publish' task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' + archiveClassifier = 'javadoc' from 'build/javadoc' } task sourceJar(type: Jar) { + archiveClassifier = "sources" from sourceSets.main.allSource } @@ -17,10 +18,7 @@ publishing { from components.java - artifact sourceJar { - classifier "sources" - } - + artifact sourceJar artifact javadocJar pom.withXml { @@ -67,4 +65,4 @@ signing { useInMemoryPgpKeys(System.getenv("PGP_KEY"), System.getenv("PGP_PWD")) sign publishing.publications.javaLibrary } -} \ No newline at end of file +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ec991f9a..59bc51a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/mockito-kotlin/build.gradle b/mockito-kotlin/build.gradle index 868260f7..9b38018c 100644 --- a/mockito-kotlin/build.gradle +++ b/mockito-kotlin/build.gradle @@ -1,3 +1,4 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile apply plugin: 'kotlin' @@ -5,7 +6,7 @@ apply from: '../gradle/publishing.gradle' apply plugin: 'org.jetbrains.dokka' buildscript { - ext.kotlin_version = "1.4.20" + ext.kotlin_version = "1.9.20" repositories { mavenCentral() @@ -13,7 +14,7 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17" + classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.9.10" } } @@ -25,33 +26,35 @@ dependencies { compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compileOnly 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.0' - compile "org.mockito:mockito-core:5.3.1" + implementation "org.mockito:mockito-core:5.7.0" - testCompile 'junit:junit:4.13.2' - testCompile 'com.nhaarman:expect.kt:1.0.1' + testImplementation 'junit:junit:4.13.2' + testImplementation 'com.nhaarman:expect.kt:1.0.1' - testCompile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version" - testCompile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0' + testImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" + testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0' testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.0" } -dokka { - outputFormat = 'html' - outputDirectory = "$buildDir/javadoc" +dokkaHtml.configure { + outputDirectory.set(file("$buildDir/javadoc")) - linkMapping { - dir = "src/main/kotlin" - url = "https://github.com/nhaarman/mockito-kotlin/tree/master/mockito-kotlin/src/main/kotlin" - suffix = "#L" + dokkaSourceSets { + named("main") { + localDirectory.set(file("src/main/kotlin")) + remoteUrl.set(new URL("https://github.com/nhaarman/mockito-kotlin/tree/master/mockito-kotlin/src/main/kotlin")) + remoteLineSuffix.set("#L") + } } } tasks.withType(KotlinCompile).configureEach { - kotlinOptions { - jvmTarget = JavaVersion.VERSION_11 + compilerOptions { + jvmTarget.set(JvmTarget.JVM_11) + targetCompatibility = "11" } } -javadoc.dependsOn dokka +javadoc.dependsOn dokkaHtml diff --git a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mocking.kt b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mocking.kt index 9f6acd27..f45f97ea 100644 --- a/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mocking.kt +++ b/mockito-kotlin/src/main/kotlin/org/mockito/kotlin/Mocking.kt @@ -208,4 +208,4 @@ inline fun mock(s: String): T = mock(name = s) @Suppress("DeprecatedCallableAddReplaceWith") @Deprecated("Use mock() with optional arguments instead.", level = ERROR) -inline fun mock(s: MockSettings): T = Mockito.mock(T::class.java, s)!! \ No newline at end of file +inline fun mock(s: MockSettings): T = Mockito.mock(T::class.java, s)!! diff --git a/tests/build.gradle b/tests/build.gradle index 6d190aa9..5e05cf4e 100644 --- a/tests/build.gradle +++ b/tests/build.gradle @@ -1,7 +1,8 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile buildscript { - ext.kotlin_version = System.getenv("KOTLIN_VERSION") ?: '1.4.20' + ext.kotlin_version = System.getenv("KOTLIN_VERSION") ?: '1.9.20' println "$project uses Kotlin $kotlin_version" repositories { @@ -19,18 +20,23 @@ repositories { mavenCentral() } +tasks.named('compileTestKotlin') { + dependsOn ':mockito-kotlin:jar' +} + dependencies { - compile files("${rootProject.projectDir}/mockito-kotlin/build/libs/mockito-kotlin-${version}.jar") + implementation files("${rootProject.projectDir}/mockito-kotlin/build/libs/mockito-kotlin-${version}.jar") - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.mockito:mockito-core:5.3.1" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.mockito:mockito-core:5.7.0" - testCompile 'junit:junit:4.13.2' - testCompile "com.nhaarman:expect.kt:1.0.1" + testImplementation 'junit:junit:4.13.2' + testImplementation "com.nhaarman:expect.kt:1.0.1" } tasks.withType(KotlinCompile).configureEach { - kotlinOptions { - jvmTarget = JavaVersion.VERSION_11 + compilerOptions { + jvmTarget.set(JvmTarget.JVM_11) + targetCompatibility = "11" } } diff --git a/tests/src/test/kotlin/test/OngoingStubbingTest.kt b/tests/src/test/kotlin/test/OngoingStubbingTest.kt index c5dfb7ca..bf2af984 100644 --- a/tests/src/test/kotlin/test/OngoingStubbingTest.kt +++ b/tests/src/test/kotlin/test/OngoingStubbingTest.kt @@ -7,9 +7,18 @@ import org.junit.Assume.assumeFalse import org.junit.Test import org.mockito.Mockito import org.mockito.exceptions.misusing.UnfinishedStubbingException -import org.mockito.kotlin.* +import org.mockito.kotlin.any +import org.mockito.kotlin.argThat +import org.mockito.kotlin.check +import org.mockito.kotlin.doAnswer +import org.mockito.kotlin.doReturn +import org.mockito.kotlin.doReturnConsecutively +import org.mockito.kotlin.doThrow +import org.mockito.kotlin.mock +import org.mockito.kotlin.stub +import org.mockito.kotlin.stubbing +import org.mockito.kotlin.whenever import org.mockito.stubbing.Answer -import kotlin.check class OngoingStubbingTest : TestBase() { @@ -288,14 +297,13 @@ class OngoingStubbingTest : TestBase() { @Test fun doReturn_withGenericIntReturnType_on() { - /* Expect */ - expectErrorWithMessage("onGeneric") on { - - /* When */ - mock> { - on { genericMethod() } doReturn 2 - } + /* When */ + val mock = mock> { + on { genericMethod() } doReturn 2 } + + /* Then */ + expect(mock.genericMethod()).toBe(2) } @Test