Skip to content

Commit

Permalink
Enforce minimum supported AGP version.
Browse files Browse the repository at this point in the history
Support for AGP 4.2 was dropped in 74ea765 due to tools upgrade, this change will now enforce the usage of AGP 7.0+ (the minimum supported) and also removes the pre-7.0 code path and classes.

RELNOTES=The Hilt Android Gradle plugin will now enforce minimum Android Gradle plugin (AGP) version of 7.0.
PiperOrigin-RevId: 544069911
  • Loading branch information
danysantiago authored and Dagger Team committed Jun 28, 2023
1 parent e25c930 commit e512d87
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 732 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class AndroidComponentsExtensionCompatApi70Impl(
private val project: Project
) : AndroidComponentsExtensionCompat {

@Suppress("UnstableApiUsage")
override fun onAllVariants(block: (ComponentCompat) -> Unit) {
val actual = project.extensions.getByType(AndroidComponentsExtension::class.java)
actual.onVariants { variant ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class ComponentCompatApi70Impl(private val component: Component) : Comp
override val name: String
get() = component.name

@Suppress("UnstableApiUsage")
@Suppress("UnstableApiUsage") // Due to ASM pipeline APIs
override fun <ParamT : InstrumentationParameters> transformClassesWith(
classVisitorFactoryImplClass: Class<out AsmClassVisitorFactory<ParamT>>,
scope: InstrumentationScope,
Expand All @@ -36,6 +36,7 @@ internal class ComponentCompatApi70Impl(private val component: Component) : Comp
component.transformClassesWith(classVisitorFactoryImplClass, scope, instrumentationParamsConfig)
}

@Suppress("UnstableApiUsage") // Due to ASM pipeline APIs
override fun setAsmFramesComputationMode(mode: FramesComputationMode) {
component.setAsmFramesComputationMode(mode)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ internal class ComponentCompatApi71Impl(private val component: Component) : Comp
override val name: String
get() = component.name

@Suppress("UnstableApiUsage")
override fun <ParamT : InstrumentationParameters> transformClassesWith(
classVisitorFactoryImplClass: Class<out AsmClassVisitorFactory<ParamT>>,
scope: InstrumentationScope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ internal class ComponentCompatApi72Impl(private val component: Component) : Comp
override val name: String
get() = component.name

@Suppress("UnstableApiUsage")
override fun <ParamT : InstrumentationParameters> transformClassesWith(
classVisitorFactoryImplClass: Class<out AsmClassVisitorFactory<ParamT>>,
scope: InstrumentationScope,
Expand All @@ -40,7 +39,6 @@ internal class ComponentCompatApi72Impl(private val component: Component) : Comp
)
}

@Suppress("UnstableApiUsage")
override fun setAsmFramesComputationMode(mode: FramesComputationMode) {
component.instrumentation.setAsmFramesComputationMode(mode)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ data class SimpleAGPVersion(
val minor: Int,
) : Comparable<SimpleAGPVersion> {

override fun toString(): String {
return "$major.$minor"
}

override fun compareTo(other: SimpleAGPVersion): Int {
return compareValuesBy(
this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import com.android.build.api.instrumentation.InstrumentationScope
* - In AGP 4.2 its package is 'com.android.build.api.component'
* - In AGP 7.0 its packages is 'com.android.build.api.variant'
*/
@Suppress("UnstableApiUsage") // ASM Pipeline APIs
abstract class ComponentCompat {

/** Redeclaration of [com.android.build.api.variant.ComponentIdentity.name] */
Expand Down
2 changes: 1 addition & 1 deletion java/dagger/hilt/android/plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
kotlin_version = "1.8.0"
kotlin_version = "1.8.20"
agp_version = System.getenv('AGP_VERSION') ?: "7.2.0"
pluginArtifactId = 'hilt-android-gradle-plugin'
pluginId = 'com.google.dagger.hilt.android'
Expand Down
12 changes: 5 additions & 7 deletions java/dagger/hilt/android/plugin/main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ dependencies {
implementation gradleApi()
compileOnly "com.android.tools.build:gradle:$agp_version"
compileOnly "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
implementation 'org.javassist:javassist:3.26.0-GA'
implementation 'org.ow2.asm:asm:9.0'
implementation "com.squareup:javapoet:1.13.0"

testImplementation gradleTestKit()
testImplementation 'junit:junit:4.12'
testImplementation 'com.google.truth:truth:1.0.1'
testImplementation 'org.javassist:javassist:3.26.0-GA'
testPluginCompile 'com.android.tools.build:gradle:7.1.2'
testPluginCompile 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0'
}
Expand All @@ -83,18 +83,16 @@ tasks.withType(PluginUnderTestMetadata.class).named("pluginUnderTestMetadata").c
it.pluginClasspath.from(configurations.testPluginCompile)
}

kotlin {
jvmToolchain(11)
}

compileKotlin {
kotlinOptions {
jvmTarget = '11'
allWarningsAsErrors = true
}
}

java {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}

// Imports a shared library from the main project. The library and its classes
// will be shadowed in the plugin's artifact.
tasks.register("importSharedLib").configure {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ class AndroidEntryPointClassVisitor(
private val additionalClasses: File
) : ClassVisitor(apiVersion, nextClassVisitor) {

@Suppress("UnstableApiUsage") // ASM Pipeline APIs
interface AndroidEntryPointParams : InstrumentationParameters {
@get:Internal
val additionalClassesDir: Property<File>
}

@Suppress("UnstableApiUsage") // ASM Pipeline APIs
abstract class Factory : AsmClassVisitorFactory<AndroidEntryPointParams> {
override fun createClassVisitor(
classContext: ClassContext,
Expand Down
Loading

0 comments on commit e512d87

Please sign in to comment.