Skip to content

[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

Merged
merged 4 commits into from
Dec 2, 2020

Conversation

jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Dec 1, 2020

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:

jonahwilliams-macbookpro2% flutter build apk           
Building flutter tool...                                          
Running "flutter pub get" in hello_world...                        432ms
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
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
lib/main.dart:6:1: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
Try adding the name of the type of the variable or the keyword 'var'.   
x;                                                                      
^                                                                       
                                                                        
                                                                        
FAILURE: Build failed with an exception.                                
                                                                        
* Where:                                                                
Script '/Users/jonahwilliams/Documents/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 900
                                                                        
* What went wrong:                                                      
Execution failed for task ':app:compileFlutterBuildRelease'.            
> Process 'command '/Users/jonahwilliams/Documents/flutter/bin/flutter'' finished with non-zero exit value 1
                                                                        
* 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 5s                                                      
Running Gradle task 'assembleRelease'...                                
Running Gradle task 'assembleRelease'... Done                       5.9s
Gradle task assembleRelease failed with exit code 1

After:

jonahwilliams-macbookpro2% flutter build apk
Building flutter tool...                                          
Running "flutter pub get" in hello_world...                        437ms
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
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
lib/main.dart:7:1: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
Try adding the name of the type of the variable or the keyword 'var'.   
x;                                                                      
^                                                                       
                                                                        
                                                                        
Running Gradle task 'assembleRelease'...                                
Running Gradle task 'assembleRelease'... Done                       6.1s
Gradle task assembleRelease failed with exit code 1

Fixes #13466
Fixes #69022
Fixes #58337
Fixes #39201

@google-cla google-cla bot added the cla: yes label Dec 1, 2020
@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Dec 1, 2020
@jonahwilliams jonahwilliams marked this pull request as ready for review December 1, 2020 20:30
'''.split('\n');

void main() {
testUsingContext('Does not print failure footer in non-verbose mode', () async {
Copy link
Member

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)) {
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

@jonahwilliams jonahwilliams merged commit d688b52 into flutter:master Dec 2, 2020
@jonahwilliams jonahwilliams deleted the remove_gradle_footer branch December 2, 2020 01:13
jonahwilliams pushed a commit that referenced this pull request Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy