mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 00:07:05 +05:30
build-logic: make android-common a separate plugin and support com.android.test
This commit is contained in:
parent
504cdfe78a
commit
4d6b97adaf
4 changed files with 28 additions and 6 deletions
|
@ -30,6 +30,10 @@ gradlePlugin {
|
|||
id = "dev.msfjarvis.claw.android-application"
|
||||
implementationClass = "dev.msfjarvis.aps.gradle.ApplicationPlugin"
|
||||
}
|
||||
register("android-common") {
|
||||
id = "dev.msfjarvis.claw.android-common"
|
||||
implementationClass = "dev.msfjarvis.aps.gradle.AndroidCommonPlugin"
|
||||
}
|
||||
register("android-library") {
|
||||
id = "dev.msfjarvis.claw.android-library"
|
||||
implementationClass = "dev.msfjarvis.aps.gradle.LibraryPlugin"
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
package dev.msfjarvis.aps.gradle
|
||||
|
||||
import com.android.build.api.dsl.TestExtension
|
||||
import com.android.build.gradle.TestedExtension
|
||||
import org.gradle.api.JavaVersion
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.configure
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
|
||||
@Suppress("UnstableApiUsage")
|
||||
object AndroidCommon {
|
||||
fun configure(project: Project) {
|
||||
project.extensions.configure<TestedExtension> {
|
||||
class AndroidCommonPlugin : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
project.extensions.findByType<TestedExtension>()?.run {
|
||||
setCompileSdkVersion(31)
|
||||
defaultConfig {
|
||||
minSdk = 26
|
||||
|
@ -35,6 +37,22 @@ object AndroidCommon {
|
|||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
testOptions {
|
||||
animationsDisabled = true
|
||||
unitTests.isReturnDefaultValues = true
|
||||
}
|
||||
}
|
||||
project.extensions.findByType<TestExtension>()?.run {
|
||||
compileSdk = 31
|
||||
defaultConfig {
|
||||
minSdk = 26
|
||||
targetSdk = 31
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
testOptions {
|
||||
animationsDisabled = true
|
||||
unitTests.isReturnDefaultValues = true
|
|
@ -15,7 +15,7 @@ class ApplicationPlugin : Plugin<Project> {
|
|||
|
||||
override fun apply(project: Project) {
|
||||
project.pluginManager.apply(AppPlugin::class)
|
||||
AndroidCommon.configure(project)
|
||||
project.pluginManager.apply(AndroidCommonPlugin::class)
|
||||
project.extensions.getByType<BaseAppModuleExtension>().run {
|
||||
adbOptions.installOptions("--user 0")
|
||||
|
||||
|
|
|
@ -10,6 +10,6 @@ class LibraryPlugin : Plugin<Project> {
|
|||
|
||||
override fun apply(project: Project) {
|
||||
project.pluginManager.apply(LibraryPlugin::class)
|
||||
AndroidCommon.configure(project)
|
||||
project.pluginManager.apply(AndroidCommonPlugin::class)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue