Skip to content

Conversation

@gmackall
Copy link
Member

@gmackall gmackall commented Jun 12, 2024

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 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.

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 12, 2024
+ ignored)
} catch (Exception e) {

if (!project.failedDependencyChecks) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This if statement is a bit difficult to read since you are negating "failed" then logging an error.

Suggested change
if (!project.failedDependencyChecks) {
// Exception means something went wrong.
if (project.failedToCheckDependencies) {
// Possible bug in dependency checking code warn and do not block build.
...
} else {
// If failedToCheckDependencies is unset or false then the exception is thrown by us and/or an an error that should block the build.
throw e.
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Made the property a constant, and changed it to usesUnsupportedDependencyVersions so that the check reads better as:

if (!project.usesUnsupportedDependencyVersions) {
...
} else {
...
}

Gray Mackall added 2 commits June 13, 2024 12:05
@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 13, 2024
@gmackall
Copy link
Member Author

cc @bartekpacia - no action needed, just figured you might be interested in the reason for the revert+reland as it relates to the work of re-writing the FGP to Kotlin.

@auto-submit auto-submit bot merged commit 7e97cf7 into flutter:master Jun 13, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 14, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jun 14, 2024
flutter/flutter@01db23b...349ec71

2024-06-14 [email protected] Add tests for navigator.0.dart (flutter/flutter#150034)
2024-06-14 [email protected] Switch to `Iterable.cast` instance method (flutter/flutter#150185)
2024-06-14 [email protected] Include transform in static Gradient lerp methods (flutter/flutter#149624)
2024-06-14 [email protected] Validate the `contrastLevel` during `ColorScheme` creation (flutter/flutter#150176)
2024-06-14 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.9 to 3.25.10 (flutter/flutter#150228)
2024-06-13 [email protected] Fix leaky test. (flutter/flutter#150235)
2024-06-13 [email protected] Document CIPD role & login for upgrading Android engine (flutter/flutter#149433)
2024-06-13 [email protected] Update doc for `ColorScheme.surface` (flutter/flutter#150212)
2024-06-13 [email protected] Roll pub packages (flutter/flutter#150206)
2024-06-13 [email protected] Bump new release for a11y_assessment (flutter/flutter#150213)
2024-06-13 [email protected] Use --(no-)strip-wams instead of --(no-)-name-section in `dart compile wasm` (flutter/flutter#149641)
2024-06-13 [email protected] Reland "Identify and re-throw our dependency checking errors in flutter.groovy" (flutter/flutter#150128)
2024-06-13 [email protected] Use --(no-)strip-wams instead of --(no-)-name-section in `dart compile wasm` (flutter/flutter#150180)
2024-06-13 [email protected] Suppress Flutter update check if `--machine` is present at all. (flutter/flutter#150138)
2024-06-13 [email protected] [Reland] Introduce `ChipAnimationStyle` to override default chips animations durations (flutter/flutter#149876)
2024-06-13 [email protected] Update framework and flutter fix flutter.dev/docs links (flutter/flutter#150174)
2024-06-13 [email protected] Roll Flutter Engine from 4cb3025d3abf to 8167dffd1914 (2 revisions) (flutter/flutter#150208)
2024-06-13 [email protected] Replace InputDecorator M3 golden test (flutter/flutter#150111)
2024-06-13 [email protected] Roll Packages from 260102b to 7805455 (2 revisions) (flutter/flutter#150198)

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

@bartekpacia bartekpacia left a comment

Choose a reason for hiding this comment

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

That's an interesting approach! Thanks for the ping :-)

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