mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
229 lines
7.4 KiB
Plaintext
229 lines
7.4 KiB
Plaintext
import com.android.build.api.dsl.ApplicationExtension
|
|
import java.io.ByteArrayOutputStream
|
|
|
|
plugins {
|
|
id("com.android.application")
|
|
id("org.jetbrains.kotlin.android")
|
|
kotlin("plugin.serialization") version "1.8.10"
|
|
}
|
|
|
|
android {
|
|
namespace = "moe.fuqiuluo.shamrock"
|
|
ndkVersion = "25.1.8937393"
|
|
compileSdk = 34
|
|
|
|
defaultConfig {
|
|
applicationId = "moe.fuqiuluo.shamrock"
|
|
minSdk = 27
|
|
targetSdk = 34
|
|
versionCode = getVersionCode()
|
|
versionName = "1.0.7" + ".r${getGitCommitCount()}." + getVersionName()
|
|
|
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
|
vectorDrawables {
|
|
useSupportLibrary = true
|
|
}
|
|
@Suppress("UnstableApiUsage")
|
|
externalNativeBuild {
|
|
cmake {
|
|
cppFlags += ""
|
|
}
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
isMinifyEnabled = false
|
|
proguardFiles(
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
"proguard-rules.pro"
|
|
)
|
|
}
|
|
}
|
|
|
|
android.applicationVariants.all {
|
|
outputs.map { it as com.android.build.gradle.internal.api.BaseVariantOutputImpl }
|
|
.forEach {
|
|
val abiName = when (val abi = it.outputFileName.split("-")[1].split(".apk")[0]) {
|
|
"app" -> "all"
|
|
"x64" -> "x86_64"
|
|
else -> abi
|
|
}
|
|
it.outputFileName = "Shamrock-v${versionName}-${abiName}.apk"
|
|
}
|
|
}
|
|
|
|
flavorDimensions.add("mode")
|
|
|
|
productFlavors {
|
|
create("app") {
|
|
dimension = "mode"
|
|
ndk {
|
|
println("Full architecture and full compilation.")
|
|
abiFilters.add("arm64-v8a")
|
|
abiFilters.add("x86_64")
|
|
}
|
|
}
|
|
create("arm64") {
|
|
dimension = "mode"
|
|
ndk {
|
|
println("Full compilation of arm64 architecture")
|
|
abiFilters.add("arm64-v8a")
|
|
}
|
|
}
|
|
create("x64") {
|
|
dimension = "mode"
|
|
ndk {
|
|
println("Full compilation of x64 architecture")
|
|
abiFilters.add("x86_64")
|
|
}
|
|
}
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
kotlinOptions {
|
|
jvmTarget = "17"
|
|
}
|
|
buildFeatures {
|
|
compose = true
|
|
}
|
|
composeOptions {
|
|
kotlinCompilerExtensionVersion = "1.4.3"
|
|
}
|
|
packaging {
|
|
jniLibs {
|
|
useLegacyPackaging = true
|
|
}
|
|
resources {
|
|
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
|
excludes += "/META-INF/*"
|
|
excludes += "/META-INF/NOTICE.txt"
|
|
excludes += "/META-INF/DEPENDENCIES.txt"
|
|
excludes += "/META-INF/NOTICE"
|
|
excludes += "/META-INF/LICENSE"
|
|
excludes += "/META-INF/DEPENDENCIES"
|
|
excludes += "/META-INF/notice.txt"
|
|
excludes += "/META-INF/dependencies.txt"
|
|
excludes += "/META-INF/LGPL2.1"
|
|
excludes += "/META-INF/ASL2.0"
|
|
excludes += "/META-INF/INDEX.LIST"
|
|
excludes += "/META-INF/io.netty.versions.properties"
|
|
excludes += "/META-INF/INDEX.LIST"
|
|
excludes += "/META-INF/LICENSE.txt"
|
|
excludes += "/META-INF/license.txt"
|
|
excludes += "/META-INF/*.kotlin_module"
|
|
excludes += "/META-INF/services/reactor.blockhound.integration.BlockHoundIntegration"
|
|
}
|
|
}
|
|
externalNativeBuild {
|
|
cmake {
|
|
path = file("src/main/cpp/CMakeLists.txt")
|
|
version = "3.22.1"
|
|
}
|
|
}
|
|
|
|
configureAppSigningConfigsForRelease(project)
|
|
packagingOptions {
|
|
jniLibs {
|
|
useLegacyPackaging = true
|
|
}
|
|
}
|
|
}
|
|
|
|
fun configureAppSigningConfigsForRelease(project: Project) {
|
|
val keystorePath: String? = System.getenv("KEYSTORE_PATH")
|
|
if (keystorePath.isNullOrBlank()) {
|
|
return
|
|
}
|
|
project.configure<ApplicationExtension> {
|
|
signingConfigs {
|
|
create("release") {
|
|
storeFile = file(System.getenv("KEYSTORE_PATH"))
|
|
storePassword = System.getenv("KEYSTORE_PASSWORD")
|
|
keyAlias = System.getenv("KEY_ALIAS")
|
|
keyPassword = System.getenv("KEY_PASSWORD")
|
|
enableV2Signing = true
|
|
}
|
|
}
|
|
buildTypes {
|
|
release {
|
|
signingConfig = signingConfigs.findByName("release")
|
|
}
|
|
debug {
|
|
signingConfig = signingConfigs.findByName("release")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fun getGitCommitCount(): Int {
|
|
val out = ByteArrayOutputStream()
|
|
exec {
|
|
commandLine("git", "rev-list", "--count", "HEAD")
|
|
standardOutput = out
|
|
}
|
|
return out.toString().trim().toInt()
|
|
}
|
|
|
|
fun getGitCommitHash(): String {
|
|
val out = ByteArrayOutputStream()
|
|
exec {
|
|
commandLine("git", "rev-parse", "--short", "HEAD")
|
|
standardOutput = out
|
|
}
|
|
return out.toString().trim()
|
|
}
|
|
|
|
fun getVersionCode(): Int {
|
|
return (System.currentTimeMillis() / 1000L).toInt()
|
|
}
|
|
|
|
fun getVersionName(): String {
|
|
return getGitCommitHash()
|
|
}
|
|
|
|
dependencies {
|
|
implementation("androidx.core:core-ktx:1.9.0")
|
|
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1")
|
|
implementation("androidx.activity:activity-compose:1.7.2")
|
|
implementation(platform("androidx.compose:compose-bom:2023.06.01"))
|
|
implementation("androidx.compose.ui:ui")
|
|
implementation("androidx.compose.ui:ui-graphics")
|
|
implementation("androidx.compose.ui:ui-tooling-preview")
|
|
implementation("androidx.compose.material3:material3")
|
|
//noinspection GradleDynamicVersion
|
|
implementation("com.google.accompanist:accompanist-pager:0.31.5+")
|
|
//noinspection GradleDynamicVersion
|
|
implementation("com.google.accompanist:accompanist-systemuicontroller:0.31.5+")
|
|
//noinspection GradleDynamicVersion useless
|
|
// implementation("androidx.constraintlayout:constraintlayout-compose:1.1.0+")
|
|
implementation("io.coil-kt:coil:2.4.0")
|
|
implementation("io.coil-kt:coil-compose:2.4.0")
|
|
|
|
implementation("org.jetbrains.kotlinx:kotlinx-io-jvm:0.1.16")
|
|
|
|
val ktorVersion = "2.3.3"
|
|
implementation("io.ktor:ktor-server-core:$ktorVersion")
|
|
implementation("io.ktor:ktor-server-host-common:$ktorVersion")
|
|
implementation("io.ktor:ktor-server-status-pages:$ktorVersion")
|
|
implementation("io.ktor:ktor-server-netty:$ktorVersion")
|
|
implementation("io.ktor:ktor-server-content-negotiation:$ktorVersion")
|
|
implementation("io.ktor:ktor-client-core:$ktorVersion")
|
|
implementation("io.ktor:ktor-client-cio:$ktorVersion")
|
|
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
|
|
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
|
|
//implementation("io.ktor:ktor-serialization-kotlinx-protobuf:$ktorVersion")
|
|
|
|
implementation(project(":xposed"))
|
|
|
|
testImplementation("junit:junit:4.13.2")
|
|
androidTestImplementation("androidx.test.ext:junit:1.1.5")
|
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
|
|
androidTestImplementation(platform("androidx.compose:compose-bom:2023.06.01"))
|
|
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
|
|
debugImplementation("androidx.compose.ui:ui-tooling")
|
|
debugImplementation("androidx.compose.ui:ui-test-manifest")
|
|
} |