Skip to content

Android: Add failOnWarnings check to android build.gradle and configure lint as warnings as error #12040

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Sangamesh1997
Copy link

@Sangamesh1997 Sangamesh1997 commented Apr 28, 2025

Android: Add failOnWarnings check to android build.gradle and configure lint as warnings as error.

Fixes: #6868

@Sangamesh1997 Sangamesh1997 marked this pull request as draft April 28, 2025 04:39
@Sangamesh1997 Sangamesh1997 marked this pull request as ready for review April 28, 2025 04:52
@Sangamesh1997 Sangamesh1997 marked this pull request as draft April 28, 2025 10:05
@Sangamesh1997
Copy link
Author

@vinodhabib Please review and share feedback on any changes or improvements needed.

Copy link
Contributor

@vinodhabib vinodhabib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM.

@Sangamesh1997 Sangamesh1997 marked this pull request as ready for review April 29, 2025 05:05
Copy link
Member

@shivaspeaks shivaspeaks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've done both (linter warnings and enabling -Werror) the mentioned issues in this PR. That's fine for me. @ejona86 should be able to tell us if we shouldn't be doing like this.

lintOptions { abortOnError true }

// fail on android lint warnings if failOnWarning is set true
lintOptions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are doing this anyway, lintOptions is deprecated. Use lint instead. (Wait for Eric's comment on this before working)

@@ -44,6 +52,14 @@ dependencies {
testImplementation libraries.truth
}

// Enforce -Werror on java compiler if failOnWarning is set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may remove the comments as they are self explanatory.

@shivaspeaks shivaspeaks requested a review from ejona86 April 30, 2025 07:12
@ejona86 ejona86 added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Apr 30, 2025
@grpc-kokoro grpc-kokoro removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Apr 30, 2025
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is adding it to grpc-android only. We actually want this on all android-related builds, which would include android-interop-testing, binder, and cronet as well. For that, the configuration should go in build.gradle and activate when the plugins com.android.application or com.android.library are used. You would use plugins.withId() for that, similar to the existing plugins.withId("java") and similar blocks. The easiest way may be to use plugins.withId("com.android.base"), which is the base plugin for both library and application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Teach Android build -PfailOnWarnings=true
5 participants