Configure android extensions in BasePlugin types

Follow up #2903
This commit is contained in:
Goooler
2022-09-18 02:48:38 +08:00
parent 7c948369b9
commit 6757e78cbd

View File

@@ -1,3 +1,4 @@
import com.android.build.gradle.BasePlugin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
@@ -13,11 +14,36 @@ plugins {
}
allprojects {
plugins.withId("com.android.library") {
setupAndroid(project)
}
plugins.withId("com.android.application") {
setupAndroid(project)
plugins.withType(BasePlugin).configureEach {
project.android {
compileSdk 33
defaultConfig {
minSdk 26
targetSdk 32
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lint {
abortOnError true
checkReleaseBuilds false
}
}
project.dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'org.mockito:mockito-core:4.6.1'
androidTestImplementation 'com.google.dexmaker:dexmaker:1.2'
androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
androidTestImplementation "androidx.annotation:annotation:1.4.0"
}
}
tasks.withType(KotlinCompile).configureEach {
@@ -404,35 +430,3 @@ protobuf {
}
}
}
def setupAndroid(Project project) {
project.android {
compileSdk 33
defaultConfig {
minSdk 26
targetSdk 32
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lint {
abortOnError true
checkReleaseBuilds false
}
}
project.dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'org.mockito:mockito-core:4.6.1'
androidTestImplementation 'com.google.dexmaker:dexmaker:1.2'
androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
androidTestImplementation "androidx.annotation:annotation:1.4.0"
}
}