Unverified Commit 3b390c52 authored by Gray Mackall's avatar Gray Mackall Committed by GitHub

Add a `--no-gradle-generation` mode to the `generate_gradle_lockfiles.dart` script (#145568)

The script currently overwrites existing `settings.gradle`, `build.gradle`, and `gradle-wrapper.properties` files in the directories it processes. This mode makes it not do that, and just generate the lockfiles themselves.

Related to https://github.com/flutter/flutter/pull/145564#r1371888460
parent a36569d1
......@@ -8,17 +8,39 @@
import 'dart:io';
import 'package:args/args.dart';
import 'package:file/file.dart';
import 'package:file/local.dart';
import 'package:path/path.dart' as path;
void main(List<String> arguments) {
print(
"Usage: find . -type d -name 'android' | dart dev/tools/bin/generate_gradle_lockfiles.dart\n"
const String usageMessage = "Usage: find . -type d -name 'android' | dart dev/tools/bin/generate_gradle_lockfiles.dart\n"
'If you would rather enter the files manually, just run `dart dev/tools/bin/generate_gradle_lockfiles.dart`,\n'
"enter the absolute paths to the app's android directory, then press CTRL-D.\n"
"If you don't wish to re-generate the settings.gradle, build.gradle, and gradle-wrapper.properties files,\n"
"add the flag '--no-gradle-generation'";
final ArgParser argParser = ArgParser()
..addFlag(
'gradle-generation',
help: 'Re-generate gradle files in each processed directory.',
defaultsTo: true,
);
ArgResults args;
try {
args = argParser.parse(arguments);
} on FormatException catch (error) {
stderr.writeln('${error.message}\n');
stderr.writeln(usageMessage);
exit(1);
}
print(usageMessage);
/// Re-generate gradle files in each processed directory.
final bool gradleGeneration = (args['gradle-generation'] as bool?) ?? true;
const FileSystem fileSystem = LocalFileSystem();
final List<String> androidDirectories = getFilesFromStdin();
......@@ -86,9 +108,11 @@ void main(List<String> arguments) {
// noop
}
if (gradleGeneration) {
rootBuildGradle.writeAsStringSync(rootGradleFileContent);
settingsGradle.writeAsStringSync(settingGradleFile);
wrapperGradle.writeAsStringSync(wrapperGradleFileContent);
}
final String appDirectory = androidDirectory.parent.absolute.path;
......
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