Unverified Commit 7ce6d414 authored by pan's avatar pan Committed by GitHub

add --extra-gen-snapshot-options support for build_aar command. (#91590)

parent e9519d8a
......@@ -44,6 +44,7 @@ class BuildAarCommand extends BuildSubCommand {
addSplitDebugInfoOption();
addDartObfuscationOption();
usesDartDefineOption();
usesExtraDartFlagOptions(verboseHelp: verboseHelp);
usesTrackWidgetCreation(verboseHelp: false);
addNullSafetyModeOptions(hide: !verboseHelp);
addEnableExperimentation(hide: !verboseHelp);
......
......@@ -7,10 +7,12 @@
import 'package:args/command_runner.dart';
import 'package:flutter_tools/src/android/android_builder.dart';
import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/android/android_studio.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build_aar.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
......@@ -20,6 +22,8 @@ import 'package:test/fake.dart';
import '../../src/android_common.dart';
import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/fake_process_manager.dart';
import '../../src/fakes.dart';
import '../../src/test_flutter_command_runner.dart';
void main() {
......@@ -190,9 +194,18 @@ void main() {
group('Gradle', () {
Directory tempDir;
AndroidSdk mockAndroidSdk;
String gradlew;
FakeProcessManager processManager;
String flutterRoot;
setUp(() {
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.');
mockAndroidSdk = FakeAndroidSdk();
gradlew = globals.fs.path.join(tempDir.path, 'flutter_project', '.android',
globals.platform.isWindows ? 'gradlew.bat' : 'gradlew');
processManager = FakeProcessManager.empty();
flutterRoot = getFlutterRoot();
});
tearDown(() {
......@@ -219,6 +232,46 @@ void main() {
ProcessManager: () => FakeProcessManager.any(),
});
});
testUsingContext('support ExtraDartFlagOptions', () async {
final String projectPath = await createProject(tempDir,
arguments: <String>['--no-pub', '--template=module']);
processManager.addCommand(FakeCommand(
command: <String>[
gradlew,
'-I=${globals.fs.path.join(flutterRoot, 'packages', 'flutter_tools', 'gradle','aar_init_script.gradle')}',
'-Pflutter-root=$flutterRoot',
'-Poutput-dir=${globals.fs.path.join(tempDir.path, 'flutter_project', 'build', 'host')}',
'-Pis-plugin=false',
'-PbuildNumber=1.0',
'-q',
'-Ptarget=${globals.fs.path.join('lib', 'main.dart')}',
'-Pdart-obfuscation=false',
'-Pextra-front-end-options=foo,bar',
'-Ptrack-widget-creation=true',
'-Ptree-shake-icons=true',
'-Ptarget-platform=android-arm,android-arm64,android-x64',
'assembleAarRelease',
],
exitCode: 1,
));
await expectLater(() => runBuildAarCommand(projectPath, arguments: <String>[
'--no-debug',
'--no-profile',
'--extra-front-end-options=foo',
'--extra-front-end-options=bar',
]), throwsToolExit(message: 'Gradle task assembleAarRelease failed with exit code 1'));
expect(processManager, hasNoRemainingExpectations);
},
overrides: <Type, Generator>{
AndroidSdk: () => mockAndroidSdk,
FlutterProjectFactory: () => FakeFlutterProjectFactory(tempDir),
ProcessManager: () => processManager,
FeatureFlags: () => TestFeatureFlags(isIOSEnabled: false),
AndroidStudio: () => FakeAndroidStudio(),
});
});
}
......@@ -259,3 +312,11 @@ class FakeAndroidBuilder extends Fake implements AndroidBuilder {
this.buildNumber = buildNumber;
}
}
class FakeAndroidSdk extends Fake implements AndroidSdk {
}
class FakeAndroidStudio extends Fake implements AndroidStudio {
@override
String get javaPath => 'java';
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment