Skip to content

Commit

Permalink
Remove support for imperative apply of Flutter Gradle Plugin (flutter…
Browse files Browse the repository at this point in the history
…#160947)

imperative apply has been deprecated since flutter#139690

part of flutter#121541

Doing this will make things easier for us during the conversion of
`flutter.groovy` into Kotlin.
  • Loading branch information
bartekpacia authored Jan 7, 2025
1 parent a3a4995 commit 4b23b81
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 656 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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.

pluginManagement {
val flutterSdkPath =
run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}

includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.7.0" apply false
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
}

include(":app", ":component1")
14 changes: 6 additions & 8 deletions packages/flutter_tools/gradle/app_plugin_loader.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
// 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
// This file existed solely for the compatibility with apps that have
// not migrated to the declarative apply of the Flutter App Plugin Loader Gradle Plugin.
// The old (imperative) apply of this plugin is not possible anymore.

logger.error("You are applying Flutter's app_plugin_loader 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/to/flutter-gradle-plugin-apply\n\
throw new GradleException("You are applying Flutter's app_plugin_loader Gradle plugin \
imperatively using the apply script method, which is not possible anymore. \
Migrate to applying Gradle plugins with the declarative plugins block: \
https://flutter.dev/to/flutter-gradle-plugin-apply\n\
")

def pathToThisDirectory = buildscript.sourceFile.parentFile
apply from: "$pathToThisDirectory/src/main/groovy/app_plugin_loader.groovy"
1 change: 0 additions & 1 deletion packages/flutter_tools/gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ gradlePlugin {
dependencies {
// When bumping, also update:
// * ndkVersion in FlutterExtension in packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
// * AGP version in the buildscript block in packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
// * AGP version in the buildscript block in packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts
// * AGP version constants in packages/flutter_tools/lib/src/android/gradle_utils.dart
compileOnly("com.android.tools.build:gradle:7.3.0")
Expand Down
15 changes: 7 additions & 8 deletions packages/flutter_tools/gradle/flutter.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// 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
// This file existed solely for the compatibility with apps that have
// not migrated to the declarative apply of the Flutter Gradle Plugin.
// The old (imperative) apply of this plugin is not possible anymore.

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/to/flutter-gradle-plugin-apply\n")

def pathToThisDirectory = buildscript.sourceFile.parentFile
apply from: "$pathToThisDirectory/src/main/groovy/flutter.groovy"
throw new GradleException("You are applying Flutter's main Gradle plugin imperatively using \
the apply script method, which is not possible anymore. \
Migrate to applying Gradle plugins with the declarative plugins block: \
https://flutter.dev/to/flutter-gradle-plugin-apply\n\
")
34 changes: 0 additions & 34 deletions packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -102,40 +102,6 @@ class FlutterExtension {
}
}

// This buildscript block supplies dependencies for this file's own import
// declarations above. It exists solely for compatibility with projects that
// have not migrated to declaratively apply the Flutter Gradle Plugin;
// for those that have, FGP's `build.gradle.kts` takes care of this.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
// When bumping, also update:
// * ndkVersion in FlutterExtension in packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
// * AGP version in the buildscript block in packages/flutter_tools/gradle/src/main/kotlin/dependency_version_checker.gradle.kts
// * AGP version constants in packages/flutter_tools/lib/src/android/gradle_utils.dart
// * AGP version in dependencies block in packages/flutter_tools/gradle/build.gradle.kts
classpath("com.android.tools.build:gradle:7.3.0")
}
}

/**
* Some apps don't set default compile options.
* Apps can change these values in the app-level Gradle build file
* (android/app/build.gradle or android/app/build.gradle.kts).
* This just ensures that default values are set.
*/
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

apply plugin: FlutterPlugin

class FlutterPlugin implements Plugin<Project> {

private static final String DEFAULT_MAVEN_HOST = "https://storage.googleapis.com"
Expand Down

This file was deleted.

Loading

0 comments on commit 4b23b81

Please sign in to comment.