-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[flutter_tools] post process the gradle log output #71499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flutter_tools] post process the gradle log output #71499
Conversation
'''.split('\n'); | ||
|
||
void main() { | ||
testUsingContext('Does not print failure footer in non-verbose mode', () async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these tests need the context?
// All gradle failures lead to a fairly long footer which contains mostly | ||
// irrelevant information for a flutter build, along with misleading advice to | ||
// run with --stacktrace (which does not exist for the flutter CLI). remove this. | ||
if (!verbose && (line.startsWith('FAILURE: Build failed with an exception.') || atFailureFooter)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way split on output that we control instead of a line from gradle? Like could the tool emit a known line from the recursive call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate a bit on what that would be used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, just taking a possibly naive look at the example 'before' output in the PR description, we have:
[lines emitted by the tool or the Dart compiler]
FAILURE: Build failed with an exception. [First line emitted by gradle?]
[more lines emitted by gradle]
[more lines emitted by the tool]
Instead of detecting gradle output using the first line emitted by gradle, which we don't control, the idea would be to detect gradle output using the last line of [lines emitted by the tool or the Dart compiler]
, which we do control, adding a new sentinel line there if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't hide all Gradle output though. For example, a compilation error in the users Java code:
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
/Users/jonahwilliams/Documents/flutter/dev/integration_tests/flutter_gallery/android/app/src/main/java/io/flutter/demo/gallery/MainActivity.java:11: error: '{' expected
public class MainActivity extends FlutterActivity
^
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 55s
We still want to chop off the footer since it is wrong, but we need to show the output from the javac task
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay. Got it. Thanks.
This reverts commit d688b52.
Description
The gradle error footer is super confusing, because it looks like a tool crash and refers to flags that do not exist on the flutter tool. Just remove it entirely on non-verbose builds.
Before:
After:
Fixes #13466
Fixes #69022
Fixes #58337
Fixes #39201