flutter/packages/flutter_tools/gradle/flutter.gradle
Bartek Pacia a1e1dc3f6c
Reland "Warn when Gradle plugins are applied using the legacy apply script method (#140103)
> This PR relands #139690 which was reverted in #140102

This PR adds a deprecation message when Android build is using the legacy "apply script method" way of applying Flutter's Gradle plugins (that is: [`flutter.gradle`](https://github.com/flutter/flutter/blob/3.16.0/packages/flutter_tools/gradle/flutter.gradle) and [`app_plugin_loader.gradle`](https://github.com/flutter/flutter/blob/3.16.0/packages/flutter_tools/gradle/app_plugin_loader.gradle)).

See also:
- #121541
  - in particular https://github.com/flutter/flutter/issues/121541#issuecomment-1836947311
- #135392
  - and PR that add the migration guide: [#9857](https://github.com/flutter/website/pull/9857)

- I think either `logger.error` or `logger.quiet` must be used, because all other error levels are not shown during `flutter build apk` (and that's what most people use).
2023-12-19 16:03:23 +00:00

15 lines
734 B
Groovy

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file exists solely for the compatibility with projects that have
// not migrated to the declarative apply of the Flutter Gradle Plugin.
logger.error("You are applying Flutter's main Gradle plugin imperatively using \
the apply script method, which is deprecated and will be removed in a future \
release. Migrate to applying Gradle plugins with the declarative plugins \
block: https://flutter.dev/go/flutter-gradle-plugin-apply\n")
def pathToThisDirectory = buildscript.sourceFile.parentFile
apply from: "$pathToThisDirectory/src/main/groovy/flutter.groovy"