Unverified Commit c6d46252 authored by Danny Tuppeny's avatar Danny Tuppeny Committed by GitHub

Ensure the flutter_gen project is correctly created as part of "flutter create" (#92975)

parent 09d08510
......@@ -13,8 +13,11 @@ import '../android/gradle_utils.dart' as gradle;
import '../base/common.dart';
import '../base/file_system.dart';
import '../base/utils.dart';
import '../build_info.dart';
import '../build_system/build_system.dart';
import '../cache.dart';
import '../convert.dart';
import '../dart/generate_synthetic_packages.dart';
import '../dart/pub.dart';
import '../features.dart';
import '../flutter_project_metadata.dart';
......@@ -480,6 +483,27 @@ abstract class CreateBase extends FlutterCommand {
}
if (boolArg('pub')) {
final Environment environment = Environment(
artifacts: globals.artifacts,
logger: globals.logger,
cacheDir: globals.cache.getRoot(),
engineVersion: globals.flutterVersion.engineRevision,
fileSystem: globals.fs,
flutterRootDir: globals.fs.directory(Cache.flutterRoot),
outputDir: globals.fs.directory(getBuildDirectory()),
processManager: globals.processManager,
platform: globals.platform,
projectDir: project.directory,
generateDartPluginRegistry: true,
);
// Generate the l10n synthetic package that will be injected into the
// package_config in the call to pub.get() below.
await generateLocalizationsSyntheticPackage(
environment: environment,
buildSystem: globals.buildSystem,
);
await pub.get(
context: PubContext.create,
directory: directory.path,
......
......@@ -1291,7 +1291,9 @@ class LocalizationsGenerator {
// A pubspec.yaml file is required when using a synthetic package. If it does not
// exist, create a blank one.
if (useSyntheticPackage) {
final Directory syntheticPackageDirectory = _fs.directory(_defaultSyntheticPackagePath(_fs));
final Directory syntheticPackageDirectory = projectDirectory != null
? projectDirectory!.childDirectory(_defaultSyntheticPackagePath(_fs))
: _fs.directory(_defaultSyntheticPackagePath(_fs));
syntheticPackageDirectory.createSync(recursive: true);
final File flutterGenPubspec = syntheticPackageDirectory.childFile('pubspec.yaml');
if (!flutterGenPubspec.existsSync()) {
......
......@@ -147,6 +147,8 @@ void main() {
projectDir,
<String>['-t', 'skeleton', '-i', 'objc', '-a', 'java', '--implementation-tests'],
<String>[
'.dart_tool/flutter_gen/pubspec.yaml',
'.dart_tool/flutter_gen/gen_l10n/app_localizations.dart',
'analysis_options.yaml',
'android/app/src/main/java/com/example/flutter_project/MainActivity.java',
'android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.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