Skip to content

Conversation

@gmackall
Copy link
Member

@gmackall gmackall commented Jun 3, 2024

The application of the dependency_version_checker gradle plugin is wrapped in a try catch, which prevented blocking the build in #149204. This pr re-throws the errors we intended to throw.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jun 3, 2024
@gmackall gmackall changed the title identify and re-throw our dependency checking errors Identify and re-throw our dependency checking errors in flutter.groovy Jun 3, 2024
@gmackall gmackall marked this pull request as ready for review June 3, 2024 19:38
@gmackall gmackall requested review from a team and bartekpacia June 3, 2024 19:39
project.apply from: dependencyCheckerPluginPath
} catch (Exception ignored) {
} catch (Exception e) {
// If the exception was thrown by us in the dependency version checker plugin then
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit gross as any change to that message would cause this unrelated code to fail.

Can you modify the exception to have a root class maybe and catch that root class and rethrow?

Copy link
Member

Choose a reason for hiding this comment

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

name idea: DependencyValidationException :P

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I agree it's pretty gross.

The reason I wrote it this way is that I thought at first that any exception class I wrote for use in the kotlin side (where we throw) wouldn't resolve in the groovy side (where we catch). But I think I'm mistaken about that, it just gets wrapped in a GradleException, so I'll still have to dig in like I am here, but won't have to rely on error message at least

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, this is still gross but hopefully less so.

I've made changes so that we have a DependencyValidationException defined in flutter.groovy, and then we throw that from within the kotlin file. We still catch broadly, because Gradle wraps our exception in a couple others, but now we test for that error class with instanceof.

@gmackall gmackall marked this pull request as draft June 3, 2024 20:15
@gmackall gmackall requested a review from reidbaker June 3, 2024 22:23
@gmackall gmackall marked this pull request as ready for review June 3, 2024 22:23
"dependency_version_checker.gradle.kts")
project.apply from: dependencyCheckerPluginPath
} catch (Exception ignored) {
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why can't we do something like the suggestion below this comment with multiple catch blocks? Is is a quirk of throwing an exception from kotlin to groovy?

Suggested change
} catch (Exception e) {
} catch (DependencyValidationException e) {
// Rethrow
} catch (Exception e) {
// eat exception Do other code path.
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Is is a quirk of throwing an exception from kotlin to groovy?

Yes, that is correct. The DependencyValidationException gets wrapped in a couple of GradleExceptions

Copy link
Member

Choose a reason for hiding this comment

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

I think when the Gradle plugin is fully rewritten to Kotlin, then we'll no longer have to depend on such hacks, right?

Copy link
Member Author

@gmackall gmackall Jun 4, 2024

Choose a reason for hiding this comment

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

Correct. I also haven't looked too far into this, but I think when the full re-write happens it can also be done in actual Kotlin source, and not Kotlin script (I believe AGP is written this way https://android.googlesource.com/platform/tools/base/+/1839aa23b8dc562005e2f0f0cc8e8b4c5caa37d0/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/utils/agpVersionChecker.kt)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's my understanding as well (Kotlin "proper" instead of kts). Sweet!

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 4, 2024
@auto-submit auto-submit bot merged commit 9d1de7b into flutter:master Jun 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 5, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jun 5, 2024
flutter/flutter@c246ecd...27e0656

2024-06-05 98614782+auto-submit[bot]@users.noreply.github.com Reverts "TreeSliver & associated classes (#147171)" (flutter/flutter#149754)
2024-06-05 [email protected] Feature: Add AnimatedList with separators (flutter/flutter#144899)
2024-06-05 [email protected] make output of flutter run web tests verbose (flutter/flutter#149694)
2024-06-05 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Request focus if `SemanticsAction.focus` is sent to a focusable widget (#142942)" (flutter/flutter#149741)
2024-06-05 [email protected] Roll Flutter Engine from e88469090fed to 11a32d43e3f6 (2 revisions) (flutter/flutter#149699)
2024-06-05 [email protected] Request focus if `SemanticsAction.focus` is sent to a focusable widget (flutter/flutter#142942)
2024-06-04 [email protected] Roll Flutter Engine from 3dd40156afb6 to e88469090fed (2 revisions) (flutter/flutter#149695)
2024-06-04 [email protected] TreeSliver & associated classes (flutter/flutter#147171)
2024-06-04 [email protected] Roll Flutter Engine from fe00f023666c to 3dd40156afb6 (3 revisions) (flutter/flutter#149692)
2024-06-04 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.7 to 3.25.8 (flutter/flutter#149691)
2024-06-04 [email protected] Prepares semantics_update_test for upcoming heading level changes (flutter/flutter#149671)
2024-06-04 [email protected] Identify and re-throw our dependency checking errors in `flutter.groovy` (flutter/flutter#149609)
2024-06-04 [email protected] Scrollbar thumb drag gestures now produce one start and one end scroll notification (flutter/flutter#146654)
2024-06-04 [email protected] Disable sandboxing for macOS apps and tests in CI (flutter/flutter#149618)
2024-06-04 [email protected] Roll Flutter Engine from e211c43f3dc1 to fe00f023666c (3 revisions) (flutter/flutter#149680)
2024-06-04 [email protected] Allow `find.byTooltip` to use a RegEx (flutter/flutter#149348)
2024-06-04 [email protected] Roll Flutter Engine from a6aa5d826649 to e211c43f3dc1 (8 revisions) (flutter/flutter#149658)

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
Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

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

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@gmackall
Copy link
Member Author

gmackall commented Jun 7, 2024

Reason for revert: Long spam in certain circumstances:

e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:238:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:263:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:288:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:313:23: Unresolved reference: DependencyValidationException
Warning: Flutter was unable to detect project Gradle, Java, AGP, and KGP versions. Skipping dependency version checking. Error was: org.gradle.internal.exceptions.LocationAwareException: Script '/Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts' line: 238
Script compilation errors:

  Line 238:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

  Line 263:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

  Line 288:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

  Line 313:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

@gmackall gmackall added the revert Autorevert PR (with "Reason for revert:" comment) label Jun 7, 2024
@auto-submit
Copy link
Contributor

auto-submit bot commented Jun 7, 2024

Time to revert pull request flutter/flutter/149609 has elapsed.
You need to open the revert manually and process as a regular pull request.

@auto-submit auto-submit bot removed the revert Autorevert PR (with "Reason for revert:" comment) label Jun 7, 2024
gmackall pushed a commit to gmackall/flutter that referenced this pull request Jun 7, 2024
auto-submit bot pushed a commit that referenced this pull request Jun 7, 2024
…ter.groovy` (#149609)" (#149918)

This reverts commit 9d1de7b.

Reverts due to log spam and crashing of the dependency version checker (which doesn't block the build but still isn't the desired outcome).
gmackall pushed a commit to gmackall/flutter that referenced this pull request Jun 12, 2024
auto-submit bot pushed a commit that referenced this pull request Jun 13, 2024
…er.groovy" (#150128)

The original approach in #149609 didn't work when the Flutter Gradle plugin was applied using the deprecated script apply - the kotlin portion couldn't resolve the custom exception defined in `flutter.groovy`:
```
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:238:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:263:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:288:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:313:23: Unresolved reference: DependencyValidationException
Warning: Flutter was unable to detect project Gradle, Java, AGP, and KGP versions. Skipping dependency version checking. Error was: org.gradle.internal.exceptions.LocationAwareException: Script '/Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts' line: 238
Script compilation errors:

  Line 238:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

  Line 263:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

  Line 288:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

  Line 313:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException
```

This new approach of setting one of the [`extra` properties](https://docs.gradle.org/current/dsl/org.gradle.api.Project.html#N14FF7) works in both cases (tested with the `camera_android` example app, which uses the script apply, and a freshly created counter app). 

It also removes some brittleness in that we don't have to unwrap the exception anymore, and aren't subject to breaking if Gradle decides one day to wrap our custom exception 1 layer deeper in additional exceptions.
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request Jun 14, 2024
…er.groovy" (flutter#150128)

The original approach in flutter#149609 didn't work when the Flutter Gradle plugin was applied using the deprecated script apply - the kotlin portion couldn't resolve the custom exception defined in `flutter.groovy`:
```
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:238:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:263:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:288:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:313:23: Unresolved reference: DependencyValidationException
Warning: Flutter was unable to detect project Gradle, Java, AGP, and KGP versions. Skipping dependency version checking. Error was: org.gradle.internal.exceptions.LocationAwareException: Script '/Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts' line: 238
Script compilation errors:

  Line 238:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

  Line 263:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

  Line 288:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

  Line 313:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException
```

This new approach of setting one of the [`extra` properties](https://docs.gradle.org/current/dsl/org.gradle.api.Project.html#N14FF7) works in both cases (tested with the `camera_android` example app, which uses the script apply, and a freshly created counter app). 

It also removes some brittleness in that we don't have to unwrap the exception anymore, and aren't subject to breaking if Gradle decides one day to wrap our custom exception 1 layer deeper in additional exceptions.
victorsanni pushed a commit to victorsanni/flutter that referenced this pull request Jun 14, 2024
…er.groovy" (flutter#150128)

The original approach in flutter#149609 didn't work when the Flutter Gradle plugin was applied using the deprecated script apply - the kotlin portion couldn't resolve the custom exception defined in `flutter.groovy`:
```
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:238:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:263:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:288:23: Unresolved reference: DependencyValidationException
e: /Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts:313:23: Unresolved reference: DependencyValidationException
Warning: Flutter was unable to detect project Gradle, Java, AGP, and KGP versions. Skipping dependency version checking. Error was: org.gradle.internal.exceptions.LocationAwareException: Script '/Users/mackall/development/flutter/flutter/packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts' line: 238
Script compilation errors:

  Line 238:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

  Line 263:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

  Line 288:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException

  Line 313:                 throw DependencyValidationException(errorMessage)
                                  ^ Unresolved reference: DependencyValidationException
```

This new approach of setting one of the [`extra` properties](https://docs.gradle.org/current/dsl/org.gradle.api.Project.html#N14FF7) works in both cases (tested with the `camera_android` example app, which uses the script apply, and a freshly created counter app). 

It also removes some brittleness in that we don't have to unwrap the exception anymore, and aren't subject to breaking if Gradle decides one day to wrap our custom exception 1 layer deeper in additional exceptions.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants