diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt index 8b2894c9c..d0d927d0a 100644 --- a/buildSrc/src/main/java/Config.kt +++ b/buildSrc/src/main/java/Config.kt @@ -1,5 +1,5 @@ object Config { - val kotlinVersion = "1.3.72" + val kotlinVersion = "1.4.0" val kotlinStdLib = "stdlib-jdk8" object BuildPlugins { @@ -23,39 +23,40 @@ object Config { } object Libs { - val appCompat = "androidx.appcompat:appcompat:1.1.0" + val appCompat = "androidx.appcompat:appcompat:1.2.0" val timber = "com.jakewharton.timber:timber:4.7.1" // only bump gson if https://github.com/google/gson/issues/1597 is fixed val gson = "com.google.code.gson:gson:2.8.5" - val leakCanary = "com.squareup.leakcanary:leakcanary-android:2.3" + val leakCanary = "com.squareup.leakcanary:leakcanary-android:2.4" - val lifecycleVersion = "2.2.0" + private val lifecycleVersion = "2.2.0" val lifecycleProcess = "androidx.lifecycle:lifecycle-process:$lifecycleVersion" val lifecycleCommonJava8 = "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion" } object TestLibs { - private val androidxTestVersion = "1.2.0" + private val androidxTestVersion = "1.3.0" val kotlinTestJunit = "org.jetbrains.kotlin:kotlin-test-junit:$kotlinVersion" val androidxCore = "androidx.test:core:$androidxTestVersion" val androidxRunner = "androidx.test:runner:$androidxTestVersion" - val androidxJunit = "androidx.test.ext:junit:1.1.1" - val robolectric = "org.robolectric:robolectric:4.3.1" + val androidxJunit = "androidx.test.ext:junit:1.1.2" + val robolectric = "org.robolectric:robolectric:4.4" val mockitoKotlin = "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0" + val mockitoInline = "org.mockito:mockito-inline:3.5.10" val awaitility = "org.awaitility:awaitility-kotlin:4.0.3" } object QualityPlugins { val jacocoVersion = "0.8.5" val spotless = "com.diffplug.spotless" - val spotlessVersion = "5.1.0" + val spotlessVersion = "5.3.0" val errorProne = "net.ltgt.errorprone" val errorpronePlugin = "net.ltgt.gradle:gradle-errorprone-plugin:1.2.1" - val gradleVersionsPlugin = "com.github.ben-manes:gradle-versions-plugin:0.29.0" + val gradleVersionsPlugin = "com.github.ben-manes:gradle-versions-plugin:0.31.0" val gradleVersions = "com.github.ben-manes.versions" val detekt = "io.gitlab.arturbosch.detekt" - val detektVersion = "1.10.0" + val detektVersion = "1.12.0" val detektPlugin = "io.gitlab.arturbosch.detekt" } @@ -83,7 +84,7 @@ object Config { object CompileOnly { private val nopenVersion = "1.0.1" - val jetbrainsAnnotations = "org.jetbrains:annotations:20.0.0" + val jetbrainsAnnotations = "org.jetbrains:annotations:20.1.0" val nopen = "com.jakewharton.nopen:nopen-annotations:$nopenVersion" val nopenChecker = "com.jakewharton.nopen:nopen-checker:$nopenVersion" val errorprone = "com.google.errorprone:error_prone_core:2.4.0" diff --git a/sentry-android-core/build.gradle.kts b/sentry-android-core/build.gradle.kts index ed347249c..dbbc6948a 100644 --- a/sentry-android-core/build.gradle.kts +++ b/sentry-android-core/build.gradle.kts @@ -64,6 +64,11 @@ android { // We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks. isCheckReleaseBuilds = false } + + // needed because of Kotlin 1.4.x + configurations.all { + resolutionStrategy.force(Config.CompileOnly.jetbrainsAnnotations) + } } dependencies { @@ -87,6 +92,7 @@ dependencies { testImplementation(Config.TestLibs.androidxRunner) testImplementation(Config.TestLibs.androidxJunit) testImplementation(Config.TestLibs.mockitoKotlin) + testImplementation(Config.TestLibs.mockitoInline) testImplementation(Config.TestLibs.awaitility) } diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/ANRWatchDogTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/ANRWatchDogTest.kt index 5a8b932d1..b316524b1 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/ANRWatchDogTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/ANRWatchDogTest.kt @@ -8,7 +8,6 @@ import com.nhaarman.mockitokotlin2.any import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.whenever -import io.sentry.android.core.ANRWatchDog.ANRListener import java.util.concurrent.CountDownLatch import java.util.concurrent.Executors import java.util.concurrent.TimeUnit @@ -32,7 +31,7 @@ class ANRWatchDogTest { whenever(handler.post(any())).then { latch.countDown() } whenever(handler.thread).thenReturn(thread) val interval = 1L - val sut = ANRWatchDog(interval, true, ANRListener { a -> anr = a }, mock(), handler, mock()) + val sut = ANRWatchDog(interval, true, { a -> anr = a }, mock(), handler, mock()) val es = Executors.newSingleThreadExecutor() try { es.submit { sut.run() } @@ -64,7 +63,7 @@ class ANRWatchDogTest { } whenever(handler.thread).thenReturn(thread) val interval = 1L - val sut = ANRWatchDog(interval, true, ANRListener { a -> anr = a }, mock(), handler, mock()) + val sut = ANRWatchDog(interval, true, { a -> anr = a }, mock(), handler, mock()) val es = Executors.newSingleThreadExecutor() try { es.submit { sut.run() } @@ -103,7 +102,7 @@ class ANRWatchDogTest { stateInfo.condition = NOT_RESPONDING val anrs = listOf(stateInfo) whenever(am.processesInErrorState).thenReturn(anrs) - val sut = ANRWatchDog(interval, true, ANRListener { a -> anr = a }, mock(), handler, context) + val sut = ANRWatchDog(interval, true, { a -> anr = a }, mock(), handler, context) val es = Executors.newSingleThreadExecutor() try { es.submit { sut.run() } @@ -144,7 +143,7 @@ class ANRWatchDogTest { stateInfo.condition = NO_ERROR val anrs = listOf(stateInfo) whenever(am.processesInErrorState).thenReturn(anrs) - val sut = ANRWatchDog(interval, true, ANRListener { a -> anr = a }, mock(), handler, context) + val sut = ANRWatchDog(interval, true, { a -> anr = a }, mock(), handler, context) val es = Executors.newSingleThreadExecutor() try { es.submit { sut.run() } diff --git a/sentry-android-ndk/build.gradle.kts b/sentry-android-ndk/build.gradle.kts index dee6a9235..d6ccf4b2c 100644 --- a/sentry-android-ndk/build.gradle.kts +++ b/sentry-android-ndk/build.gradle.kts @@ -92,6 +92,11 @@ android { nativeBundleExport { headerDir = "${project.projectDir}/$sentryNativeSrc/include" } + + // needed because of Kotlin 1.4.x + configurations.all { + resolutionStrategy.force(Config.CompileOnly.jetbrainsAnnotations) + } } dependencies { diff --git a/sentry-android-timber/build.gradle.kts b/sentry-android-timber/build.gradle.kts index 75a857800..db948e00f 100644 --- a/sentry-android-timber/build.gradle.kts +++ b/sentry-android-timber/build.gradle.kts @@ -77,6 +77,7 @@ dependencies { testImplementation(Config.TestLibs.kotlinTestJunit) testImplementation(Config.TestLibs.androidxJunit) testImplementation(Config.TestLibs.mockitoKotlin) + testImplementation(Config.TestLibs.mockitoInline) } //TODO: move thse blocks to parent gradle file, DRY diff --git a/sentry-android-timber/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/sentry-android-timber/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker new file mode 100644 index 000000000..1f0955d45 --- /dev/null +++ b/sentry-android-timber/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -0,0 +1 @@ +mock-maker-inline diff --git a/sentry-core/build.gradle.kts b/sentry-core/build.gradle.kts index 58bb6468a..33d152971 100644 --- a/sentry-core/build.gradle.kts +++ b/sentry-core/build.gradle.kts @@ -33,6 +33,7 @@ dependencies { testImplementation(kotlin(Config.kotlinStdLib)) testImplementation(Config.TestLibs.kotlinTestJunit) testImplementation(Config.TestLibs.mockitoKotlin) + testImplementation(Config.TestLibs.mockitoInline) testImplementation(Config.TestLibs.awaitility) } diff --git a/sentry-core/src/main/java/io/sentry/core/MainEventProcessor.java b/sentry-core/src/main/java/io/sentry/core/MainEventProcessor.java index 5268a99e9..6d2bc6597 100644 --- a/sentry-core/src/main/java/io/sentry/core/MainEventProcessor.java +++ b/sentry-core/src/main/java/io/sentry/core/MainEventProcessor.java @@ -22,8 +22,7 @@ public final class MainEventProcessor implements EventProcessor { new SentryStackTraceFactory(options.getInAppExcludes(), options.getInAppIncludes()); sentryExceptionFactory = new SentryExceptionFactory(sentryStackTraceFactory); - sentryThreadFactory = - new SentryThreadFactory(sentryStackTraceFactory, this.options); + sentryThreadFactory = new SentryThreadFactory(sentryStackTraceFactory, this.options); } MainEventProcessor( diff --git a/sentry-core/src/main/java/io/sentry/core/SentryThreadFactory.java b/sentry-core/src/main/java/io/sentry/core/SentryThreadFactory.java index 8b19b16ba..fe2b223f8 100644 --- a/sentry-core/src/main/java/io/sentry/core/SentryThreadFactory.java +++ b/sentry-core/src/main/java/io/sentry/core/SentryThreadFactory.java @@ -17,9 +17,7 @@ final class SentryThreadFactory { /** the SentryStackTraceFactory */ private final @NotNull SentryStackTraceFactory sentryStackTraceFactory; - /** - * the SentryOptions. - */ + /** the SentryOptions. */ private final @NotNull SentryOptions options; /** @@ -29,7 +27,8 @@ final class SentryThreadFactory { * @param options the SentryOptions */ public SentryThreadFactory( - final @NotNull SentryStackTraceFactory sentryStackTraceFactory, final @NotNull SentryOptions options) { + final @NotNull SentryStackTraceFactory sentryStackTraceFactory, + final @NotNull SentryOptions options) { this.sentryStackTraceFactory = Objects.requireNonNull(sentryStackTraceFactory, "The SentryStackTraceFactory is required."); this.options = Objects.requireNonNull(options, "The SentryOptions is required"); diff --git a/sentry-core/src/test/java/io/sentry/core/DirectoryProcessorTest.kt b/sentry-core/src/test/java/io/sentry/core/DirectoryProcessorTest.kt index 231180698..7a8e0cea2 100644 --- a/sentry-core/src/test/java/io/sentry/core/DirectoryProcessorTest.kt +++ b/sentry-core/src/test/java/io/sentry/core/DirectoryProcessorTest.kt @@ -8,7 +8,7 @@ import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.whenever import io.sentry.core.hints.ApplyScopeData import io.sentry.core.protocol.User -import io.sentry.core.util.NoFlushTimeout +import io.sentry.core.util.noFlushTimeout import java.io.File import java.nio.file.Files import java.nio.file.Paths @@ -25,7 +25,7 @@ class DirectoryProcessorTest { var envelopeReader: IEnvelopeReader = mock() var serializer: ISerializer = mock() var logger: ILogger = mock() - var options = SentryOptions().NoFlushTimeout() + var options = SentryOptions().noFlushTimeout() init { options.isDebug = true diff --git a/sentry-core/src/test/java/io/sentry/core/EnvelopeSenderTest.kt b/sentry-core/src/test/java/io/sentry/core/EnvelopeSenderTest.kt index 7f2817375..2babeb95f 100644 --- a/sentry-core/src/test/java/io/sentry/core/EnvelopeSenderTest.kt +++ b/sentry-core/src/test/java/io/sentry/core/EnvelopeSenderTest.kt @@ -29,13 +29,6 @@ class EnvelopeSenderTest { var envelopeReader: IEnvelopeReader = mock() var serializer: ISerializer = mock() var logger: ILogger = mock() - var options: SentryOptions - - init { - options = SentryOptions() - options.isDebug = true - options.setLogger(logger) - } fun getSut(): EnvelopeSender { return EnvelopeSender(hub, envelopeReader, serializer, logger, 15000) diff --git a/sentry-core/src/test/java/io/sentry/core/SendCachedEventTest.kt b/sentry-core/src/test/java/io/sentry/core/SendCachedEventTest.kt index 0d8453dd4..c32449807 100644 --- a/sentry-core/src/test/java/io/sentry/core/SendCachedEventTest.kt +++ b/sentry-core/src/test/java/io/sentry/core/SendCachedEventTest.kt @@ -9,7 +9,7 @@ import com.nhaarman.mockitokotlin2.verifyNoMoreInteractions import com.nhaarman.mockitokotlin2.whenever import io.sentry.core.cache.DiskCache import io.sentry.core.hints.Retryable -import io.sentry.core.util.NoFlushTimeout +import io.sentry.core.util.noFlushTimeout import java.io.File import java.nio.file.Files import java.nio.file.Path @@ -23,7 +23,7 @@ class SendCachedEventTest { var hub: IHub? = mock() var logger: ILogger? = mock() var serializer: ISerializer? = mock() - var options = SentryOptions().NoFlushTimeout() + var options = SentryOptions().noFlushTimeout() init { options.isDebug = true diff --git a/sentry-core/src/test/java/io/sentry/core/SentryClientTest.kt b/sentry-core/src/test/java/io/sentry/core/SentryClientTest.kt index 08cb4531d..edd509680 100644 --- a/sentry-core/src/test/java/io/sentry/core/SentryClientTest.kt +++ b/sentry-core/src/test/java/io/sentry/core/SentryClientTest.kt @@ -635,7 +635,7 @@ class SentryClientTest { scope.setContexts("key", "value") scope.startSession().current sut.captureEvent(event, scope, null) - verify(fixture.connection).send(check() { + verify(fixture.connection).send(check { assertEquals("value", it.contexts["key"]) }, anyOrNull()) } @@ -645,12 +645,12 @@ class SentryClientTest { val sut = fixture.getSut() val event = SentryEvent() - event.contexts.put("key", "event value") + event.contexts["key"] = "event value" val scope = Scope(fixture.sentryOptions) scope.setContexts("key", "scope value") scope.startSession().current sut.captureEvent(event, scope, null) - verify(fixture.connection).send(check() { + verify(fixture.connection).send(check { assertEquals("event value", it.contexts["key"]) }, anyOrNull()) } diff --git a/sentry-core/src/test/java/io/sentry/core/SentryExceptionFactoryTest.kt b/sentry-core/src/test/java/io/sentry/core/SentryExceptionFactoryTest.kt index 97236bc94..471680856 100644 --- a/sentry-core/src/test/java/io/sentry/core/SentryExceptionFactoryTest.kt +++ b/sentry-core/src/test/java/io/sentry/core/SentryExceptionFactoryTest.kt @@ -84,8 +84,8 @@ class SentryExceptionFactoryTest { assertEquals(thread.id, queue.first.threadId) } - internal inner class InnerClassThrowable constructor(cause: Throwable? = null) : Throwable(cause) + internal class InnerClassThrowable constructor(cause: Throwable? = null) : Throwable(cause) - internal val anonymousException = object : Exception() { + private val anonymousException = object : Exception() { } } diff --git a/sentry-core/src/test/java/io/sentry/core/UncaughtExceptionHandlerIntegrationTest.kt b/sentry-core/src/test/java/io/sentry/core/UncaughtExceptionHandlerIntegrationTest.kt index cfda29c34..7ddc0c0dc 100644 --- a/sentry-core/src/test/java/io/sentry/core/UncaughtExceptionHandlerIntegrationTest.kt +++ b/sentry-core/src/test/java/io/sentry/core/UncaughtExceptionHandlerIntegrationTest.kt @@ -9,7 +9,7 @@ import com.nhaarman.mockitokotlin2.verifyZeroInteractions import com.nhaarman.mockitokotlin2.whenever import io.sentry.core.exception.ExceptionMechanismException import io.sentry.core.protocol.SentryId -import io.sentry.core.util.NoFlushTimeout +import io.sentry.core.util.noFlushTimeout import java.io.File import java.nio.file.Files import kotlin.test.AfterTest @@ -45,7 +45,7 @@ class UncaughtExceptionHandlerIntegrationTest { val threadMock = mock() val throwableMock = mock() val hubMock = mock() - val options = SentryOptions().NoFlushTimeout() + val options = SentryOptions().noFlushTimeout() val sut = UncaughtExceptionHandlerIntegration(handlerMock) sut.register(hubMock, options) sut.uncaughtException(threadMock, throwableMock) @@ -60,7 +60,7 @@ class UncaughtExceptionHandlerIntegrationTest { val defaultHandlerMock = mock() whenever(handlerMock.defaultUncaughtExceptionHandler).thenReturn(defaultHandlerMock) val hubMock = mock() - val options = SentryOptions().NoFlushTimeout() + val options = SentryOptions().noFlushTimeout() val sut = UncaughtExceptionHandlerIntegration(handlerMock) sut.register(hubMock, options) sut.uncaughtException(threadMock, throwableMock) @@ -80,7 +80,7 @@ class UncaughtExceptionHandlerIntegrationTest { assertTrue(e.exceptionMechanism.isHandled) SentryId.EMPTY_ID } - val options = SentryOptions().NoFlushTimeout() + val options = SentryOptions().noFlushTimeout() val sut = UncaughtExceptionHandlerIntegration(handlerMock) sut.register(hubMock, options) sut.uncaughtException(threadMock, throwableMock) diff --git a/sentry-core/src/test/java/io/sentry/core/util/Extensions.kt b/sentry-core/src/test/java/io/sentry/core/util/Extensions.kt index b4c050206..b4391c4d8 100644 --- a/sentry-core/src/test/java/io/sentry/core/util/Extensions.kt +++ b/sentry-core/src/test/java/io/sentry/core/util/Extensions.kt @@ -2,7 +2,7 @@ package io.sentry.core.util import io.sentry.core.SentryOptions -fun SentryOptions.NoFlushTimeout(): SentryOptions { +fun SentryOptions.noFlushTimeout(): SentryOptions { return this.apply { flushTimeoutMillis = 0L }