forked from shadowsocks/v2ray-plugin-android
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Teddysun <[email protected]>
- Loading branch information
Showing
1 changed file
with
86 additions
and
86 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,86 +1,86 @@ | ||
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 | ||
compileSdkVersion(30) | ||
compileOptions { | ||
sourceCompatibility = javaVersion | ||
targetCompatibility = javaVersion | ||
} | ||
kotlinOptions.jvmTarget = javaVersion.toString() | ||
defaultConfig { | ||
applicationId = "com.github.shadowsocks.plugin.v2ray" | ||
minSdkVersion(23) | ||
targetSdkVersion(30) | ||
versionCode = 5010000 | ||
versionName = "5.10.0" | ||
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") | ||
args("go-build.bash", 23) | ||
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") | ||
implementation("com.github.shadowsocks:plugin:2.0.1") | ||
implementation("com.takisoft.preferencex:preferencex-simplemenu:1.1.0") | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test:runner:1.3.0") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0") | ||
} | ||
|
||
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 | ||
} | ||
} | ||
} | ||
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 | ||
compileSdkVersion(30) | ||
compileOptions { | ||
sourceCompatibility = javaVersion | ||
targetCompatibility = javaVersion | ||
} | ||
kotlinOptions.jvmTarget = javaVersion.toString() | ||
defaultConfig { | ||
applicationId = "com.github.shadowsocks.plugin.v2ray" | ||
minSdkVersion(23) | ||
targetSdkVersion(30) | ||
versionCode = 5011000 | ||
versionName = "5.11.0" | ||
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") | ||
args("go-build.bash", 23) | ||
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") | ||
implementation("com.github.shadowsocks:plugin:2.0.1") | ||
implementation("com.takisoft.preferencex:preferencex-simplemenu:1.1.0") | ||
testImplementation("junit:junit:4.13.2") | ||
androidTestImplementation("androidx.test:runner:1.3.0") | ||
androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0") | ||
} | ||
|
||
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 | ||
} | ||
} | ||
} |