Skip to content

Commit 393fa45

Browse files
committed
🚀 Migrate new Gradle scripts
1 parent 3ffa737 commit 393fa45

File tree

3 files changed

+30
-31
lines changed

3 files changed

+30
-31
lines changed

example/android/app/build.gradle

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
id "kotlin-kapt"
5+
id "dev.flutter.flutter-gradle-plugin"
6+
}
7+
18
def localProperties = new Properties()
29
def localPropertiesFile = rootProject.file('local.properties')
310
if (localPropertiesFile.exists()) {
@@ -6,11 +13,6 @@ if (localPropertiesFile.exists()) {
613
}
714
}
815

9-
def flutterRoot = localProperties.getProperty('flutter.sdk')
10-
if (flutterRoot == null) {
11-
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12-
}
13-
1416
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
1517
if (flutterVersionCode == null) {
1618
flutterVersionCode = '1'
@@ -21,11 +23,6 @@ if (flutterVersionName == null) {
2123
flutterVersionName = '1.0'
2224
}
2325

24-
apply plugin: 'com.android.application'
25-
apply plugin: 'kotlin-android'
26-
apply plugin: 'kotlin-kapt'
27-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
28-
2926
android {
3027
namespace "com.fluttercandies.wechatCameraPickerExample"
3128

example/android/build.gradle

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
buildscript {
2-
ext.kotlin_version = '1.9.20'
3-
repositories {
4-
google()
5-
mavenCentral()
6-
}
7-
8-
dependencies {
9-
classpath 'com.android.tools.build:gradle:8.2.2'
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
}
12-
}
13-
141
allprojects {
152
repositories {
163
google()

example/android/settings.gradle

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,29 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
include ':app'
5+
pluginManagement {
6+
def flutterSdkPath = {
7+
def properties = new Properties()
8+
file("local.properties").withInputStream { properties.load(it) }
9+
def flutterSdkPath = properties.getProperty("flutter.sdk")
10+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11+
return flutterSdkPath
12+
}
13+
settings.ext.flutterSdkPath = flutterSdkPath()
614

7-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
8-
def properties = new Properties()
15+
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
916

10-
assert localPropertiesFile.exists()
11-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
17+
repositories {
18+
google()
19+
mavenCentral()
20+
gradlePluginPortal()
21+
}
22+
}
1223

13-
def flutterSdkPath = properties.getProperty("flutter.sdk")
14-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
15-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
24+
plugins {
25+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
26+
id "com.android.application" version "8.2.2" apply false
27+
id "org.jetbrains.kotlin.android" version "1.9.20" apply false
28+
}
29+
30+
include ":app"

0 commit comments

Comments
 (0)