Skip to content

[tool] Add initial gradle validation command #3715

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 7 commits into from
Apr 17, 2023

Conversation

stuartmorgan-g
Copy link
Contributor

Adds a repo tool command to validate that all plugins set an explicit Java compatibility version, instead of using whatever the local toolchain happens to be (which creates the potential for issues like flutter/flutter#124839 where our CI passes but builds fail for some clients because our default is newer than theirs).

Currently that's all it checks, but we can add any other gradle best practices we want to enforce here in the future.

This also enables the new check in CI, and fixes all the violations it found.

Fixes flutter/flutter#124839

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

@stuartmorgan-g
Copy link
Contributor Author

This will obsolete #3712 if it's ready to land before that gets a no-test exception.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know changing file names can be a pain but can we name this something more specific. I think we will have more gradle checks moving forward. Maybe gradle_conventions_check_command

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was assuming that future gradle checks would be added here; is there a reason we'd want new commands for those instead of having them all here? If you look at things like pubspec-check, we do a bunch of different checks related to the file in the one command.

Copy link
Contributor

Choose a reason for hiding this comment

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

So I had assumed that this command was only for the gradle files at the top of packages since that was what was parsed. Basically the implementation was the behavior you desired but the documentation was incorrect. Based on this update if all checks will live in this file then then the name makes sense.

import 'common/package_looping_command.dart';
import 'common/repository_package.dart';

/// A command to enforce gradle file conventions and best practices.
Copy link
Contributor

@reidbaker reidbaker Apr 14, 2023

Choose a reason for hiding this comment

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

This is not true based on the implementation. I think this will only impact topline gradle files and does not check gradle files in app.

Also from a structural perspective I think you might want to logically separate example gradle files from gradle files of plugins that are published.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this will only impact topline gradle files and does not check gradle files in app.

This is currently true, because the check I've added didn't seem important for apps. If that's not the case we can definitely change that.

Also from a structural perspective I think you might want to logically separate example gradle files from gradle files of plugins that are published.

Yes, that's why I have it only iterating over top-level packages, rather than setting the command to iterate over everything. My thought was that we could add example checks later, but I can definitely implement the structure for that now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It now iterates over everything, and just skips the current check for examples, so it will be easy to add things for all gradle files later.

(Let me know if you want this specific check to run for examples; currently it's not even in the flutter template for apps.)

@stuartmorgan-g stuartmorgan-g changed the title Tool gradle validation [tool] Add initial gradle validation command Apr 14, 2023
Copy link
Contributor

Choose a reason for hiding this comment

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

So I had assumed that this command was only for the gradle files at the top of packages since that was what was parsed. Basically the implementation was the behavior you desired but the documentation was incorrect. Based on this update if all checks will live in this file then then the name makes sense.

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 17, 2023
@auto-submit auto-submit bot merged commit a4ced6b into flutter:main Apr 17, 2023
@stuartmorgan-g stuartmorgan-g deleted the tool-gradle-validation branch April 18, 2023 13:56
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 18, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Apr 18, 2023
flutter/packages@0277f2a...faf53fb

2023-04-18 engine-flutter-autoroll@skia.org Manual roll Flutter from 50171bb to 15cb1f8 (9 revisions) (flutter/packages#3749)
2023-04-17 reidbaker@google.com [palette_generator] run agp update for example (flutter/packages#3747)
2023-04-17 47866232+chunhtai@users.noreply.github.com [go_router] Fixes a bug that go_router would crash if pageBuilder depends on InheritedWidgets.s. (flutter/packages#3714)
2023-04-17 49699333+dependabot[bot]@users.noreply.github.com [pigeon]: Bump com.android.tools.build:gradle from 7.3.1 to 8.0.0 in /packages/pigeon/platform_tests/alternate_language_test_plugin/android (flutter/packages#3727)
2023-04-17 49699333+dependabot[bot]@users.noreply.github.com [pigeon]: Bump com.android.tools.build:gradle from 7.3.1 to 8.0.0 in /packages/pigeon/platform_tests/test_plugin/android (flutter/packages#3726)
2023-04-17 49699333+dependabot[bot]@users.noreply.github.com [pigeon]: Bump io.mockk:mockk from 1.13.4 to 1.13.5 in /packages/pigeon/platform_tests/test_plugin/android (flutter/packages#3725)
2023-04-17 stuartmorgan@google.com [tool] Add initial gradle validation command (flutter/packages#3715)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com,rmistry@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
Adds a repo tool command to validate that all plugins set an explicit Java compatibility version, instead of using whatever the local toolchain happens to be (which creates the potential for issues like flutter/flutter#124839 where our CI passes but builds fail for some clients because our default is newer than theirs).

Currently that's all it checks, but we can add any other gradle best practices we want to enforce here in the future.

This also enables the new check in CI, and fixes all the violations it found.

Fixes flutter/flutter#124839
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[shared_preferences] not supported in -source 7 errors building on Android
2 participants