|
| 1 | +import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
| 2 | +import org.gradle.api.tasks.testing.logging.TestLogEvent |
| 3 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 4 | + |
| 5 | +buildscript { |
| 6 | + repositories { |
| 7 | + google() |
| 8 | + jcenter() |
| 9 | + maven("https://oss.sonatype.org/content/repositories/snapshots") |
| 10 | + } |
| 11 | + |
| 12 | + dependencies { |
| 13 | + val latest = Artifacts.Plugin.latestStableVersion |
| 14 | + classpath("de.mannodermaus.gradle.plugins:android-junit5:$latest") |
| 15 | + } |
| 16 | +} |
| 17 | + |
| 18 | +plugins { |
| 19 | + id("com.android.library") |
| 20 | + kotlin("android") |
| 21 | +} |
| 22 | + |
| 23 | +apply { |
| 24 | + plugin("de.mannodermaus.android-junit5") |
| 25 | +} |
| 26 | + |
| 27 | +android { |
| 28 | + compileSdkVersion(Android.compileSdkVersion) |
| 29 | + |
| 30 | + dexOptions { |
| 31 | + javaMaxHeapSize = Android.javaMaxHeapSize |
| 32 | + } |
| 33 | + |
| 34 | + defaultConfig { |
| 35 | + minSdkVersion(Android.testCoreMinSdkVersion) |
| 36 | + targetSdkVersion(Android.targetSdkVersion) |
| 37 | + multiDexEnabled = true |
| 38 | + |
| 39 | + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" |
| 40 | + testInstrumentationRunnerArgument("runnerBuilder", "de.mannodermaus.junit5.AndroidJUnit5Builder") |
| 41 | + } |
| 42 | + |
| 43 | + sourceSets { |
| 44 | + getByName("main").java.srcDir("src/main/kotlin") |
| 45 | + getByName("test").java.srcDir("src/test/kotlin") |
| 46 | + getByName("androidTest").java.srcDir("src/androidTest/kotlin") |
| 47 | + } |
| 48 | + |
| 49 | + compileOptions { |
| 50 | + setSourceCompatibility(JavaVersion.VERSION_1_8) |
| 51 | + setTargetCompatibility(JavaVersion.VERSION_1_8) |
| 52 | + } |
| 53 | + |
| 54 | + lintOptions { |
| 55 | + // JUnit 4 refers to java.lang.management APIs, which are absent on Android. |
| 56 | + warning("InvalidPackage") |
| 57 | + } |
| 58 | + |
| 59 | + packagingOptions { |
| 60 | + exclude("META-INF/LICENSE.md") |
| 61 | + exclude("META-INF/LICENSE-notice.md") |
| 62 | + } |
| 63 | + |
| 64 | + testOptions { |
| 65 | + unitTests.apply { |
| 66 | + isReturnDefaultValues = true |
| 67 | + } |
| 68 | + } |
| 69 | +} |
| 70 | + |
| 71 | +tasks.withType<KotlinCompile> { |
| 72 | + kotlinOptions.jvmTarget = "1.8" |
| 73 | +} |
| 74 | + |
| 75 | +tasks.withType<Test> { |
| 76 | + failFast = true |
| 77 | + testLogging { |
| 78 | + events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED) |
| 79 | + exceptionFormat = TestExceptionFormat.FULL |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +dependencies { |
| 84 | + implementation(Libs.junit_jupiter_api) |
| 85 | + implementation(Libs.kotlin_stdlib) |
| 86 | + implementation(Libs.androidx_test_core) |
| 87 | + |
| 88 | + // This is required by the "instrumentation-runner" companion library, |
| 89 | + // since it can't provide any JUnit 5 runtime libraries itself |
| 90 | + // due to fear of prematurely incrementing the minSdkVersion requirement. |
| 91 | + runtimeOnly(Libs.junit_platform_runner) |
| 92 | + |
| 93 | + androidTestImplementation(Libs.junit_jupiter_api) |
| 94 | + androidTestImplementation(Libs.espresso_core) |
| 95 | + |
| 96 | + androidTestRuntimeOnly(project(":runner")) |
| 97 | + androidTestRuntimeOnly(Libs.junit_jupiter_engine) |
| 98 | +} |
| 99 | + |
| 100 | +// ------------------------------------------------------------------------------------------------ |
| 101 | +// Deployment Setup |
| 102 | +// |
| 103 | +// Releases are pushed to jcenter via Bintray, while snapshots are pushed to Sonatype OSS. |
| 104 | +// This section defines the necessary tasks to push new releases and snapshots using Gradle tasks. |
| 105 | +// ------------------------------------------------------------------------------------------------ |
| 106 | + |
| 107 | +val deployConfig by extra<Deployed> { Artifacts.Instrumentation.Core } |
| 108 | +apply(from = "$rootDir/gradle/deployment.gradle") |
0 commit comments