[flutter_tools] Allow providing dart-defines to Android, iOS, macOS builds (#51714)

This commit is contained in:
Jonah Williams
2020-03-05 12:38:40 -08:00
committed by GitHub
parent aed961993d
commit ee60eeea3e
46 changed files with 293 additions and 257 deletions

View File

@@ -615,6 +615,10 @@ class FlutterPlugin implements Plugin<Project> {
if (project.hasProperty('tree-shake-icons')) {
treeShakeIconsOptionsValue = project.property('tree-shake-icons').toBoolean()
}
String dartDefinesValue = null
if (project.hasProperty('dart-defines')) {
dartDefinesValue = project.property('dart-defines')
}
def targetPlatforms = getTargetPlatforms()
def addFlutterDeps = { variant ->
if (shouldSplitPerAbi()) {
@@ -652,6 +656,7 @@ class FlutterPlugin implements Plugin<Project> {
splitDebugInfo splitDebugInfoValue
treeShakeIcons treeShakeIconsOptionsValue
dartObfuscation dartObfuscationValue
dartDefines dartDefinesValue
doLast {
project.exec {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
@@ -799,6 +804,8 @@ abstract class BaseFlutterTask extends DefaultTask {
Boolean treeShakeIcons
@Optional @Input
Boolean dartObfuscation
@Optional @Input
String dartDefines
@OutputFiles
FileCollection getDependenciesFiles() {
@@ -864,6 +871,9 @@ abstract class BaseFlutterTask extends DefaultTask {
if (dartObfuscation == true) {
args "-dDartObfuscation=true"
}
if (dartDefines != null) {
args "-dDartDefines=${dartDefines}"
}
if (extraGenSnapshotOptions != null) {
args "--ExtraGenSnapshotOptions=${extraGenSnapshotOptions}"
}