-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from JunJaBoy/main
Migrate to Kotlin DSL (Android build script)
- Loading branch information
Showing
6 changed files
with
176 additions
and
156 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import java.nio.charset.Charset | ||
import java.util.Properties | ||
import java.io.FileInputStream | ||
|
||
val localProperties = Properties().apply { | ||
rootProject.file("local.properties").bufferedReader(Charset.forName("UTF-8")) | ||
.use { reader -> load(reader) } | ||
} | ||
|
||
val flutterVersionCode = localProperties.getProperty("flutter.versionCode") ?: "1" | ||
val flutterVersionName = localProperties.getProperty("flutter.versionName") ?: "1.0" | ||
|
||
val keystoreProperties = Properties().apply { | ||
val keystorePropertiesFile = rootProject.file("key.properties") | ||
val keystorePropertiesFileExists = keystorePropertiesFile.exists() | ||
if (keystorePropertiesFileExists) { | ||
this.load(FileInputStream(keystorePropertiesFile)) | ||
} | ||
} | ||
|
||
plugins { | ||
id("com.android.application") | ||
id("kotlin-android") | ||
id("dev.flutter.flutter-gradle-plugin") | ||
} | ||
|
||
android { | ||
namespace = "org.sparcs.otlplus" | ||
compileSdk = rootProject.extra.get("compileSdkVersion")?.toString()?.toIntOrNull() | ||
|
||
sourceSets { | ||
kotlin.sourceSets["main"].kotlin { | ||
srcDir("src/main/kotlin") | ||
} | ||
} | ||
|
||
lint { | ||
disable.addAll( | ||
listOf( | ||
"InvalidPackage", | ||
), | ||
) | ||
} | ||
|
||
defaultConfig { | ||
applicationId = "org.sparcs.otlplus" | ||
minSdk = 21 | ||
targetSdk = rootProject.extra.get("targetSdkVersion")?.toString()?.toIntOrNull() | ||
versionCode = flutterVersionCode.toInt() | ||
versionName = flutterVersionName | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
signingConfigs { | ||
register("release") { | ||
if (keystoreProperties.isNotEmpty()) { | ||
keyAlias = keystoreProperties.getProperty("keyAlias")!! | ||
keyPassword = keystoreProperties.getProperty("keyPassword")!! | ||
storeFile = file(keystoreProperties.getProperty("storeFile")!!) | ||
storePassword = keystoreProperties.getProperty("storePassword")!! | ||
} | ||
} | ||
} | ||
|
||
buildTypes { | ||
release { | ||
signingConfig = signingConfigs.getByName("release") | ||
} | ||
} | ||
|
||
packaging { | ||
jniLibs.keepDebugSymbols.add("**/*.so") | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = "17" | ||
} | ||
} | ||
|
||
flutter { | ||
source = "../.." | ||
} | ||
|
||
dependencies { | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test:runner:1.6.1") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1") | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import com.android.build.gradle.BaseExtension | ||
import com.android.build.gradle.LibraryExtension | ||
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
buildscript { | ||
extra.apply { | ||
set("compileSdkVersion", 34) | ||
set("targetSdkVersion", 34) | ||
} | ||
} | ||
|
||
rootProject.layout.buildDirectory.set(file("../build")) | ||
subprojects { | ||
project.layout.buildDirectory.set(file("${rootProject.layout.buildDirectory.asFile.get().path}/${project.name}")) | ||
} | ||
subprojects { | ||
// check if library extension block is available and namespace isn't set | ||
afterEvaluate { | ||
if (project.hasProperty("android")) { | ||
val ext = try { | ||
project.extensions.getByType<BaseAppModuleExtension>() | ||
} catch (_: Exception) { | ||
project.extensions.getByType<LibraryExtension>() | ||
} | ||
|
||
ext.apply { | ||
if (namespace == null) { | ||
namespace = project.group.toString() | ||
} | ||
} | ||
} | ||
tasks.withType(KotlinCompile::class.java).configureEach { | ||
if (project.plugins.hasPlugin("com.android.application") || project.plugins.hasPlugin("com.android.library")) { | ||
kotlinOptions { | ||
kotlinOptions.jvmTarget = | ||
project.extensions.getByType<BaseExtension>().compileOptions.sourceCompatibility.toString() | ||
} | ||
} | ||
} | ||
} | ||
|
||
project.evaluationDependsOn(":app") | ||
} | ||
|
||
tasks { | ||
register<Delete>("clean") { | ||
delete(rootProject.layout.buildDirectory) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
pluginManagement { | ||
val flutterSdkPath = run { | ||
val properties = java.util.Properties().apply { | ||
file("local.properties") | ||
.bufferedReader(java.nio.charset.Charset.forName("UTF-8")) | ||
.use { reader -> load(reader) } | ||
} | ||
properties.getProperty("flutter.sdk") | ||
?: throw GradleException("flutter.sdk not set in local.properties") | ||
} | ||
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") | ||
|
||
repositories { | ||
google() | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
plugins { | ||
id("dev.flutter.flutter-plugin-loader") version "1.0.0" | ||
id("com.android.application") version "8.3.0" apply false | ||
id("org.jetbrains.kotlin.android") version "1.9.23" apply false | ||
} | ||
|
||
include(":app") |