Skip to content

Commit

Permalink
Merge pull request #93 from Banno/agp-4.2
Browse files Browse the repository at this point in the history
Update to AGP 4.2.0
  • Loading branch information
joshschriever authored May 6, 2021
2 parents f6e1a2e + 04334f3 commit 2483292
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 37 deletions.
22 changes: 6 additions & 16 deletions gordon-plugin/src/main/kotlin/com/banno/gordon/GordonPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@ package com.banno.gordon

import com.android.build.api.artifact.ArtifactType
import com.android.build.api.attributes.VariantAttr
import com.android.build.api.dsl.AndroidSourceSet
import com.android.build.api.dsl.BuildFeatures
import com.android.build.api.dsl.BuildType
import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.DefaultConfig
import com.android.build.api.dsl.ProductFlavor
import com.android.build.api.dsl.SigningConfig
import com.android.build.api.extension.AndroidComponentsExtension
import com.android.build.api.variant.Variant
import com.android.build.api.variant.VariantProperties
import com.android.build.api.variant.VariantBuilder
import com.android.build.gradle.AppExtension
import com.android.build.gradle.TestedExtension
import com.android.build.gradle.api.ApkVariant
Expand All @@ -25,8 +19,6 @@ import org.gradle.kotlin.dsl.getByName
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.register

private typealias GenericCommonExtension = CommonExtension<AndroidSourceSet, BuildFeatures, BuildType, DefaultConfig, ProductFlavor, SigningConfig, Variant<VariantProperties>, VariantProperties>

class GordonPlugin : Plugin<Project> {

override fun apply(project: Project) {
Expand All @@ -35,12 +27,11 @@ class GordonPlugin : Plugin<Project> {

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

val androidExtension = project.extensions.getByName<GenericCommonExtension>("android")
val componentsExtension = project.extensions.getByName<AndroidComponentsExtension<VariantBuilder, Variant>>("androidComponents")
val testedExtension = project.extensions.getByType<TestedExtension>()

androidExtension.onVariants {
androidTestProperties {
val testVariantProperties = this
componentsExtension
.androidTests { testVariantProperties ->
val variantTaskName = testVariantProperties.name
.capitalize()
.replace(Regex("AndroidTest$"), "")
Expand Down Expand Up @@ -96,7 +87,7 @@ class GordonPlugin : Plugin<Project> {
InstrumentationRunnerOptions(
testInstrumentationRunner = instrumentationRunner,
testInstrumentationRunnerArguments = testedVariant.mergedFlavor.testInstrumentationRunnerArguments,
animationsDisabled = androidExtension.testOptions.animationsDisabled
animationsDisabled = testedExtension.testOptions.animationsDisabled
)
}
this.androidInstrumentationRunnerOptions.set(instrumentationRunnerOptions)
Expand All @@ -110,7 +101,6 @@ class GordonPlugin : Plugin<Project> {
this.extensionTestInstrumentationRunner.set(gordonExtension.testInstrumentationRunner)
}
}
}
}

private fun ApplicationVariant.aabOutputFile(appProject: Project) = appProject.layout.buildDirectory.file(
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
androidGradlePluginVersion=4.1.2
aapt2Version=4.1.2-6503028
androidGradlePluginVersion=4.2.0
aapt2Version=4.2.0-7147631
kotlinVersion=1.4.31
kotlinterVersion=3.3.0
gradlePluginPublishVersion=0.12.0
Expand Down
10 changes: 5 additions & 5 deletions test_app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ plugins {
}

android {
compileSdkVersion(29)
buildToolsVersion("29.0.3")
compileSdk = 30
buildToolsVersion = "30.0.3"
defaultConfig {
minSdkVersion(21)
targetSdkVersion(29)
minSdk = 21
targetSdk = 30
applicationId = "com.banno.android.gordontest"
versionCode = 1
versionName = "1.0"
Expand All @@ -25,7 +25,7 @@ android {
buildTypes.named("debug") {
signingConfig = debugSigningConfig.get()
}
dynamicFeatures = mutableSetOf(
dynamicFeatures.add(
":test_feature"
)
}
Expand Down
10 changes: 4 additions & 6 deletions test_feature/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ plugins {
}

android {
compileSdkVersion(29)
buildToolsVersion("29.0.3")
compileSdkVersion(30)
buildToolsVersion("30.0.3")
defaultConfig {
minSdkVersion(21)
targetSdkVersion(29)
versionCode = 1
versionName = "1.0"
targetSdkVersion(30)
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}
Expand All @@ -24,6 +22,6 @@ repositories {

dependencies {
implementation(project(":test_app"))
implementation("androidx.fragment:fragment-ktx:1.3.0")
implementation("androidx.fragment:fragment-ktx:1.3.3")
androidTestImplementation("androidx.test:runner:1.3.0")
}
14 changes: 6 additions & 8 deletions test_library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@ plugins {
}

android {
compileSdkVersion(29)
buildToolsVersion("29.0.3")
compileSdk = 30
buildToolsVersion = "30.0.3"
defaultConfig {
minSdkVersion(21)
targetSdkVersion(29)
versionCode = 1
versionName = "1.0"
minSdk = 21
targetSdk = 30
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
flavorDimensions("foo")
flavorDimensions.add("foo")
productFlavors {
register("bar") {
dimension = "foo"
}
register("baz") {
dimension = "foo"
testInstrumentationRunnerArgument("notAnnotation", "org.junit.Test")
testInstrumentationRunnerArguments["notAnnotation"] = "org.junit.Test"
}
}
}
Expand Down

0 comments on commit 2483292

Please sign in to comment.