|
| 1 | +import io.gitlab.arturbosch.detekt.Detekt |
| 2 | +import io.gitlab.arturbosch.detekt.extensions.DetektExtension |
| 3 | +import net.ltgt.gradle.errorprone.errorprone |
| 4 | + |
| 5 | +plugins { |
| 6 | + id("com.android.application") |
| 7 | + kotlin("android") |
| 8 | + id(Config.QualityPlugins.errorProne) |
| 9 | + id(Config.QualityPlugins.gradleVersions) |
| 10 | + id(Config.QualityPlugins.detektPlugin) |
| 11 | +} |
| 12 | + |
| 13 | +android { |
| 14 | + compileSdk = Config.Android.compileSdkVersion |
| 15 | + |
| 16 | + defaultConfig { |
| 17 | + applicationId = "io.sentry.uitest.android.benchmark" |
| 18 | + minSdk = Config.Android.minSdkVersionNdk |
| 19 | + targetSdk = Config.Android.targetSdkVersion |
| 20 | + versionCode = 1 |
| 21 | + versionName = "1.0.0" |
| 22 | + |
| 23 | + testInstrumentationRunner = Config.TestLibs.androidJUnitRunner |
| 24 | + // Runs each test in its own instance of Instrumentation. This way they are isolated from |
| 25 | + // one another and get their own Application instance. |
| 26 | + // https://developer.android.com/training/testing/instrumented-tests/androidx-test-libraries/runner#enable-gradle |
| 27 | + // This doesn't work on some devices with Android 11+. Clearing package data resets permissions. |
| 28 | + // Check the readme for more info. |
| 29 | +// testInstrumentationRunnerArguments["clearPackageData"] = "true" |
| 30 | + } |
| 31 | + |
| 32 | + buildFeatures { |
| 33 | + // Determines whether to support View Binding. |
| 34 | + // Note that the viewBinding.enabled property is now deprecated. |
| 35 | + viewBinding = true |
| 36 | + } |
| 37 | + |
| 38 | + testOptions { |
| 39 | + execution = "ANDROIDX_TEST_ORCHESTRATOR" |
| 40 | + } |
| 41 | + |
| 42 | + signingConfigs { |
| 43 | + getByName("debug") { |
| 44 | + storeFile = rootProject.file("debug.keystore") |
| 45 | + storePassword = "android" |
| 46 | + keyAlias = "androiddebugkey" |
| 47 | + keyPassword = "android" |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + testBuildType = System.getProperty("testBuildType", "debug") |
| 52 | + |
| 53 | + buildTypes { |
| 54 | + getByName("debug") { |
| 55 | + isDebuggable = false |
| 56 | + isMinifyEnabled = true |
| 57 | + signingConfig = signingConfigs.getByName("debug") |
| 58 | + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "benchmark-proguard-rules.pro") |
| 59 | + } |
| 60 | + getByName("release") { |
| 61 | + isMinifyEnabled = true |
| 62 | + isShrinkResources = true |
| 63 | + signingConfig = signingConfigs.getByName("debug") // to be able to run release mode |
| 64 | + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "benchmark-proguard-rules.pro") |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + kotlinOptions { |
| 69 | + jvmTarget = JavaVersion.VERSION_1_8.toString() |
| 70 | + } |
| 71 | + |
| 72 | + lint { |
| 73 | + warningsAsErrors = true |
| 74 | + checkDependencies = true |
| 75 | + |
| 76 | + // We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks. |
| 77 | + checkReleaseBuilds = false |
| 78 | + } |
| 79 | + |
| 80 | + variantFilter { |
| 81 | + if (Config.Android.shouldSkipDebugVariant(buildType.name)) { |
| 82 | + ignore = true |
| 83 | + } |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +dependencies { |
| 88 | + |
| 89 | + implementation(kotlin(Config.kotlinStdLib, org.jetbrains.kotlin.config.KotlinCompilerVersion.VERSION)) |
| 90 | + |
| 91 | + implementation(projects.sentryAndroidIntegrationTests.sentryUitestAndroid) |
| 92 | + implementation(projects.sentryAndroid) |
| 93 | + implementation(Config.Libs.appCompat) |
| 94 | + implementation(Config.Libs.androidxCore) |
| 95 | + implementation(Config.Libs.androidxRecylerView) |
| 96 | + implementation(Config.Libs.constraintLayout) |
| 97 | + implementation(Config.TestLibs.espressoIdlingResource) |
| 98 | + |
| 99 | + compileOnly(Config.CompileOnly.nopen) |
| 100 | + errorprone(Config.CompileOnly.nopenChecker) |
| 101 | + errorprone(Config.CompileOnly.errorprone) |
| 102 | + errorprone(Config.CompileOnly.errorProneNullAway) |
| 103 | + |
| 104 | + androidTestImplementation(Config.TestLibs.kotlinTestJunit) |
| 105 | + androidTestImplementation(Config.TestLibs.espressoCore) |
| 106 | + androidTestImplementation(Config.TestLibs.androidxTestCoreKtx) |
| 107 | + androidTestImplementation(Config.TestLibs.androidxRunner) |
| 108 | + androidTestImplementation(Config.TestLibs.androidxTestRules) |
| 109 | + androidTestImplementation(Config.TestLibs.androidxJunit) |
| 110 | + androidTestUtil(Config.TestLibs.androidxTestOrchestrator) |
| 111 | +} |
| 112 | + |
| 113 | +tasks.withType<JavaCompile>().configureEach { |
| 114 | + options.errorprone { |
| 115 | + check("NullAway", net.ltgt.gradle.errorprone.CheckSeverity.ERROR) |
| 116 | + option("NullAway:AnnotatedPackages", "io.sentry") |
| 117 | + option("NullAway:UnannotatedSubPackages", "io.sentry.uitest.android.benchmark.databinding") |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +tasks.withType<Detekt> { |
| 122 | + // Target version of the generated JVM bytecode. It is used for type resolution. |
| 123 | + jvmTarget = JavaVersion.VERSION_1_8.toString() |
| 124 | +} |
| 125 | + |
| 126 | +configure<DetektExtension> { |
| 127 | + buildUponDefaultConfig = true |
| 128 | + allRules = true |
| 129 | +} |
| 130 | + |
| 131 | +kotlin { |
| 132 | + explicitApi() |
| 133 | +} |
0 commit comments