Skip to content

Commit

Permalink
pass extension properties in configuration done by plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
joshschriever committed Aug 13, 2020
1 parent a6c67e7 commit f2abf7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
12 changes: 11 additions & 1 deletion gordon-plugin/src/main/kotlin/com/banno/gordon/GordonPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GordonPlugin : Plugin<Project> {
val androidPluginType = project.androidPluginType()
?: error("Gordon plugin must be applied after applying the application, library, or dynamic-feature Android plugin")

project.extensions.create<GordonExtension>("gordon")
val gordonExtension = project.extensions.create<GordonExtension>("gordon")

val androidExtension = project.extensions.getByType<TestedExtension>()

Expand Down Expand Up @@ -82,6 +82,16 @@ class GordonPlugin : Plugin<Project> {

this.instrumentationApk.apply { set(testVariant.apkOutputFile()) }.finalizeValue()
this.instrumentationPackage.apply { set(testVariant.applicationId) }.finalizeValue()

this.poolingStrategy.apply { set(gordonExtension.poolingStrategy) }.finalizeValue()
this.tabletShortestWidthDp.apply { set(gordonExtension.tabletShortestWidthDp) }.finalizeValue()
this.retryQuota.apply { set(gordonExtension.retryQuota) }.finalizeValue()
this.installTimeoutMillis.apply { set(gordonExtension.installTimeoutMillis) }.finalizeValue()
this.testTimeoutMillis.apply { set(gordonExtension.testTimeoutMillis) }.finalizeValue()
this.extensionTestFilter.apply { set(gordonExtension.testFilter) }.finalizeValue()
this.extensionTestInstrumentationRunner.apply { set(gordonExtension.testInstrumentationRunner) }
.finalizeValue()

this.androidInstrumentationRunnerOptions.apply { set(instrumentationRunnerOptions) }.finalizeValue()
}
}
Expand Down
19 changes: 8 additions & 11 deletions gordon-plugin/src/main/kotlin/com/banno/gordon/GordonTestTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.options.Option
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.property
import se.vidstige.jadb.JadbConnection
import java.io.File
Expand Down Expand Up @@ -73,25 +72,23 @@ internal abstract class GordonTestTask @Inject constructor(
.map { it.replace('#', '.') }

@get:Input
internal val poolingStrategy = project.extensions.getByType<GordonExtension>().poolingStrategy
internal val poolingStrategy: Property<PoolingStrategy> = objects.property()

@get:Input
internal val tabletShortestWidthDp = project.extensions.getByType<GordonExtension>().tabletShortestWidthDp
internal val tabletShortestWidthDp: Property<Int> = objects.property()

private val retryQuota = project.extensions.getByType<GordonExtension>().retryQuota
private val installTimeoutMillis = project.extensions.getByType<GordonExtension>().installTimeoutMillis
private val testTimeoutMillis = project.extensions.getByType<GordonExtension>().testTimeoutMillis
internal val retryQuota: Property<Int> = objects.property()
internal val installTimeoutMillis: Property<Long> = objects.property()
internal val testTimeoutMillis: Property<Long> = objects.property()

internal val extensionTestFilter: Property<String> = objects.property()
internal val extensionTestInstrumentationRunner: Property<String> = objects.property()

@Option(option = "tests", description = "Comma-separated packages, classes, methods, or annotations.")
val commandlineTestFilter: Property<String> = objects.property()

private val extensionTestFilter = project.extensions.getByType<GordonExtension>().testFilter

internal val androidInstrumentationRunnerOptions: Property<InstrumentationRunnerOptions> = objects.property()

private val extensionTestInstrumentationRunner =
project.extensions.getByType<GordonExtension>().testInstrumentationRunner

@OutputDirectory
val testResultsDirectory: Provider<Directory> = projectLayout.buildDirectory.dir("test-results/$name")

Expand Down

0 comments on commit f2abf7a

Please sign in to comment.