Skip to content

Commit 25ee944

Browse files
[FSSDK-10374] chore: migration of flutter's gradle plugins (#74)
1 parent eec8fdb commit 25ee944

File tree

4 files changed

+54
-48
lines changed

4 files changed

+54
-48
lines changed

android/build.gradle

+10-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
1+
plugins {
2+
id "com.android.library"
3+
}
4+
15
group 'com.optimizely.optimizely_flutter_sdk'
26
version '1.0'
37

4-
buildscript {
5-
6-
def version_name = System.getenv('TRAVIS_TAG')
7-
if (version_name != null) {
8-
rootProject.ext.version_name = version_name
9-
} else {
10-
rootProject.ext.version_name = 'debugVersion'
11-
}
12-
13-
repositories {
14-
google()
15-
mavenCentral()
16-
}
17-
18-
dependencies {
19-
classpath 'com.android.tools.build:gradle:7.2.1'
20-
}
8+
def version_name = System.getenv('TRAVIS_TAG')
9+
if (version_name != null) {
10+
rootProject.ext.version_name = version_name
11+
} else {
12+
rootProject.ext.version_name = 'debugVersion'
2113
}
14+
2215
configurations {
2316
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
2417
}
@@ -29,7 +22,6 @@ rootProject.allprojects {
2922
}
3023
}
3124

32-
apply plugin: 'com.android.library'
3325

3426
ext {
3527
compile_sdk_version = 32
@@ -71,7 +63,6 @@ android {
7163

7264
}
7365

74-
7566
dependencies {
7667
implementation 'androidx.multidex:multidex:2.0.0'
7768
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

example/android/app/build.gradle

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2+
plugins {
3+
id "com.android.application"
4+
id "org.jetbrains.kotlin.android"
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,10 +23,6 @@ if (flutterVersionName == null) {
2123
flutterVersionName = '1.0'
2224
}
2325

24-
apply plugin: 'com.android.application'
25-
apply plugin: 'kotlin-android'
26-
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27-
2826
android {
2927
compileSdkVersion 32
3028
ndkVersion flutter.ndkVersion
@@ -57,3 +55,7 @@ android {
5755
flutter {
5856
source '../..'
5957
}
58+
59+
dependencies {
60+
implementation 'com.android.support:multidex:1.0.3'
61+
}

example/android/build.gradle

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
buildscript {
2-
ext.kotlin_version = '1.6.10'
3-
repositories {
4-
google()
5-
mavenCentral()
6-
}
71

8-
dependencies {
9-
classpath 'com.android.tools.build:gradle:7.2.1'
10-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
}
12-
}
132
ext {
143
android_sdk_version = "4.0.0"
154
}
5+
166
allprojects {
177
repositories {
188
google()
@@ -28,6 +18,6 @@ subprojects {
2818
project.evaluationDependsOn(':app')
2919
}
3020

31-
task clean(type: Delete) {
21+
tasks.register("clean", Delete) {
3222
delete rootProject.buildDir
3323
}

example/android/settings.gradle

+31-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
1-
include ':app'
1+
pluginManagement {
2+
def flutterSdkPath = {
3+
def properties = new Properties()
4+
file("local.properties").withInputStream { properties.load(it) }
5+
def flutterSdkPath = properties.getProperty("flutter.sdk")
6+
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
7+
return flutterSdkPath
8+
}
9+
10+
settings.ext.flutterSdkPath = flutterSdkPath()
11+
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
212

3-
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4-
def properties = new Properties()
13+
repositories {
14+
google()
15+
mavenCentral()
16+
gradlePluginPortal()
17+
}
18+
resolutionStrategy {
19+
eachPlugin {
20+
if (requested.id.namespace == 'dev.flutter') {
21+
useModule("dev.flutter:${requested.id.name}:${requested.version}")
22+
}
23+
}
24+
}
25+
}
526

6-
assert localPropertiesFile.exists()
7-
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
27+
plugins {
28+
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
29+
id "com.android.application" version "7.2.1" apply false
30+
id "org.jetbrains.kotlin.android" version "1.6.10" apply false
31+
}
32+
33+
include ":app"
834

9-
def flutterSdkPath = properties.getProperty("flutter.sdk")
10-
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11-
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

0 commit comments

Comments
 (0)