7
7
8
8
package com.facebook.react
9
9
10
- import com.android.build.gradle.api.BaseVariant
11
10
import com.facebook.react.utils.projectPathToLibraryName
12
- import java.io.File
13
11
import javax.inject.Inject
14
12
import org.gradle.api.Project
15
13
import org.gradle.api.file.DirectoryProperty
16
14
import org.gradle.api.file.RegularFileProperty
17
15
import org.gradle.api.provider.ListProperty
18
- import org.gradle.api.provider.MapProperty
19
16
import org.gradle.api.provider.Property
20
17
21
18
abstract class ReactExtension @Inject constructor(project : Project ) {
@@ -54,10 +51,10 @@ abstract class ReactExtension @Inject constructor(project: Project) {
54
51
val bundleCommand: Property <String > = objects.property(String ::class .java).convention(" bundle" )
55
52
56
53
/* *
57
- * Custom configuration for the [bundleCommand]. If provided it will be passed over with a
54
+ * Custom configuration file for the [bundleCommand]. If provided, it will be passed over with a
58
55
* `--config` flag to the bundle command.
59
56
*/
60
- val bundleConfig: Property < String > = objects.property( String :: class .java )
57
+ val bundleConfig: RegularFileProperty = objects.fileProperty( )
61
58
62
59
/* *
63
60
* The Bundle Asset name. This name will be used also for deriving other bundle outputs such as
@@ -69,69 +66,24 @@ abstract class ReactExtension @Inject constructor(project: Project) {
69
66
objects.property(String ::class .java).convention(" index.android.bundle" )
70
67
71
68
/* *
72
- * Variant Name to File destination map that allows to specify where is the resource dir for a
73
- * specific variant. If a value is supplied, the plugin will copy the bundled resource for that
74
- * variant from `generated/res/react/<variant>` into the custom specified location. Default: {}
69
+ * Toggles the .so Cleanup step. If enabled, we will clean up all the unnecessary files before the
70
+ * bundle task. If disabled, the developers will have to manually cleanup the files. Default: true
75
71
*/
76
- val resourcesDir: MapProperty <String , File > =
77
- objects.mapProperty(String ::class .java, File ::class .java).convention(emptyMap())
78
-
79
- /* *
80
- * Variant Name to File destination map that allows to specify where is the asset dir for a
81
- * specific variant. If a value is supplied, the plugin will copy the bundled JS for that variant
82
- * from `generated/assets/react/<variant>` into the custom specified location. Default: {}
83
- */
84
- val jsBundleDir: MapProperty <String , File > =
85
- objects.mapProperty(String ::class .java, File ::class .java).convention(emptyMap())
86
-
87
- /* * ANT-style excludes for the bundle command. Default: ["android / **", "ios / **"] */
88
- val inputExcludes: ListProperty <String > =
89
- objects.listProperty(String ::class .java).convention(listOf (" android/**" , " ios/**" ))
90
-
91
- /* *
92
- * Toggles the VM Cleanup step. If enabled, before the bundle task we will clean up all the
93
- * unnecessary files. If disabled, the developers will have to manually cleanup the files.
94
- * Default: true
95
- */
96
- val enableVmCleanup: Property <Boolean > = objects.property(Boolean ::class .java).convention(true )
72
+ val enableSoCleanup: Property <Boolean > = objects.property(Boolean ::class .java).convention(true )
97
73
98
74
/* * Extra args that will be passed to the [bundleCommand] Default: [] */
99
75
val extraPackagerArgs: ListProperty <String > =
100
76
objects.listProperty(String ::class .java).convention(emptyList())
101
77
102
78
/* *
103
- * Allows to disable dev mode for certain variants. That's useful if you have a production variant
104
- * (say `canary`) where you don't want dev mode to be enabled. Default: []
105
- */
106
- val devDisabledInVariants: ListProperty <String > =
107
- objects.listProperty(String ::class .java).convention(emptyList())
108
-
109
- /* *
110
- * Functional interface to disable dev mode only on specific [BaseVariant] Default: will check
111
- * [devDisabledInVariants] or return True for Release variants and False for Debug variants.
112
- */
113
- var disableDevForVariant: (BaseVariant ) -> Boolean = { variant ->
114
- variant.name in devDisabledInVariants.get() || variant.isRelease
115
- }
116
-
117
- /* *
118
- * Variant Name to Boolean map that allows to toggle the bundle command for a specific variant.
119
- * Default: {}
120
- */
121
- // todo maybe lambda as for hermes?
122
- val bundleIn: MapProperty <String , Boolean > =
123
- objects.mapProperty(String ::class .java, Boolean ::class .java).convention(emptyMap())
124
-
125
- /* *
126
- * Functional interface to toggle the bundle command only on specific [BaseVariant] Default: will
127
- * check [bundleIn] or return True for Release variants and False for Debug variants.
79
+ * Allows to specify the debuggable variants (by default just 'debug'). Variants in this list
80
+ * will:
81
+ * - Not be bundled (the bundle file will not be created and won't be copied over).
82
+ * - Have the Hermes Debug flags set. That's useful if you have another variant (say `canary`)
83
+ * where you want dev mode to be enabled. Default: ['debug']
128
84
*/
129
- var bundleForVariant: (BaseVariant ) -> Boolean = { variant ->
130
- if (bundleIn.getting(variant.name).isPresent) bundleIn.getting(variant.name).get()
131
- else if (bundleIn.getting(variant.buildType.name).isPresent)
132
- bundleIn.getting(variant.buildType.name).get()
133
- else variant.isRelease
134
- }
85
+ val debuggableVariants: ListProperty <String > =
86
+ objects.listProperty(String ::class .java).convention(listOf (" debug" ))
135
87
136
88
/* * Hermes Config */
137
89
@@ -141,35 +93,18 @@ abstract class ReactExtension @Inject constructor(project: Project) {
141
93
*/
142
94
val hermesCommand: Property <String > = objects.property(String ::class .java).convention(" " )
143
95
144
- /* * Toggle Hermes for the whole build. Default: false */
145
- val enableHermes: Property <Boolean > = objects.property(Boolean ::class .java).convention(false )
146
-
147
96
/* *
148
- * Functional interface to selectively enabled Hermes only on specific [BaseVariant] Default: will
149
- * return [enableHermes] for all the variants.
150
- */
151
- var enableHermesForVariant: (BaseVariant ) -> Boolean = { enableHermes.get() }
152
-
153
- /* *
154
- * Functional interface specify flags for Hermes on specific [BaseVariant] Default: will return
155
- * [hermesFlagsRelease] for Release variants and [hermesFlagsDebug] for Debug variants.
156
- */
157
- var hermesFlagsForVariant: (BaseVariant ) -> List <String > = { variant ->
158
- if (variant.isRelease) hermesFlagsRelease.get() else hermesFlagsDebug.get()
159
- }
160
-
161
- /* *
162
- * Functional interface to delete debug files only on specific [BaseVariant] Default: will return
163
- * True for Release variants and False for Debug variants.
97
+ * Whether to enable Hermes only on certain variants. If specified as a non-empty list, hermesc
98
+ * and the .so cleanup for Hermes will be executed only for variants in this list. An empty list
99
+ * assumes you're either using Hermes for all variants or not (see [enableHermes]).
100
+ *
101
+ * Default: []
164
102
*/
165
- var deleteDebugFilesForVariant: (BaseVariant ) -> Boolean = { variant -> variant.isRelease }
166
-
167
- /* * Flags to pass to Hermes for Debug variants. Default: [] */
168
- val hermesFlagsDebug: ListProperty <String > =
103
+ val enableHermesOnlyInVariants: ListProperty <String > =
169
104
objects.listProperty(String ::class .java).convention(emptyList())
170
105
171
- /* * Flags to pass to Hermes for Release variants . Default: ["-O", "-output-source-map"] */
172
- val hermesFlagsRelease : ListProperty <String > =
106
+ /* * Flags to pass to Hermesc . Default: ["-O", "-output-source-map"] */
107
+ val hermesFlags : ListProperty <String > =
173
108
objects.listProperty(String ::class .java).convention(listOf (" -O" , " -output-source-map" ))
174
109
175
110
/* *
0 commit comments