Skip to content

Instantly share code, notes, and snippets.

@LizzieStudeneer
Created September 9, 2019 08:34
Show Gist options
  • Save LizzieStudeneer/0d03b6cbcd67e2a3d6c3361a4367ab5d to your computer and use it in GitHub Desktop.
Save LizzieStudeneer/0d03b6cbcd67e2a3d6c3361a4367ab5d to your computer and use it in GitHub Desktop.
// BluesquarePlugin.kt
open class BluesquarePlugin : Plugin<Project> {
override fun apply(project: Project) {
project.configureAndroid()
project.configureDependencies()
}
}
// Dependencies.kt
const val jUnit = "junit:junit:4.12"
const val androidTestRunner = "com.android.support.test:runner:1.0.2"
const val androidTestRules = "com.android.support.test:rules:1.0.2"
const val mockkAndroid = "io.mockk:mockk-android:1.9"
const val mockk = "io.mockk:mockk:1.9"
const val espressoCore = "com.android.support.test.espresso:espresso-core:3.0.2"
internal fun Project.configureDependencies() = dependencies {
add("testImplementation", jUnit)
if (project.containsAndroidPlugin()) {
add("androidTestImplementation", androidTestRunner)
add("androidTestImplementation", androidTestRules)
add("androidTestImplementation", espressoCore)
}
}
internal fun Project.containsAndroidPlugin(): Boolean {
return project.plugins.toList().any { plugin -> plugin is AndroidBasePlugin }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment