1 /*
2  * Copyright (C) 2020 The Dagger Authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package dagger.hilt.android.plugin
18 
19 /** Configuration options for the Hilt Gradle Plugin */
20 interface HiltExtension {
21 
22   /**
23    * If set to `true`, Hilt will adjust the compile classpath such that it includes transitive
24    * dependencies, ignoring `api` or `implementation` boundaries during compilation. You should
25    * enable this option if your project has multiple level of transitive dependencies that contain
26    * injected classes or entry points. The default value is `false`.
27    *
28    * This option should be enable as a last resort to avoid classpath issues if
29    * [enableAggregatingTask] (set to `true` by default) causes issues.
30    *
31    * See https://github.com/google/dagger/issues/1991 for more context.
32    */
33   var enableExperimentalClasspathAggregation: Boolean
34 
35   /**
36    * If set to `true`, Hilt will register a transform task that will rewrite `@AndroidEntryPoint`
37    * annotated classes before the host-side JVM tests run. You should enable this option if you are
38    * running Robolectric UI tests as part of your JUnit tests.
39    *
40    * This flag is not necessary when com.android.tools.build:gradle:4.2.0+ is used.
41    */
42   @Deprecated("Since Hilt Android Gradle plugin requires the usage of the Android " +
43       "Gradle plugin (AGP) version 7.0 or higher this option is no longer necessary and has no " +
44       "effect in the configuration.")
45   var enableTransformForLocalTests: Boolean
46 
47   /**
48    * If set to `true`, Hilt will perform module and entry points aggregation in a task instead of an
49    * aggregating annotation processor. Enabling this flag improves incremental build times. The
50    * default value is `true`.
51    *
52    * When this flag is enabled, 'enableExperimentalClasspathAggregation' has no effect since
53    * classpath aggregation is already performed by the aggregation task.
54    */
55   var enableAggregatingTask: Boolean
56 
57   /**
58    * If set to `true`, Hilt will disable cross compilation root validation. The default value is
59    * `false`.
60    *
61    * See [documentation](https://dagger.dev/hilt/flags#disable-cross-compilation-root-validation)
62    * for more information.
63    */
64   var disableCrossCompilationRootValidation: Boolean
65 }
66 
67 internal open class HiltExtensionImpl : HiltExtension {
68   override var enableExperimentalClasspathAggregation: Boolean = false
69   @Deprecated("Since Hilt Android Gradle plugin requires the usage of the Android " +
70       "Gradle plugin (AGP) version 7.0 or higher this option is no longer necessary and has no " +
71       "effect in the configuration.")
72   override var enableTransformForLocalTests: Boolean = false
73   override var enableAggregatingTask: Boolean = true
74   override var disableCrossCompilationRootValidation: Boolean = false
75 }
76