Correctly propagate verbosity to subtasks in flutter.gradle (#117897)
* Correctly propagate verbosity to subtasks in flutter.gradle * Add test * Revert accidental changes * Fix copyright year * Fix imports
This commit is contained in:
parent
c53501d835
commit
025ce117b7
@ -618,10 +618,7 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Boolean shouldSplitPerAbi() {
|
private Boolean shouldSplitPerAbi() {
|
||||||
if (project.hasProperty('split-per-abi')) {
|
return project.findProperty('split-per-abi')?.toBoolean() ?: false;
|
||||||
return project.property('split-per-abi').toBoolean()
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean useLocalEngine() {
|
private Boolean useLocalEngine() {
|
||||||
@ -629,18 +626,12 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Boolean isVerbose() {
|
private Boolean isVerbose() {
|
||||||
if (project.hasProperty('verbose')) {
|
return project.findProperty('verbose')?.toBoolean() ?: false;
|
||||||
return project.property('verbose').toBoolean()
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Whether to build the debug app in "fast-start" mode. */
|
/** Whether to build the debug app in "fast-start" mode. */
|
||||||
private Boolean isFastStart() {
|
private Boolean isFastStart() {
|
||||||
if (project.hasProperty("fast-start")) {
|
return project.findProperty("fast-start")?.toBoolean() ?: false;
|
||||||
return project.property("fast-start").toBoolean()
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Boolean isBuiltAsApp(Project project) {
|
private static Boolean isBuiltAsApp(Project project) {
|
||||||
@ -877,6 +868,12 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
}
|
}
|
||||||
String variantBuildMode = buildModeFor(variant.buildType)
|
String variantBuildMode = buildModeFor(variant.buildType)
|
||||||
String taskName = toCamelCase(["compile", FLUTTER_BUILD_PREFIX, variant.name])
|
String taskName = toCamelCase(["compile", FLUTTER_BUILD_PREFIX, variant.name])
|
||||||
|
// Be careful when configuring task below, Groovy has bizarre
|
||||||
|
// scoping rules: writing `verbose isVerbose()` means calling
|
||||||
|
// `isVerbose` on the task itself - which would return `verbose`
|
||||||
|
// original value. You either need to hoist the value
|
||||||
|
// into a separate variable `verbose verboseValue` or prefix with
|
||||||
|
// `this` (`verbose this.isVerbose()`).
|
||||||
FlutterTask compileTask = project.tasks.create(name: taskName, type: FlutterTask) {
|
FlutterTask compileTask = project.tasks.create(name: taskName, type: FlutterTask) {
|
||||||
flutterRoot this.flutterRoot
|
flutterRoot this.flutterRoot
|
||||||
flutterExecutable this.flutterExecutable
|
flutterExecutable this.flutterExecutable
|
||||||
@ -884,8 +881,8 @@ class FlutterPlugin implements Plugin<Project> {
|
|||||||
localEngine this.localEngine
|
localEngine this.localEngine
|
||||||
localEngineSrcPath this.localEngineSrcPath
|
localEngineSrcPath this.localEngineSrcPath
|
||||||
targetPath getFlutterTarget()
|
targetPath getFlutterTarget()
|
||||||
verbose isVerbose()
|
verbose this.isVerbose()
|
||||||
fastStart isFastStart()
|
fastStart this.isFastStart()
|
||||||
fileSystemRoots fileSystemRootsValue
|
fileSystemRoots fileSystemRootsValue
|
||||||
fileSystemScheme fileSystemSchemeValue
|
fileSystemScheme fileSystemSchemeValue
|
||||||
trackWidgetCreation trackWidgetCreationValue
|
trackWidgetCreation trackWidgetCreationValue
|
||||||
@ -1089,7 +1086,7 @@ abstract class BaseFlutterTask extends DefaultTask {
|
|||||||
Boolean fastStart
|
Boolean fastStart
|
||||||
@Input
|
@Input
|
||||||
String targetPath
|
String targetPath
|
||||||
@Optional @Internal
|
@Optional @Input
|
||||||
Boolean verbose
|
Boolean verbose
|
||||||
@Optional @Input
|
@Optional @Input
|
||||||
String[] fileSystemRoots
|
String[] fileSystemRoots
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
|
|
||||||
|
import '../src/common.dart';
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
|
// Test that verbosity it propagated to Gradle tasks correctly.
|
||||||
|
void main() {
|
||||||
|
late Directory tempDir;
|
||||||
|
late String flutterBin;
|
||||||
|
late Directory exampleAppDir;
|
||||||
|
|
||||||
|
setUp(() async {
|
||||||
|
tempDir = createResolvedTempDirectorySync('flutter_build_test.');
|
||||||
|
flutterBin = fileSystem.path.join(
|
||||||
|
getFlutterRoot(),
|
||||||
|
'bin',
|
||||||
|
'flutter',
|
||||||
|
);
|
||||||
|
exampleAppDir = tempDir.childDirectory('aaa').childDirectory('example');
|
||||||
|
|
||||||
|
processManager.runSync(<String>[
|
||||||
|
flutterBin,
|
||||||
|
...getLocalEngineArguments(),
|
||||||
|
'create',
|
||||||
|
'--template=plugin',
|
||||||
|
'--platforms=android',
|
||||||
|
'aaa',
|
||||||
|
], workingDirectory: tempDir.path);
|
||||||
|
});
|
||||||
|
|
||||||
|
tearDown(() async {
|
||||||
|
tryToDelete(tempDir);
|
||||||
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'flutter build apk -v output should contain gen_snapshot command',
|
||||||
|
() async {
|
||||||
|
final ProcessResult result = processManager.runSync(<String>[
|
||||||
|
flutterBin,
|
||||||
|
...getLocalEngineArguments(),
|
||||||
|
'build',
|
||||||
|
'apk',
|
||||||
|
'--target-platform=android-arm',
|
||||||
|
'-v',
|
||||||
|
], workingDirectory: exampleAppDir.path);
|
||||||
|
expect(
|
||||||
|
result.stdout, contains(RegExp(r'executing:\s+\S+gen_snapshot\s+')));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user