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() {
|
||||
if (project.hasProperty('split-per-abi')) {
|
||||
return project.property('split-per-abi').toBoolean()
|
||||
}
|
||||
return false;
|
||||
return project.findProperty('split-per-abi')?.toBoolean() ?: false;
|
||||
}
|
||||
|
||||
private Boolean useLocalEngine() {
|
||||
@ -629,18 +626,12 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
}
|
||||
|
||||
private Boolean isVerbose() {
|
||||
if (project.hasProperty('verbose')) {
|
||||
return project.property('verbose').toBoolean()
|
||||
}
|
||||
return false
|
||||
return project.findProperty('verbose')?.toBoolean() ?: false;
|
||||
}
|
||||
|
||||
/** Whether to build the debug app in "fast-start" mode. */
|
||||
private Boolean isFastStart() {
|
||||
if (project.hasProperty("fast-start")) {
|
||||
return project.property("fast-start").toBoolean()
|
||||
}
|
||||
return false
|
||||
return project.findProperty("fast-start")?.toBoolean() ?: false;
|
||||
}
|
||||
|
||||
private static Boolean isBuiltAsApp(Project project) {
|
||||
@ -877,6 +868,12 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
}
|
||||
String variantBuildMode = buildModeFor(variant.buildType)
|
||||
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) {
|
||||
flutterRoot this.flutterRoot
|
||||
flutterExecutable this.flutterExecutable
|
||||
@ -884,8 +881,8 @@ class FlutterPlugin implements Plugin<Project> {
|
||||
localEngine this.localEngine
|
||||
localEngineSrcPath this.localEngineSrcPath
|
||||
targetPath getFlutterTarget()
|
||||
verbose isVerbose()
|
||||
fastStart isFastStart()
|
||||
verbose this.isVerbose()
|
||||
fastStart this.isFastStart()
|
||||
fileSystemRoots fileSystemRootsValue
|
||||
fileSystemScheme fileSystemSchemeValue
|
||||
trackWidgetCreation trackWidgetCreationValue
|
||||
@ -1089,7 +1086,7 @@ abstract class BaseFlutterTask extends DefaultTask {
|
||||
Boolean fastStart
|
||||
@Input
|
||||
String targetPath
|
||||
@Optional @Internal
|
||||
@Optional @Input
|
||||
Boolean verbose
|
||||
@Optional @Input
|
||||
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