diff --git a/.travis.yml b/.travis.yml index 19d433ba..a59c65a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,11 @@ matrix: - jdk: oraclejdk7 env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.0.5-2 - jdk: oraclejdk7 - env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.1-M02 + env: TERM=dumb MOCK_MAKER=mock-maker-inline KOTLIN_VERSION=1.1-M03 - jdk: oraclejdk8 env: TERM=dumb KOTLIN_VERSION=1.0.5-2 - jdk: oraclejdk8 - env: TERM=dumb KOTLIN_VERSION=1.1-M02 + env: TERM=dumb KOTLIN_VERSION=1.1-M03 env: diff --git a/README.md b/README.md index 339bf37a..5a424b45 100644 --- a/README.md +++ b/README.md @@ -5,16 +5,11 @@ A small library that provides helper functions to work with [Mockito](https://gi ## Install -Mockito-Kotlin is available on Maven Central. +Mockito-Kotlin is available on Maven Central and JCenter. For Gradle users, add the following to your `build.gradle`, replacing `x.x.x` with the latest version: ```groovy -repositories { - mavenCentral() -} -dependencies { - testCompile "com.nhaarman:mockito-kotlin:x.x.x" -} +testCompile "com.nhaarman:mockito-kotlin:x.x.x" ``` ## Example @@ -23,7 +18,7 @@ A test using Mockito-Kotlin typically looks like the following: ```kotlin @Test -fun a(){ +fun doAction_doesSomething(){ /* Given */ val mock = mock { on { getText() } doReturn "text" diff --git a/mockito-kotlin/build.gradle b/mockito-kotlin/build.gradle index 7554969f..87111b48 100644 --- a/mockito-kotlin/build.gradle +++ b/mockito-kotlin/build.gradle @@ -14,6 +14,8 @@ buildscript { dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.9" + classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3" + classpath "com.github.dcendents:android-maven-gradle-plugin:1.5" } } diff --git a/mockito-kotlin/publishing.gradle b/mockito-kotlin/publishing.gradle index 7cc23917..c8841e11 100644 --- a/mockito-kotlin/publishing.gradle +++ b/mockito-kotlin/publishing.gradle @@ -1,11 +1,9 @@ -apply plugin: 'maven' apply plugin: 'signing' +apply plugin: 'com.jfrog.bintray' +apply plugin: 'com.github.dcendents.android-maven' group = 'com.nhaarman' version = rootProject.ext.versionName -def sonatypeUsername = hasProperty('sonatype_username') ? sonatype_username : System.getenv('SONATYPE_USERNAME') -def sonatypePassword = hasProperty('sonatype_password') ? sonatype_password : System.getenv('SONATYPE_PASSWORD') - task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' @@ -28,19 +26,10 @@ signing { sign configurations.archives } -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") { - authentication( - userName: sonatypeUsername, - password: sonatypePassword - ) - } - - pom.project { +install { + repositories.mavenInstaller { + pom { + project { name 'Mockito-Kotlin' packaging 'jar' description 'Using Mockito with Kotlin.' @@ -55,6 +44,7 @@ uploadArchives { licenses { license { name 'MIT' + url 'https://opensource.org/licenses/MIT' distribution 'repo' } } @@ -68,4 +58,35 @@ uploadArchives { } } } +} + +bintray { + user = hasProperty('bintray_username') ? bintray_username : System.getenv('BINTRAY_USER') + key = hasProperty('bintray_key') ? bintray_key : System.getenv('BINTRAY_KEY') + + configurations = ['archives'] + + publish = true + + pkg { + repo = 'maven' + name = 'Mockito-Kotlin' + licenses = ['MIT'] + vcsUrl = 'https://github.com/nhaarman/mockito-kotlin.git' + + version { + name = versionName + + gpg { + sign = true + } + + mavenCentralSync { + sync = true + user = hasProperty('sonatype_username') ? sonatype_username : System.getenv('SONATYPE_USERNAME') + password = hasProperty('sonatype_password') ? sonatype_password : System.getenv('SONATYPE_PASSWORD') + close = '1' + } + } + } } \ No newline at end of file diff --git a/mockito-kotlin/src/main/kotlin/com/nhaarman/mockito_kotlin/ArgumentCaptor.kt b/mockito-kotlin/src/main/kotlin/com/nhaarman/mockito_kotlin/ArgumentCaptor.kt index bbf093d5..5b5004d6 100644 --- a/mockito-kotlin/src/main/kotlin/com/nhaarman/mockito_kotlin/ArgumentCaptor.kt +++ b/mockito-kotlin/src/main/kotlin/com/nhaarman/mockito_kotlin/ArgumentCaptor.kt @@ -36,10 +36,6 @@ inline fun capture(captor: ArgumentCaptor): T = captor.capt class KArgumentCaptor(private val captor: ArgumentCaptor, private val tClass: KClass<*>) { - @Deprecated("Use lastValue", ReplaceWith("lastValue")) - val value: T - get() = captor.value - /** * The first captured value of the argument. * @throws IndexOutOfBoundsException if the value is not available. @@ -86,18 +82,3 @@ val ArgumentCaptor.thirdValue: T val ArgumentCaptor.lastValue: T get() = allValues.last() - -/** - * This method is deprecated because its behavior differs from the Java behavior. - * Instead, use [argumentCaptor] in the traditional way, or use one of - * [argThat], [argForWhich] or [check]. - */ -@Deprecated("Use argumentCaptor(), argThat() or check() instead.", ReplaceWith("check(consumer)"), DeprecationLevel.ERROR) -inline fun capture(noinline consumer: (T) -> Unit): T { - var times = 0 - return argThat { if (++times == 1) consumer.invoke(this); true } -} - -@Deprecated("Use captor.capture() instead.", ReplaceWith("captor.capture()"), DeprecationLevel.ERROR) -inline fun capture(captor: KArgumentCaptor): T = captor.capture() - diff --git a/mockito-kotlin/src/main/kotlin/com/nhaarman/mockito_kotlin/Mockito.kt b/mockito-kotlin/src/main/kotlin/com/nhaarman/mockito_kotlin/Mockito.kt index 9a67e3c2..86b97135 100644 --- a/mockito-kotlin/src/main/kotlin/com/nhaarman/mockito_kotlin/Mockito.kt +++ b/mockito-kotlin/src/main/kotlin/com/nhaarman/mockito_kotlin/Mockito.kt @@ -156,15 +156,3 @@ fun verifyZeroInteractions(vararg mocks: Any) = Mockito.verifyZeroInteractions(* fun whenever(methodCall: T): OngoingStubbing = Mockito.`when`(methodCall)!! fun withSettings(): MockSettings = Mockito.withSettings()!! - -@Deprecated("Use any() instead.", ReplaceWith("any()"), DeprecationLevel.ERROR) -inline fun anyCollection(): Collection = any() - -@Deprecated("Use any() instead.", ReplaceWith("any()"), DeprecationLevel.ERROR) -inline fun anyList(): List = any() - -@Deprecated("Use any() instead.", ReplaceWith("any()"), DeprecationLevel.ERROR) -inline fun anySet(): Set = any() - -@Deprecated("Use any() instead.", ReplaceWith("any()"), DeprecationLevel.ERROR) -inline fun anyMap(): Map = any() diff --git a/mockito-kotlin/src/test/kotlin/test/createinstance/NullCasterTest.kt b/mockito-kotlin/src/test/kotlin/test/createinstance/NullCasterTest.kt index 15df3e86..3a89f977 100644 --- a/mockito-kotlin/src/test/kotlin/test/createinstance/NullCasterTest.kt +++ b/mockito-kotlin/src/test/kotlin/test/createinstance/NullCasterTest.kt @@ -28,6 +28,6 @@ class NullCasterTest : TestBase() { acceptNonNullableString(s) } - private fun acceptNonNullableString(s: String) { + private fun acceptNonNullableString(@Suppress("UNUSED_PARAMETER") s: String) { } }