Skip to content

Commit

Permalink
Use declarative plugins {} block
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamVe committed Nov 23, 2023
1 parent 8aadd6d commit 72b4c95
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 23 deletions.
23 changes: 9 additions & 14 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlinx-serialization'
id 'dev.flutter.flutter-gradle-plugin'
id 'com.google.android.gms.oss-licenses-plugin'
}

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

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

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
//noinspection GroovyUnusedAssignment
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
//noinspection GroovyUnusedAssignment
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlinx-serialization'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.android.gms.oss-licenses-plugin'

import com.android.build.OutputFile

android {
Expand Down Expand Up @@ -75,7 +70,7 @@ android {
abortOnError false
}

applicationVariants.all { variant ->
applicationVariants.configureEach { variant ->
variant.outputs.each { output ->
def abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3, x86_64: 4]
def abiCode = abiCodes.get(output.getFilter(OutputFile.ABI))
Expand Down
1 change: 0 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.6'
Expand Down
30 changes: 22 additions & 8 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
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()

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

assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

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"
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.1.4" apply false
}

include ":app"

0 comments on commit 72b4c95

Please sign in to comment.