mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] remove mock process manager from gradle tests (#76252)
This commit is contained in:
parent
00630d0980
commit
555721de24
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
import 'package:process/process.dart';
|
||||||
import 'package:xml/xml.dart';
|
import 'package:xml/xml.dart';
|
||||||
|
|
||||||
import '../artifacts.dart';
|
import '../artifacts.dart';
|
||||||
@ -21,7 +22,7 @@ import '../build_info.dart';
|
|||||||
import '../cache.dart';
|
import '../cache.dart';
|
||||||
import '../convert.dart';
|
import '../convert.dart';
|
||||||
import '../flutter_manifest.dart';
|
import '../flutter_manifest.dart';
|
||||||
import '../globals.dart' as globals hide logger, printStatus, printTrace, printError;
|
import '../globals.dart' as globals hide logger, printStatus, printTrace, printError, processManager, processUtils, fs;
|
||||||
import '../project.dart';
|
import '../project.dart';
|
||||||
import '../reporting/reporting.dart';
|
import '../reporting/reporting.dart';
|
||||||
import 'android_builder.dart';
|
import 'android_builder.dart';
|
||||||
@ -108,13 +109,14 @@ Iterable<String> _apkFilesFor(AndroidBuildInfo androidBuildInfo) {
|
|||||||
|
|
||||||
/// Returns true if the current version of the Gradle plugin is supported.
|
/// Returns true if the current version of the Gradle plugin is supported.
|
||||||
bool _isSupportedVersion(AndroidProject project) {
|
bool _isSupportedVersion(AndroidProject project) {
|
||||||
|
final FileSystem fileSystem = project.hostAppGradleRoot.fileSystem;
|
||||||
final File plugin = project.hostAppGradleRoot.childFile(
|
final File plugin = project.hostAppGradleRoot.childFile(
|
||||||
globals.fs.path.join('buildSrc', 'src', 'main', 'groovy', 'FlutterPlugin.groovy'));
|
fileSystem.path.join('buildSrc', 'src', 'main', 'groovy', 'FlutterPlugin.groovy'));
|
||||||
if (plugin.existsSync()) {
|
if (plugin.existsSync()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final File appGradle = project.hostAppGradleRoot.childFile(
|
final File appGradle = project.hostAppGradleRoot.childFile(
|
||||||
globals.fs.path.join('app', 'build.gradle'));
|
fileSystem.path.join('app', 'build.gradle'));
|
||||||
if (!appGradle.existsSync()) {
|
if (!appGradle.existsSync()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -137,12 +139,12 @@ Future<File> getGradleAppOut(AndroidProject androidProject) async {
|
|||||||
|
|
||||||
/// Runs `gradlew dependencies`, ensuring that dependencies are resolved and
|
/// Runs `gradlew dependencies`, ensuring that dependencies are resolved and
|
||||||
/// potentially downloaded.
|
/// potentially downloaded.
|
||||||
Future<void> checkGradleDependencies(Logger logger) async {
|
Future<void> checkGradleDependencies(Logger logger, ProcessUtils processUtils) async {
|
||||||
final Status progress = logger.startProgress(
|
final Status progress = logger.startProgress(
|
||||||
'Ensuring gradle dependencies are up to date...',
|
'Ensuring gradle dependencies are up to date...',
|
||||||
);
|
);
|
||||||
final FlutterProject flutterProject = FlutterProject.current();
|
final FlutterProject flutterProject = FlutterProject.current();
|
||||||
await globals.processUtils.run(<String>[
|
await processUtils.run(<String>[
|
||||||
globals.gradleUtils.getExecutable(flutterProject),
|
globals.gradleUtils.getExecutable(flutterProject),
|
||||||
'dependencies',
|
'dependencies',
|
||||||
],
|
],
|
||||||
@ -162,6 +164,7 @@ Future<void> checkGradleDependencies(Logger logger) async {
|
|||||||
/// `settings.gradle` file has local edits.
|
/// `settings.gradle` file has local edits.
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
void createSettingsAarGradle(Directory androidDirectory, Logger logger) {
|
void createSettingsAarGradle(Directory androidDirectory, Logger logger) {
|
||||||
|
final FileSystem fileSystem = androidDirectory.fileSystem;
|
||||||
final File newSettingsFile = androidDirectory.childFile('settings_aar.gradle');
|
final File newSettingsFile = androidDirectory.childFile('settings_aar.gradle');
|
||||||
if (newSettingsFile.existsSync()) {
|
if (newSettingsFile.existsSync()) {
|
||||||
return;
|
return;
|
||||||
@ -172,14 +175,14 @@ void createSettingsAarGradle(Directory androidDirectory, Logger logger) {
|
|||||||
}
|
}
|
||||||
final String currentFileContent = currentSettingsFile.readAsStringSync();
|
final String currentFileContent = currentSettingsFile.readAsStringSync();
|
||||||
|
|
||||||
final String newSettingsRelativeFile = globals.fs.path.relative(newSettingsFile.path);
|
final String newSettingsRelativeFile = fileSystem.path.relative(newSettingsFile.path);
|
||||||
final Status status = logger.startProgress('✏️ Creating `$newSettingsRelativeFile`...');
|
final Status status = logger.startProgress('✏️ Creating `$newSettingsRelativeFile`...');
|
||||||
|
|
||||||
final String flutterRoot = globals.fs.path.absolute(Cache.flutterRoot);
|
final String flutterRoot = fileSystem.path.absolute(Cache.flutterRoot);
|
||||||
final File legacySettingsDotGradleFiles = globals.fs.file(globals.fs.path.join(flutterRoot, 'packages','flutter_tools',
|
final File legacySettingsDotGradleFiles = fileSystem.file(fileSystem.path.join(flutterRoot, 'packages','flutter_tools',
|
||||||
'gradle', 'settings.gradle.legacy_versions'));
|
'gradle', 'settings.gradle.legacy_versions'));
|
||||||
assert(legacySettingsDotGradleFiles.existsSync());
|
assert(legacySettingsDotGradleFiles.existsSync());
|
||||||
final String settingsAarContent = globals.fs.file(globals.fs.path.join(flutterRoot, 'packages','flutter_tools',
|
final String settingsAarContent = fileSystem.file(fileSystem.path.join(flutterRoot, 'packages','flutter_tools',
|
||||||
'gradle', 'settings_aar.gradle.tmpl')).readAsStringSync();
|
'gradle', 'settings_aar.gradle.tmpl')).readAsStringSync();
|
||||||
|
|
||||||
// Get the `settings.gradle` content variants that should be patched.
|
// Get the `settings.gradle` content variants that should be patched.
|
||||||
@ -197,7 +200,7 @@ void createSettingsAarGradle(Directory androidDirectory, Logger logger) {
|
|||||||
status.cancel();
|
status.cancel();
|
||||||
logger.printStatus('$warningMark Flutter tried to create the file `$newSettingsRelativeFile`, but failed.');
|
logger.printStatus('$warningMark Flutter tried to create the file `$newSettingsRelativeFile`, but failed.');
|
||||||
// Print how to manually update the file.
|
// Print how to manually update the file.
|
||||||
logger.printStatus(globals.fs.file(globals.fs.path.join(flutterRoot, 'packages','flutter_tools',
|
logger.printStatus(fileSystem.file(fileSystem.path.join(flutterRoot, 'packages','flutter_tools',
|
||||||
'gradle', 'manual_migration_settings.gradle.md')).readAsStringSync());
|
'gradle', 'manual_migration_settings.gradle.md')).readAsStringSync());
|
||||||
throwToolExit('Please create the file and run this command again.');
|
throwToolExit('Please create the file and run this command again.');
|
||||||
}
|
}
|
||||||
@ -211,9 +214,15 @@ void createSettingsAarGradle(Directory androidDirectory, Logger logger) {
|
|||||||
class AndroidGradleBuilder implements AndroidBuilder {
|
class AndroidGradleBuilder implements AndroidBuilder {
|
||||||
AndroidGradleBuilder({
|
AndroidGradleBuilder({
|
||||||
@required Logger logger,
|
@required Logger logger,
|
||||||
}) : _logger = logger;
|
@required ProcessManager processManager,
|
||||||
|
@required FileSystem fileSystem,
|
||||||
|
}) : _logger = logger,
|
||||||
|
_fileSystem = fileSystem,
|
||||||
|
_processUtils = ProcessUtils(logger: logger, processManager: processManager);
|
||||||
|
|
||||||
final Logger _logger;
|
final Logger _logger;
|
||||||
|
final ProcessUtils _processUtils;
|
||||||
|
final FileSystem _fileSystem;
|
||||||
|
|
||||||
/// Builds the AAR and POM files for the current Flutter module or plugin.
|
/// Builds the AAR and POM files for the current Flutter module or plugin.
|
||||||
@override
|
@override
|
||||||
@ -226,7 +235,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
Directory outputDirectory =
|
Directory outputDirectory =
|
||||||
globals.fs.directory(outputDirectoryPath ?? project.android.buildDirectory);
|
_fileSystem.directory(outputDirectoryPath ?? project.android.buildDirectory);
|
||||||
if (project.isModule) {
|
if (project.isModule) {
|
||||||
// Module projects artifacts are located in `build/host`.
|
// Module projects artifacts are located in `build/host`.
|
||||||
outputDirectory = outputDirectory.childDirectory('host');
|
outputDirectory = outputDirectory.childDirectory('host');
|
||||||
@ -249,7 +258,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
repoDirectory: getRepoDirectory(outputDirectory),
|
repoDirectory: getRepoDirectory(outputDirectory),
|
||||||
buildNumber: buildNumber,
|
buildNumber: buildNumber,
|
||||||
logger: _logger,
|
logger: _logger,
|
||||||
fileSystem: globals.fs,
|
fileSystem: _fileSystem,
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
globals.androidSdk?.reinitialize();
|
globals.androidSdk?.reinitialize();
|
||||||
@ -383,6 +392,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
final Directory localEngineRepo = _getLocalEngineRepo(
|
final Directory localEngineRepo = _getLocalEngineRepo(
|
||||||
engineOutPath: localEngineArtifacts.engineOutPath,
|
engineOutPath: localEngineArtifacts.engineOutPath,
|
||||||
androidBuildInfo: androidBuildInfo,
|
androidBuildInfo: androidBuildInfo,
|
||||||
|
fileSystem: _fileSystem,
|
||||||
);
|
);
|
||||||
_logger.printTrace(
|
_logger.printTrace(
|
||||||
'Using local engine: ${localEngineArtifacts.engineOutPath}\n'
|
'Using local engine: ${localEngineArtifacts.engineOutPath}\n'
|
||||||
@ -454,7 +464,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
..start();
|
..start();
|
||||||
int exitCode = 1;
|
int exitCode = 1;
|
||||||
try {
|
try {
|
||||||
exitCode = await globals.processUtils.stream(
|
exitCode = await _processUtils.stream(
|
||||||
command,
|
command,
|
||||||
workingDirectory: project.android.hostAppGradleRoot.path,
|
workingDirectory: project.android.hostAppGradleRoot.path,
|
||||||
allowReentrantFlutter: true,
|
allowReentrantFlutter: true,
|
||||||
@ -542,7 +552,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_logger.printStatus(
|
_logger.printStatus(
|
||||||
'$successMark Built ${globals.fs.path.relative(bundleFile.path)}$appSize.',
|
'$successMark Built ${_fileSystem.path.relative(bundleFile.path)}$appSize.',
|
||||||
color: TerminalColor.green,
|
color: TerminalColor.green,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@ -575,7 +585,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
? '' // Don't display the size when building a debug variant.
|
? '' // Don't display the size when building a debug variant.
|
||||||
: ' (${getSizeAsMB(apkFile.lengthSync())})';
|
: ' (${getSizeAsMB(apkFile.lengthSync())})';
|
||||||
_logger.printStatus(
|
_logger.printStatus(
|
||||||
'$successMark Built ${globals.fs.path.relative(apkFile.path)}$appSize.',
|
'$successMark Built ${_fileSystem.path.relative(apkFile.path)}$appSize.',
|
||||||
color: TerminalColor.green,
|
color: TerminalColor.green,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -588,15 +598,15 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
File zipFile,
|
File zipFile,
|
||||||
AndroidBuildInfo androidBuildInfo,) async {
|
AndroidBuildInfo androidBuildInfo,) async {
|
||||||
final SizeAnalyzer sizeAnalyzer = SizeAnalyzer(
|
final SizeAnalyzer sizeAnalyzer = SizeAnalyzer(
|
||||||
fileSystem: globals.fs,
|
fileSystem: _fileSystem,
|
||||||
logger: _logger,
|
logger: _logger,
|
||||||
flutterUsage: globals.flutterUsage,
|
flutterUsage: globals.flutterUsage,
|
||||||
);
|
);
|
||||||
final String archName = getNameForAndroidArch(androidBuildInfo.targetArchs.single);
|
final String archName = getNameForAndroidArch(androidBuildInfo.targetArchs.single);
|
||||||
final BuildInfo buildInfo = androidBuildInfo.buildInfo;
|
final BuildInfo buildInfo = androidBuildInfo.buildInfo;
|
||||||
final File aotSnapshot = globals.fs.directory(buildInfo.codeSizeDirectory)
|
final File aotSnapshot = _fileSystem.directory(buildInfo.codeSizeDirectory)
|
||||||
.childFile('snapshot.$archName.json');
|
.childFile('snapshot.$archName.json');
|
||||||
final File precompilerTrace = globals.fs.directory(buildInfo.codeSizeDirectory)
|
final File precompilerTrace = _fileSystem.directory(buildInfo.codeSizeDirectory)
|
||||||
.childFile('trace.$archName.json');
|
.childFile('trace.$archName.json');
|
||||||
final Map<String, Object> output = await sizeAnalyzer.analyzeZipSizeAndAotSnapshot(
|
final Map<String, Object> output = await sizeAnalyzer.analyzeZipSizeAndAotSnapshot(
|
||||||
zipFile: zipFile,
|
zipFile: zipFile,
|
||||||
@ -605,7 +615,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
kind: kind,
|
kind: kind,
|
||||||
);
|
);
|
||||||
final File outputFile = globals.fsUtils.getUniqueFile(
|
final File outputFile = globals.fsUtils.getUniqueFile(
|
||||||
globals.fs
|
_fileSystem
|
||||||
.directory(globals.fsUtils.homeDirPath)
|
.directory(globals.fsUtils.homeDirPath)
|
||||||
.childDirectory('.flutter-devtools'), '$kind-code-size-analysis', 'json',
|
.childDirectory('.flutter-devtools'), '$kind-code-size-analysis', 'json',
|
||||||
)
|
)
|
||||||
@ -658,8 +668,8 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
multilineOutput: true,
|
multilineOutput: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
final String flutterRoot = globals.fs.path.absolute(Cache.flutterRoot);
|
final String flutterRoot = _fileSystem.path.absolute(Cache.flutterRoot);
|
||||||
final String initScript = globals.fs.path.join(
|
final String initScript = _fileSystem.path.join(
|
||||||
flutterRoot,
|
flutterRoot,
|
||||||
'packages',
|
'packages',
|
||||||
'flutter_tools',
|
'flutter_tools',
|
||||||
@ -699,6 +709,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
final Directory localEngineRepo = _getLocalEngineRepo(
|
final Directory localEngineRepo = _getLocalEngineRepo(
|
||||||
engineOutPath: localEngineArtifacts.engineOutPath,
|
engineOutPath: localEngineArtifacts.engineOutPath,
|
||||||
androidBuildInfo: androidBuildInfo,
|
androidBuildInfo: androidBuildInfo,
|
||||||
|
fileSystem: _fileSystem,
|
||||||
);
|
);
|
||||||
_logger.printTrace(
|
_logger.printTrace(
|
||||||
'Using local engine: ${localEngineArtifacts.engineOutPath}\n'
|
'Using local engine: ${localEngineArtifacts.engineOutPath}\n'
|
||||||
@ -734,7 +745,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
..start();
|
..start();
|
||||||
RunResult result;
|
RunResult result;
|
||||||
try {
|
try {
|
||||||
result = await globals.processUtils.run(
|
result = await _processUtils.run(
|
||||||
command,
|
command,
|
||||||
workingDirectory: project.android.hostAppGradleRoot.path,
|
workingDirectory: project.android.hostAppGradleRoot.path,
|
||||||
allowReentrantFlutter: true,
|
allowReentrantFlutter: true,
|
||||||
@ -766,7 +777,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
_logger.printStatus(
|
_logger.printStatus(
|
||||||
'$successMark Built ${globals.fs.path.relative(repoDirectory.path)}.',
|
'$successMark Built ${_fileSystem.path.relative(repoDirectory.path)}.',
|
||||||
color: TerminalColor.green,
|
color: TerminalColor.green,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -788,7 +799,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
|
|||||||
if (pluginParts.length != 2) {
|
if (pluginParts.length != 2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Directory pluginDirectory = globals.fs.directory(pluginParts.last);
|
final Directory pluginDirectory = _fileSystem.directory(pluginParts.last);
|
||||||
assert(pluginDirectory.existsSync());
|
assert(pluginDirectory.existsSync());
|
||||||
|
|
||||||
final String pluginName = pluginParts.first;
|
final String pluginName = pluginParts.first;
|
||||||
@ -1067,12 +1078,12 @@ void _exitWithExpectedFileNotFound({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _createSymlink(String targetPath, String linkPath) {
|
void _createSymlink(String targetPath, String linkPath, FileSystem fileSystem) {
|
||||||
final File targetFile = globals.fs.file(targetPath);
|
final File targetFile = fileSystem.file(targetPath);
|
||||||
if (!targetFile.existsSync()) {
|
if (!targetFile.existsSync()) {
|
||||||
throwToolExit("The file $targetPath wasn't found in the local engine out directory.");
|
throwToolExit("The file $targetPath wasn't found in the local engine out directory.");
|
||||||
}
|
}
|
||||||
final File linkFile = globals.fs.file(linkPath);
|
final File linkFile = fileSystem.file(linkPath);
|
||||||
final Link symlink = linkFile.parent.childLink(linkFile.basename);
|
final Link symlink = linkFile.parent.childLink(linkFile.basename);
|
||||||
try {
|
try {
|
||||||
symlink.createSync(targetPath, recursive: true);
|
symlink.createSync(targetPath, recursive: true);
|
||||||
@ -1083,8 +1094,8 @@ void _createSymlink(String targetPath, String linkPath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getLocalArtifactVersion(String pomPath) {
|
String _getLocalArtifactVersion(String pomPath, FileSystem fileSystem) {
|
||||||
final File pomFile = globals.fs.file(pomPath);
|
final File pomFile = fileSystem.file(pomPath);
|
||||||
if (!pomFile.existsSync()) {
|
if (!pomFile.existsSync()) {
|
||||||
throwToolExit("The file $pomPath wasn't found in the local engine out directory.");
|
throwToolExit("The file $pomPath wasn't found in the local engine out directory.");
|
||||||
}
|
}
|
||||||
@ -1118,12 +1129,13 @@ String _getLocalArtifactVersion(String pomPath) {
|
|||||||
Directory _getLocalEngineRepo({
|
Directory _getLocalEngineRepo({
|
||||||
@required String engineOutPath,
|
@required String engineOutPath,
|
||||||
@required AndroidBuildInfo androidBuildInfo,
|
@required AndroidBuildInfo androidBuildInfo,
|
||||||
|
@required FileSystem fileSystem,
|
||||||
}) {
|
}) {
|
||||||
assert(engineOutPath != null);
|
assert(engineOutPath != null);
|
||||||
assert(androidBuildInfo != null);
|
assert(androidBuildInfo != null);
|
||||||
|
|
||||||
final String abi = _getAbiByLocalEnginePath(engineOutPath);
|
final String abi = _getAbiByLocalEnginePath(engineOutPath);
|
||||||
final Directory localEngineRepo = globals.fs.systemTempDirectory
|
final Directory localEngineRepo = fileSystem.systemTempDirectory
|
||||||
.createTempSync('flutter_tool_local_engine_repo.');
|
.createTempSync('flutter_tool_local_engine_repo.');
|
||||||
|
|
||||||
// Remove the local engine repo before the tool exits.
|
// Remove the local engine repo before the tool exits.
|
||||||
@ -1137,19 +1149,20 @@ Directory _getLocalEngineRepo({
|
|||||||
|
|
||||||
final String buildMode = androidBuildInfo.buildInfo.modeName;
|
final String buildMode = androidBuildInfo.buildInfo.modeName;
|
||||||
final String artifactVersion = _getLocalArtifactVersion(
|
final String artifactVersion = _getLocalArtifactVersion(
|
||||||
globals.fs.path.join(
|
fileSystem.path.join(
|
||||||
engineOutPath,
|
engineOutPath,
|
||||||
'flutter_embedding_$buildMode.pom',
|
'flutter_embedding_$buildMode.pom',
|
||||||
)
|
),
|
||||||
|
fileSystem,
|
||||||
);
|
);
|
||||||
for (final String artifact in const <String>['pom', 'jar']) {
|
for (final String artifact in const <String>['pom', 'jar']) {
|
||||||
// The Android embedding artifacts.
|
// The Android embedding artifacts.
|
||||||
_createSymlink(
|
_createSymlink(
|
||||||
globals.fs.path.join(
|
fileSystem.path.join(
|
||||||
engineOutPath,
|
engineOutPath,
|
||||||
'flutter_embedding_$buildMode.$artifact',
|
'flutter_embedding_$buildMode.$artifact',
|
||||||
),
|
),
|
||||||
globals.fs.path.join(
|
fileSystem.path.join(
|
||||||
localEngineRepo.path,
|
localEngineRepo.path,
|
||||||
'io',
|
'io',
|
||||||
'flutter',
|
'flutter',
|
||||||
@ -1157,14 +1170,15 @@ Directory _getLocalEngineRepo({
|
|||||||
artifactVersion,
|
artifactVersion,
|
||||||
'flutter_embedding_$buildMode-$artifactVersion.$artifact',
|
'flutter_embedding_$buildMode-$artifactVersion.$artifact',
|
||||||
),
|
),
|
||||||
|
fileSystem,
|
||||||
);
|
);
|
||||||
// The engine artifacts (libflutter.so).
|
// The engine artifacts (libflutter.so).
|
||||||
_createSymlink(
|
_createSymlink(
|
||||||
globals.fs.path.join(
|
fileSystem.path.join(
|
||||||
engineOutPath,
|
engineOutPath,
|
||||||
'${abi}_$buildMode.$artifact',
|
'${abi}_$buildMode.$artifact',
|
||||||
),
|
),
|
||||||
globals.fs.path.join(
|
fileSystem.path.join(
|
||||||
localEngineRepo.path,
|
localEngineRepo.path,
|
||||||
'io',
|
'io',
|
||||||
'flutter',
|
'flutter',
|
||||||
@ -1172,21 +1186,23 @@ Directory _getLocalEngineRepo({
|
|||||||
artifactVersion,
|
artifactVersion,
|
||||||
'${abi}_$buildMode-$artifactVersion.$artifact',
|
'${abi}_$buildMode-$artifactVersion.$artifact',
|
||||||
),
|
),
|
||||||
|
fileSystem,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for (final String artifact in <String>['flutter_embedding_$buildMode', '${abi}_$buildMode']) {
|
for (final String artifact in <String>['flutter_embedding_$buildMode', '${abi}_$buildMode']) {
|
||||||
_createSymlink(
|
_createSymlink(
|
||||||
globals.fs.path.join(
|
fileSystem.path.join(
|
||||||
engineOutPath,
|
engineOutPath,
|
||||||
'$artifact.maven-metadata.xml',
|
'$artifact.maven-metadata.xml',
|
||||||
),
|
),
|
||||||
globals.fs.path.join(
|
fileSystem.path.join(
|
||||||
localEngineRepo.path,
|
localEngineRepo.path,
|
||||||
'io',
|
'io',
|
||||||
'flutter',
|
'flutter',
|
||||||
artifact,
|
artifact,
|
||||||
'maven-metadata.xml',
|
'maven-metadata.xml',
|
||||||
),
|
),
|
||||||
|
fileSystem,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return localEngineRepo;
|
return localEngineRepo;
|
||||||
|
@ -65,7 +65,7 @@ class ApplicationPackageFactory {
|
|||||||
case TargetPlatform.android_x64:
|
case TargetPlatform.android_x64:
|
||||||
case TargetPlatform.android_x86:
|
case TargetPlatform.android_x86:
|
||||||
if (_androidSdk?.licensesAvailable == true && _androidSdk?.latestVersion == null) {
|
if (_androidSdk?.licensesAvailable == true && _androidSdk?.latestVersion == null) {
|
||||||
await checkGradleDependencies(_logger);
|
await checkGradleDependencies(_logger, _processUtils);
|
||||||
}
|
}
|
||||||
if (applicationBinary == null) {
|
if (applicationBinary == null) {
|
||||||
return await AndroidApk.fromAndroidProject(
|
return await AndroidApk.fromAndroidProject(
|
||||||
|
@ -81,6 +81,8 @@ Future<T> runInContext<T>(
|
|||||||
fallbacks: <Type, Generator>{
|
fallbacks: <Type, Generator>{
|
||||||
AndroidBuilder: () => AndroidGradleBuilder(
|
AndroidBuilder: () => AndroidGradleBuilder(
|
||||||
logger: globals.logger,
|
logger: globals.logger,
|
||||||
|
processManager: globals.processManager,
|
||||||
|
fileSystem: globals.fs,
|
||||||
),
|
),
|
||||||
AndroidLicenseValidator: () => AndroidLicenseValidator(
|
AndroidLicenseValidator: () => AndroidLicenseValidator(
|
||||||
operatingSystemUtils: globals.os,
|
operatingSystemUtils: globals.os,
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -436,9 +436,11 @@ void main() {
|
|||||||
|
|
||||||
group('Config files', () {
|
group('Config files', () {
|
||||||
Directory tempDir;
|
Directory tempDir;
|
||||||
|
FileSystem fileSystem;
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_settings_aar_test.');
|
fileSystem = MemoryFileSystem.test();
|
||||||
|
tempDir = fileSystem.systemTempDirectory.createTempSync('flutter_settings_aar_test.');
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('create settings_aar.gradle when current settings.gradle loads plugins', () {
|
testUsingContext('create settings_aar.gradle when current settings.gradle loads plugins', () {
|
||||||
@ -468,25 +470,24 @@ include ':app'
|
|||||||
|
|
||||||
tempDir.childFile('settings.gradle').writeAsStringSync(currentSettingsGradle);
|
tempDir.childFile('settings.gradle').writeAsStringSync(currentSettingsGradle);
|
||||||
|
|
||||||
final String toolGradlePath = globals.fs.path.join(
|
final String toolGradlePath = fileSystem.path.join(
|
||||||
globals.fs.path.absolute(Cache.flutterRoot),
|
fileSystem.path.absolute(Cache.flutterRoot),
|
||||||
'packages',
|
'packages',
|
||||||
'flutter_tools',
|
'flutter_tools',
|
||||||
'gradle');
|
'gradle');
|
||||||
globals.fs.directory(toolGradlePath).createSync(recursive: true);
|
fileSystem.directory(toolGradlePath).createSync(recursive: true);
|
||||||
globals.fs.file(globals.fs.path.join(toolGradlePath, 'settings.gradle.legacy_versions'))
|
fileSystem.file(fileSystem.path.join(toolGradlePath, 'settings.gradle.legacy_versions'))
|
||||||
.writeAsStringSync(currentSettingsGradle);
|
.writeAsStringSync(currentSettingsGradle);
|
||||||
|
|
||||||
globals.fs.file(globals.fs.path.join(toolGradlePath, 'settings_aar.gradle.tmpl'))
|
fileSystem.file(fileSystem.path.join(toolGradlePath, 'settings_aar.gradle.tmpl'))
|
||||||
.writeAsStringSync(settingsAarFile);
|
.writeAsStringSync(settingsAarFile);
|
||||||
|
|
||||||
createSettingsAarGradle(tempDir, testLogger);
|
createSettingsAarGradle(tempDir, testLogger);
|
||||||
|
|
||||||
expect(testLogger.statusText, contains('created successfully'));
|
expect(testLogger.statusText, contains('created successfully'));
|
||||||
expect(tempDir.childFile('settings_aar.gradle').existsSync(), isTrue);
|
expect(tempDir.childFile('settings_aar.gradle').existsSync(), isTrue);
|
||||||
|
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
FileSystem: () => MemoryFileSystem.test(),
|
FileSystem: () => fileSystem,
|
||||||
ProcessManager: () => FakeProcessManager.any(),
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -501,25 +502,24 @@ include ':app'
|
|||||||
|
|
||||||
tempDir.childFile('settings.gradle').writeAsStringSync(currentSettingsGradle);
|
tempDir.childFile('settings.gradle').writeAsStringSync(currentSettingsGradle);
|
||||||
|
|
||||||
final String toolGradlePath = globals.fs.path.join(
|
final String toolGradlePath = fileSystem.path.join(
|
||||||
globals.fs.path.absolute(Cache.flutterRoot),
|
fileSystem.path.absolute(Cache.flutterRoot),
|
||||||
'packages',
|
'packages',
|
||||||
'flutter_tools',
|
'flutter_tools',
|
||||||
'gradle');
|
'gradle');
|
||||||
globals.fs.directory(toolGradlePath).createSync(recursive: true);
|
fileSystem.directory(toolGradlePath).createSync(recursive: true);
|
||||||
globals.fs.file(globals.fs.path.join(toolGradlePath, 'settings.gradle.legacy_versions'))
|
fileSystem.file(fileSystem.path.join(toolGradlePath, 'settings.gradle.legacy_versions'))
|
||||||
.writeAsStringSync(currentSettingsGradle);
|
.writeAsStringSync(currentSettingsGradle);
|
||||||
|
|
||||||
globals.fs.file(globals.fs.path.join(toolGradlePath, 'settings_aar.gradle.tmpl'))
|
fileSystem.file(fileSystem.path.join(toolGradlePath, 'settings_aar.gradle.tmpl'))
|
||||||
.writeAsStringSync(settingsAarFile);
|
.writeAsStringSync(settingsAarFile);
|
||||||
|
|
||||||
createSettingsAarGradle(tempDir, testLogger);
|
createSettingsAarGradle(tempDir, testLogger);
|
||||||
|
|
||||||
expect(testLogger.statusText, contains('created successfully'));
|
expect(testLogger.statusText, contains('created successfully'));
|
||||||
expect(tempDir.childFile('settings_aar.gradle').existsSync(), isTrue);
|
expect(tempDir.childFile('settings_aar.gradle').existsSync(), isTrue);
|
||||||
|
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
FileSystem: () => MemoryFileSystem.test(),
|
FileSystem: () => fileSystem,
|
||||||
ProcessManager: () => FakeProcessManager.any(),
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -860,7 +860,7 @@ flutter:
|
|||||||
fakeProcessManager = FakeProcessManager.list(<FakeCommand>[]);
|
fakeProcessManager = FakeProcessManager.list(<FakeCommand>[]);
|
||||||
mockAndroidSdk = MockAndroidSdk();
|
mockAndroidSdk = MockAndroidSdk();
|
||||||
when(mockAndroidSdk.directory).thenReturn(fs.directory('irrelevant'));
|
when(mockAndroidSdk.directory).thenReturn(fs.directory('irrelevant'));
|
||||||
builder = AndroidGradleBuilder(logger: logger);
|
builder = AndroidGradleBuilder(logger: logger, processManager: fakeProcessManager, fileSystem: fs);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('calls gradle', () async {
|
testUsingContext('calls gradle', () async {
|
||||||
|
Loading…
Reference in New Issue
Block a user