closes #issue136763, changed a command to generate gradle error message according to platform (#149877)
Currently, the error message displayed to regenerate the lockfiles gives a Unix-like command ./gradlew, which will be incorrect for Windows environments. This PR uses globals.platform.isWindows to give the appropriate command. closes #136763
This commit is contained in:
@@ -414,8 +414,9 @@ final GradleHandledError lockFileDepMissingHandler = GradleHandledError(
|
||||
final File gradleFile = project.directory
|
||||
.childDirectory('android')
|
||||
.childFile('build.gradle');
|
||||
final String generatedGradleCommand = globals.platform.isWindows ? r'.\gradlew.bat' : './gradlew';
|
||||
final String textInBold = globals.logger.terminal.bolden(
|
||||
'To regenerate the lockfiles run: `./gradlew :generateLockfiles` in ${gradleFile.path}\n'
|
||||
'To regenerate the lockfiles run: `$generatedGradleCommand :generateLockfiles` in ${gradleFile.path}\n'
|
||||
'To remove dependency locking, remove the `dependencyLocking` from ${gradleFile.path}'
|
||||
);
|
||||
globals.printBox(
|
||||
|
||||
@@ -782,8 +782,7 @@ Execution failed for task ':app:generateDebugFeatureTransitiveDeps'.
|
||||
'│ To regenerate the lockfiles run: `./gradlew :generateLockfiles` in /android/build.gradle │\n'
|
||||
'│ To remove dependency locking, remove the `dependencyLocking` from /android/build.gradle │\n'
|
||||
'└──────────────────────────────────────────────────────────────────────────────────────────┘\n'
|
||||
)
|
||||
);
|
||||
));
|
||||
}, overrides: <Type, Generator>{
|
||||
GradleUtils: () => FakeGradleUtils(),
|
||||
Platform: () => fakePlatform('android'),
|
||||
@@ -792,6 +791,54 @@ Execution failed for task ':app:generateDebugFeatureTransitiveDeps'.
|
||||
});
|
||||
});
|
||||
|
||||
testUsingContext('generates correct gradle command for Unix-like environment',
|
||||
() async {
|
||||
await lockFileDepMissingHandler.handler(
|
||||
project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
|
||||
usesAndroidX: true,
|
||||
line: '',
|
||||
);
|
||||
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
contains('\n'
|
||||
'┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────┐\n'
|
||||
'│ You need to update the lockfile, or disable Gradle dependency locking. │\n'
|
||||
'│ To regenerate the lockfiles run: `./gradlew :generateLockfiles` in /android/build.gradle │\n'
|
||||
'│ To remove dependency locking, remove the `dependencyLocking` from /android/build.gradle │\n'
|
||||
'└──────────────────────────────────────────────────────────────────────────────────────────┘\n'
|
||||
''));
|
||||
}, overrides: <Type, Generator>{
|
||||
GradleUtils: () => FakeGradleUtils(),
|
||||
Platform: () => fakePlatform('linux'),
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
|
||||
testUsingContext('generates correct gradle command for windows environment',
|
||||
() async {
|
||||
await lockFileDepMissingHandler.handler(
|
||||
project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
|
||||
usesAndroidX: true,
|
||||
line: '',
|
||||
);
|
||||
expect(
|
||||
testLogger.statusText,
|
||||
contains('\n'
|
||||
'┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────┐\n'
|
||||
'│ You need to update the lockfile, or disable Gradle dependency locking. │\n'
|
||||
'│ To regenerate the lockfiles run: `.\\gradlew.bat :generateLockfiles` in /android/build.gradle │\n'
|
||||
'│ To remove dependency locking, remove the `dependencyLocking` from /android/build.gradle │\n'
|
||||
'└──────────────────────────────────────────────────────────────────────────────────────────────┘\n'
|
||||
''));
|
||||
}, overrides: <Type, Generator>{
|
||||
GradleUtils: () => FakeGradleUtils(),
|
||||
Platform: () => fakePlatform('windows'),
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
group('Incompatible Kotlin version', () {
|
||||
testWithoutContext('pattern', () {
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user