Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FSSDK-10374] chore: migration of flutter's gradle plugins #74

Merged
merged 4 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 10 additions & 19 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
plugins {
id "com.android.library"
}

group 'com.optimizely.optimizely_flutter_sdk'
version '1.0'

buildscript {

def version_name = System.getenv('TRAVIS_TAG')
if (version_name != null) {
rootProject.ext.version_name = version_name
} else {
rootProject.ext.version_name = 'debugVersion'
}

repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
}
def version_name = System.getenv('TRAVIS_TAG')
if (version_name != null) {
rootProject.ext.version_name = version_name
} else {
rootProject.ext.version_name = 'debugVersion'
}

configurations {
all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}
Expand All @@ -29,7 +22,6 @@ rootProject.allprojects {
}
}

apply plugin: 'com.android.library'

ext {
compile_sdk_version = 32
Expand Down Expand Up @@ -71,7 +63,6 @@ android {

}


dependencies {
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
Expand Down
20 changes: 11 additions & 9 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@

plugins {
id "com.android.application"
id "org.jetbrains.kotlin.android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +13,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,10 +23,6 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 32
ndkVersion flutter.ndkVersion
Expand Down Expand Up @@ -57,3 +55,7 @@ android {
flutter {
source '../..'
}

dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
14 changes: 2 additions & 12 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
ext {
android_sdk_version = "4.0.0"
}

allprojects {
repositories {
google()
Expand All @@ -28,6 +18,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
39 changes: 31 additions & 8 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}

settings.ext.flutterSdkPath = flutterSdkPath()
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
resolutionStrategy {
eachPlugin {
if (requested.id.namespace == 'dev.flutter') {
useModule("dev.flutter:${requested.id.name}:${requested.version}")
}
}
}
}

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.2.1" apply false
id "org.jetbrains.kotlin.android" version "1.6.10" apply false
}

include ":app"

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