Skip to content

Commit

Permalink
Migrated mutable*Of().apply pattern to the build APIs and opt-in to t…
Browse files Browse the repository at this point in the history
…hose stdlib APIs.

Also cleanup two sets of warnings in the plugin code:
* A warning was being emitted due to the lack of usage of jvmToolchain() in the agp-* modules.
* Unused local val in IncrementalProcessorTest

RELNOTES=N/A
PiperOrigin-RevId: 544338888
  • Loading branch information
danysantiago authored and Dagger Team committed Jun 29, 2023
1 parent 843a6a2 commit ebeaaf7
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 6 deletions.
4 changes: 4 additions & 0 deletions java/dagger/hilt/android/plugin/agp-wrapper-7-0/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ plugins {
id 'org.jetbrains.kotlin.jvm'
}

kotlin {
jvmToolchain(11)
}

dependencies {
implementation project(':agp-wrapper')
compileOnly gradleApi()
Expand Down
4 changes: 4 additions & 0 deletions java/dagger/hilt/android/plugin/agp-wrapper-7-1/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ plugins {
id 'org.jetbrains.kotlin.jvm'
}

kotlin {
jvmToolchain(11)
}

dependencies {
implementation project(':agp-wrapper')
compileOnly gradleApi()
Expand Down
4 changes: 4 additions & 0 deletions java/dagger/hilt/android/plugin/agp-wrapper-7-2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ plugins {
id 'org.jetbrains.kotlin.jvm'
}

kotlin {
jvmToolchain(11)
}

dependencies {
implementation project(':agp-wrapper')
compileOnly gradleApi()
Expand Down
4 changes: 4 additions & 0 deletions java/dagger/hilt/android/plugin/agp-wrapper-impl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ plugins {
id 'org.jetbrains.kotlin.jvm'
}

kotlin {
jvmToolchain(11)
}

dependencies {
api project(':agp-wrapper')
implementation project(':agp-wrapper-7-0')
Expand Down
4 changes: 4 additions & 0 deletions java/dagger/hilt/android/plugin/agp-wrapper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ plugins {
id 'org.jetbrains.kotlin.jvm'
}

kotlin {
jvmToolchain(11)
}

dependencies {
compileOnly gradleApi()
compileOnly "com.android.tools.build:gradle:$agp_version"
Expand Down
1 change: 1 addition & 0 deletions java/dagger/hilt/android/plugin/main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ kotlin {
compileKotlin {
kotlinOptions {
allWarningsAsErrors = true
freeCompilerArgs += [ "-opt-in=kotlin.ExperimentalStdlibApi" ]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ internal class HiltCommandLineArgumentProvider(

private val prefix = if (forKsp) "" else "-A"

override fun asArguments() = mutableMapOf<String, String>().apply {
override fun asArguments() = buildMap {
// Enable Dagger's fast-init, the best mode for Hilt.
put("dagger.fastInit", "enabled")
// Disable @AndroidEntryPoint superclass validation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class HiltGradlePlugin @Inject constructor(
config.isCanBeResolved = true
// Add user annotation processor configuration, so that SPI plugins and other processors
// are discoverable.
val apConfigurations: List<Configuration> = mutableListOf<Configuration>().apply {
val apConfigurations: List<Configuration> = buildList {
add(variant.annotationProcessorConfiguration)
// TODO(danysantiago): Also add KSP config
project.configurations.findByName(getKaptConfigName(variant))?.let { add(it) }
Expand All @@ -324,7 +324,7 @@ class HiltGradlePlugin @Inject constructor(
}

fun getInputClasspath(artifactAttributeValue: String) =
mutableListOf<Configuration>().apply {
buildList<Configuration> {
@Suppress("DEPRECATION") // Older variant API is deprecated
if (variant is com.android.build.gradle.api.TestVariant) {
add(variant.testedVariant.runtimeConfiguration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ private constructor(
return object : AnnotationVisitor(asmApiVersion, nextAnnotationVisitor) {
lateinit var rootClass: String
var rootPackage: String? = null
val rootSimpleNames: MutableList<String> = mutableListOf()
val rootSimpleNames = mutableListOf<String>()
lateinit var originatingRootClass: String
var originatingRootPackage: String? = null
val originatingRootSimpleNames: MutableList<String> = mutableListOf()
val originatingRootSimpleNames = mutableListOf<String>()
lateinit var rootAnnotationClassName: Type

override fun visit(name: String, value: Any?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ class IncrementalProcessorTest(private val incapMode: String) {

// Compute directory paths
val defaultGenSrcDir = "build/generated/ap_generated_sources/debug/out/"
val testDefaultGenSrcDir = "build/generated/ap_generated_sources/debugUnitTest/out/"
fun getComponentTreeDepsGenSrcDir(variant: String) = if (incapMode == ISOLATING_MODE) {
"build/generated/hilt/component_trees/$variant/"
} else {
Expand Down

0 comments on commit ebeaaf7

Please sign in to comment.