Skip to content

Commit

Permalink
Merge pull request #3 from Banno/deprecation
Browse files Browse the repository at this point in the history
Updates to remove deprecation warnings
  • Loading branch information
joshschriever authored Nov 5, 2019
2 parents 39788a6 + 45eb00e commit fa17770
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.banno.android.gordontest

import junit.framework.Assert.fail
import org.junit.Assert.fail
import org.junit.Test

class FailingTest {
@Test fun failure1() = fail()
@Test fun failure2() = fail()
@Test fun failure3() = fail()
}
}
19 changes: 12 additions & 7 deletions gordon-plugin/src/main/kotlin/com/banno/gordon/GordonPlugin.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.banno.gordon

import com.android.build.VariantOutput
import com.android.build.gradle.TestedExtension
import com.android.build.gradle.api.ApkVariant
import org.gradle.api.Plugin
Expand All @@ -9,6 +8,7 @@ import org.gradle.api.plugins.JavaBasePlugin.VERIFICATION_GROUP
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.register
import java.io.File

class GordonPlugin : Plugin<Project> {

Expand Down Expand Up @@ -47,17 +47,22 @@ class GordonPlugin : Plugin<Project> {

dependsOn(testVariant.assembleProvider, testedVariant.assembleProvider)

this.instrumentationApk.apply { set(instrumentationApk) }.finalizeValue()
this.applicationApk.apply { set(applicationApk) }.finalizeValue()
this.instrumentationApk.apply { set(project.layout.file(instrumentationApk)) }.finalizeValue()
this.applicationApk.apply { set(project.layout.file(applicationApk)) }.finalizeValue()
this.instrumentationRunnerOptions.apply { set(instrumentationRunnerOptions) }.finalizeValue()
}
}
}

private fun ApkVariant.requireMainApkOutputFile() = outputs
.singleOrNull { it.outputType == VariantOutput.MAIN || it.name.startsWith("universal-") }
?.outputFile
?: throw IllegalStateException("Gordon cannot be used without enabling universalApk in your abi splits")
private fun ApkVariant.requireMainApkOutputFile() = packageApplicationProvider.map { packageAppTask ->
val apkNames = packageAppTask.apkNames

val apkName = apkNames.singleOrNull()
?: apkNames.singleOrNull { it.contains("universal-") }
?: throw IllegalStateException("Gordon cannot be used without enabling universalApk in your abi splits")

File(packageAppTask.outputDirectory, apkName)
}

object NoTestInstrumentationRunnerException : IllegalStateException(
"Gordon cannot be used without a testInstrumentationRunner, such as `androidx.test.runner.AndroidJUnitRunner`"
Expand Down

0 comments on commit fa17770

Please sign in to comment.