Refactor baseline profiles generation and regenerate (#3434)
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import com.android.build.api.dsl.ManagedVirtualDevice
|
||||
|
||||
plugins {
|
||||
alias(mihonx.plugins.android.test)
|
||||
alias(libs.plugins.androidx.baselineProfile)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "mihon.baselineprofile"
|
||||
|
||||
defaultConfig {
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
targetProjectPath = ":app"
|
||||
|
||||
// This code creates the gradle managed device used to generate baseline profiles.
|
||||
// To use GMD please invoke generation through the command line:
|
||||
// ./gradlew :app:generateBaselineProfile
|
||||
testOptions.managedDevices.allDevices {
|
||||
@Suppress("UnstableApiUsage")
|
||||
create<ManagedVirtualDevice>("pixel6Api34") {
|
||||
device = "Pixel 6"
|
||||
apiLevel = 34
|
||||
systemImageSource = "google"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is the configuration block for the Baseline Profile plugin.
|
||||
// You can specify to run the generators on a managed devices or connected devices.
|
||||
baselineProfile {
|
||||
managedDevices += "pixel6Api34"
|
||||
useConnectedDevices = false
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.benchmark.macroJunit4)
|
||||
implementation(libs.androidx.test.junit)
|
||||
implementation(libs.androidx.test.espresso.core)
|
||||
implementation(libs.androidx.test.uiautomator)
|
||||
}
|
||||
|
||||
androidComponents {
|
||||
onVariants { variant ->
|
||||
val artifactsLoader = variant.artifacts.getBuiltArtifactsLoader()
|
||||
val applicationId = variant.testedApks.map { artifactsLoader.load(it)?.applicationId }
|
||||
variant.instrumentationRunnerArguments.put("targetAppId", applicationId)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user