-
-
Save ramah/32997bf5f69cd6827f2cdc05b5114d44 to your computer and use it in GitHub Desktop.
Flutter Kotlin Gradle DSL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Properties | |
import java.nio.file.Files | |
val localProperties = Properties() | |
val localPropertiesFile = rootProject.file("local.properties").toPath() | |
if (Files.exists(localPropertiesFile)) { | |
Files.newBufferedReader(localPropertiesFile).use { reader -> | |
localProperties.load(reader) | |
} | |
} | |
val flutterRoot = localProperties.getProperty("flutter.sdk") | |
?: throw GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") | |
val flutterVersionCode = localProperties.getProperty("flutter.versionCode") ?: "1" | |
val flutterVersionName = localProperties.getProperty("flutter.versionName") ?: "1.0" | |
plugins { | |
id("com.android.application") | |
kotlin("android") | |
kotlin("android.extensions") | |
} | |
apply("$flutterRoot/packages/flutter_tools/gradle/flutter.gradle") | |
android { | |
compileSdkVersion(30) | |
lintOptions { | |
disable("InvalidPackage") | |
} | |
defaultConfig { | |
applicationId = "com.linkdesk.android.automator" | |
minSdkVersion(23) | |
targetSdkVersion(30) | |
versionCode = flutterVersionCode.toInt() | |
versionName = flutterVersionName | |
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | |
} | |
signingConfigs { | |
create("release") { | |
storeFile = file("<>") | |
storePassword = "<>" | |
keyAlias = "<>" | |
keyPassword = "<>" | |
} | |
} | |
buildTypes { | |
getByName("release") { | |
// Signing with the debug keys for now, so `flutter run --release` works. | |
signingConfig = signingConfigs.getByName("release") | |
} | |
} | |
buildToolsVersion = "29.0.3" | |
compileOptions { | |
sourceCompatibility = JavaVersion.VERSION_1_8 | |
targetCompatibility = JavaVersion.VERSION_1_8 | |
} | |
kotlinOptions { | |
jvmTarget = "1.8" | |
} | |
} | |
project.extensions.getByName("flutter").apply { | |
this::class.java.getMethod("source", String::class.java).invoke(this, "../..") | |
} | |
dependencies { | |
testImplementation("junit:junit:4.13") | |
androidTestImplementation("androidx.test.ext:junit:1.1.1") | |
androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0") | |
implementation("androidx.core:core-ktx:1.3.1") | |
implementation(kotlin("stdlib-jdk7")) | |
} | |
apply(plugin = "io.fabric") | |
// Google Play services Gradle plugin | |
apply(plugin = "com.google.gms.google-services") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
extra.set("kotlin_version", "1.3.72") | |
repositories { | |
google() | |
jcenter() | |
maven("https://maven.fabric.io/public") | |
} | |
dependencies { | |
classpath("com.android.tools.build:gradle:4.0.1") | |
classpath("com.google.gms:google-services:4.3.3") // Google Services plugin | |
classpath(kotlin("gradle-plugin", version = "1.3.72")) | |
} | |
} | |
allprojects { | |
repositories { | |
google() | |
jcenter() | |
} | |
} | |
rootProject.buildDir = file("../build") | |
subprojects { | |
project.buildDir = file("${rootProject.buildDir}/${project.name}") | |
project.evaluationDependsOn(":app") | |
} | |
tasks { | |
task<Delete>("clean") { | |
delete( rootProject.buildDir) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.file.Files | |
import java.util.* | |
include(":app") | |
val flutterProjectRoot = rootDir.toPath().parent | |
val plugins = Properties() | |
val pluginsFile = flutterProjectRoot.resolve(".flutter-plugins") | |
if (Files.exists(pluginsFile)) { | |
Files.newBufferedReader(pluginsFile).use { plugins.load(it) } | |
} | |
plugins.forEach { name, path -> | |
val pluginDirectory = flutterProjectRoot.resolve(path as String).resolve("android") | |
include(":$name") | |
project(":$name").projectDir = pluginDirectory.toFile() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment