2020-05-24 05:45:10 +08:00
|
|
|
import com.android.build.gradle.internal.api.ApkVariantOutputImpl
|
|
|
|
import com.android.build.VariantOutput
|
|
|
|
import org.apache.tools.ant.taskdefs.condition.Os
|
|
|
|
import java.util.Locale
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
id("com.android.application")
|
|
|
|
kotlin("android")
|
|
|
|
}
|
|
|
|
|
|
|
|
val flavorRegex = "(assemble|generate)\\w*(Release|Debug)".toRegex()
|
|
|
|
val currentFlavor get() = gradle.startParameter.taskRequests.toString().let { task ->
|
|
|
|
flavorRegex.find(task)?.groupValues?.get(2)?.toLowerCase(Locale.ROOT) ?: "debug".also {
|
|
|
|
println("Warning: No match found for $task")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
android {
|
|
|
|
val javaVersion = JavaVersion.VERSION_1_8
|
2022-08-22 15:29:40 +08:00
|
|
|
compileSdkVersion(30)
|
2020-05-24 05:45:10 +08:00
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility = javaVersion
|
|
|
|
targetCompatibility = javaVersion
|
|
|
|
}
|
|
|
|
kotlinOptions.jvmTarget = javaVersion.toString()
|
|
|
|
defaultConfig {
|
|
|
|
applicationId = "com.github.shadowsocks.plugin.v2ray"
|
2021-02-26 20:53:53 +08:00
|
|
|
minSdkVersion(23)
|
2022-08-22 15:29:40 +08:00
|
|
|
targetSdkVersion(30)
|
2023-02-08 10:39:23 +08:00
|
|
|
versionCode = 5003000
|
|
|
|
versionName = "5.3.0"
|
2020-05-24 05:45:10 +08:00
|
|
|
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
|
|
|
|
}
|
|
|
|
buildTypes {
|
|
|
|
getByName("release") {
|
|
|
|
isShrinkResources = true
|
|
|
|
isMinifyEnabled = true
|
|
|
|
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
splits {
|
|
|
|
abi {
|
|
|
|
isEnable = true
|
|
|
|
isUniversalApk = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sourceSets.getByName("main") {
|
|
|
|
jniLibs.setSrcDirs(jniLibs.srcDirs + files("$projectDir/build/go"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.register<Exec>("goBuild") {
|
|
|
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
|
|
|
println("Warning: Building on Windows is not supported")
|
|
|
|
} else {
|
|
|
|
executable("/bin/bash")
|
2021-02-26 20:53:53 +08:00
|
|
|
args("go-build.bash", 23)
|
2020-05-24 05:45:10 +08:00
|
|
|
environment("ANDROID_HOME", android.sdkDirectory)
|
|
|
|
environment("ANDROID_NDK_HOME", android.ndkDirectory)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.whenTaskAdded {
|
|
|
|
when (name) {
|
|
|
|
"mergeDebugJniLibFolders", "mergeReleaseJniLibFolders" -> dependsOn("goBuild")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
implementation(kotlin("stdlib-jdk8", rootProject.extra.get("kotlinVersion").toString()))
|
|
|
|
implementation("androidx.preference:preference:1.1.1")
|
2021-06-09 13:05:36 +08:00
|
|
|
implementation("com.github.shadowsocks:plugin:2.0.1")
|
2020-05-24 05:45:10 +08:00
|
|
|
implementation("com.takisoft.preferencex:preferencex-simplemenu:1.1.0")
|
2021-02-26 20:53:53 +08:00
|
|
|
testImplementation("junit:junit:4.13.2")
|
|
|
|
androidTestImplementation("androidx.test:runner:1.3.0")
|
|
|
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0")
|
2020-05-24 05:45:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
val abiCodes = mapOf("armeabi-v7a" to 1, "arm64-v8a" to 2, "x86" to 3, "x86_64" to 4)
|
|
|
|
if (currentFlavor == "release") android.applicationVariants.all {
|
|
|
|
for (output in outputs) {
|
|
|
|
abiCodes[(output as ApkVariantOutputImpl).getFilter(VariantOutput.ABI)]?.let { offset ->
|
|
|
|
output.versionCodeOverride = versionCode + offset
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|