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:
Satyam Srivastav
2024-06-12 10:42:57 +05:30
committed by GitHub
parent cc24f877db
commit c5e5e0cc36
2 changed files with 51 additions and 3 deletions

View File

@@ -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(

View File

@@ -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(