Unverified Commit 93c87e92 authored by Emmanuel Garcia's avatar Emmanuel Garcia Committed by GitHub

[flutter_tool] Suggest fix for transform input (#82309)

parent b70f20b5
...@@ -74,6 +74,7 @@ final List<GradleHandledError> gradleErrors = <GradleHandledError>[ ...@@ -74,6 +74,7 @@ final List<GradleHandledError> gradleErrors = <GradleHandledError>[
r8FailureHandler, r8FailureHandler,
androidXFailureHandler, androidXFailureHandler,
minSdkVersion, minSdkVersion,
transformInputIssue,
]; ];
// Permission defined error message. // Permission defined error message.
...@@ -394,3 +395,37 @@ final GradleHandledError minSdkVersion = GradleHandledError( ...@@ -394,3 +395,37 @@ final GradleHandledError minSdkVersion = GradleHandledError(
}, },
eventLabel: 'plugin-min-sdk', eventLabel: 'plugin-min-sdk',
); );
/// Handler when https://issuetracker.google.com/issues/141126614 or
/// https://github.com/flutter/flutter/issues/58247 is triggered.
@visibleForTesting
final GradleHandledError transformInputIssue = GradleHandledError(
test: (String line) {
return line.contains('https://issuetracker.google.com/issues/158753935');
},
handler: ({
String line,
FlutterProject project,
bool usesAndroidX,
bool shouldBuildPluginAsAar,
}) async {
final File gradleFile = project.directory
.childDirectory('android')
.childDirectory('app')
.childFile('build.gradle');
globals.printStatus(
'\nThis issue appears to be https://github.com/flutter/flutter/issues/58247.\n'+
globals.logger.terminal.bolden(
'Fix this issue by adding the following to the file ${gradleFile.path}:\n'
'android {\n'
' lintOptions {\n'
' checkReleaseBuilds false\n'
' }\n'
'}'
)
);
return GradleBuildStatus.exit;
},
eventLabel: 'transform-input-issue',
);
...@@ -30,6 +30,7 @@ void main() { ...@@ -30,6 +30,7 @@ void main() {
r8FailureHandler, r8FailureHandler,
androidXFailureHandler, androidXFailureHandler,
minSdkVersion, minSdkVersion,
transformInputIssue,
]) ])
); );
}); });
...@@ -688,6 +689,44 @@ assembleProfile ...@@ -688,6 +689,44 @@ assembleProfile
ProcessManager: () => FakeProcessManager.empty(), ProcessManager: () => FakeProcessManager.empty(),
}); });
}); });
// https://issuetracker.google.com/issues/141126614
group('transform input issue', () {
testWithoutContext('pattern', () {
expect(
transformInputIssue.test(
'https://issuetracker.google.com/issues/158753935'
),
isTrue,
);
});
testUsingContext('suggestion', () async {
await transformInputIssue.handler(
project: FlutterProject.fromDirectoryTest(globals.fs.currentDirectory),
);
expect(
testLogger.statusText,
contains(
'\n'
'This issue appears to be https://github.com/flutter/flutter/issues/58247.\n'
'Fix this issue by adding the following to the file /android/app/build.gradle:\n'
'android {\n'
' lintOptions {\n'
' checkReleaseBuilds false\n'
' }\n'
'}\n'
''
)
);
}, overrides: <Type, Generator>{
GradleUtils: () => FakeGradleUtils(),
Platform: () => fakePlatform('android'),
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.empty(),
});
});
} }
bool formatTestErrorMessage(String errorMessage, GradleHandledError error) { bool formatTestErrorMessage(String errorMessage, GradleHandledError error) {
......
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