File tree Expand file tree Collapse file tree
java/dagger/hilt/android/plugin/main/src/main/kotlin/dagger/hilt/android/plugin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -402,18 +402,25 @@ class HiltGradlePlugin @Inject constructor(private val providers: ProviderFactor
402402 }
403403
404404 androidExtension.onAllVariants { variant, _ ->
405- // Error if the user is trying to set the fastInit flag via build file.
406- if (
407- variant.javaCompilation
408- ?.annotationProcessor
409- ?.arguments
410- ?.get()
411- ?.containsKey(" dagger.fastInit" ) ? : false
412- ) {
413- error(
414- " [Hilt]: The flag 'dagger.fastInit' can only be set via command line. i.e. " +
415- " add '-Pdagger.fastInit=enabled' to your command line."
416- )
405+ val processorArgs =
406+ variant.javaCompilation?.annotationProcessor?.arguments?.get() ? : emptyMap()
407+ // Error if the user is trying to set plugin controlled properties via build file.
408+ processorArgs.keys.forEach { arg ->
409+ when (arg) {
410+ " dagger.hilt.fastInit" ->
411+ error(
412+ " [Hilt]: The flag 'dagger.hilt.fastInit' can only be set via command line. i.e. " +
413+ " add '-Pdagger.hilt.fastInit=enabled' to your command line."
414+ )
415+ " dagger.hilt.android.internal.disableAndroidSuperclassValidation" ,
416+ " dagger.hilt.android.internal.projectType" ,
417+ " dagger.hilt.internal.useAggregatingRootProcessor" ,
418+ " dagger.hilt.disableCrossCompilationRootValidation" ->
419+ error(
420+ " [Hilt]: The flag '$arg ' cannot be set via annotation processor options because " +
421+ " it is controlled by the Hilt plugin."
422+ )
423+ }
417424 }
418425 // Pass annotation processor flags via a CommandLineArgumentProvider so that plugin
419426 // options defined in the extension are populated from the user's build file.
You can’t perform that action at this time.
0 commit comments