v2ray-plugin-android/app/build.gradle

89 lines
2.8 KiB
Groovy
Raw Normal View History

2019-01-11 09:44:36 +08:00
import org.apache.tools.ant.taskdefs.condition.Os
import com.android.build.OutputFile
import java.util.regex.Matcher
import java.util.regex.Pattern
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
def getCurrentFlavor() {
String task = getGradle().getStartParameter().getTaskRequests().toString()
Matcher matcher = Pattern.compile("(assemble|generate)\\w*(Release|Debug)").matcher(task)
if (matcher.find()) return matcher.group(2).toLowerCase() else {
println "Warning: No match found for $task"
return "debug"
}
}
2020-02-07 12:22:15 +08:00
def javaVersion = JavaVersion.VERSION_1_8
2019-01-11 09:44:36 +08:00
android {
2019-06-23 13:44:36 +08:00
compileSdkVersion 29
2020-02-07 12:22:15 +08:00
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
kotlinOptions.jvmTarget = javaVersion
2019-01-11 09:44:36 +08:00
defaultConfig {
applicationId "com.github.shadowsocks.plugin.v2ray"
minSdkVersion rootProject.minSdkVersion
2019-06-23 13:44:36 +08:00
targetSdkVersion 29
2019-06-24 09:33:16 +08:00
versionCode 1030000
versionName "1.3.0"
2019-01-11 09:44:36 +08:00
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
splits {
abi {
enable true
universalApk true
}
}
2019-01-18 09:45:25 +08:00
sourceSets.main.jniLibs.srcDirs += new File(projectDir, "build/go")
2019-01-11 09:44:36 +08:00
}
task goBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
println "Warning: Building on Windows is not supported"
} else {
2019-01-18 09:45:25 +08:00
executable "/bin/bash"
args "go-build.bash", minSdkVersion
2019-01-17 17:04:39 +08:00
environment "ANDROID_HOME", android.sdkDirectory
environment "ANDROID_NDK_HOME", android.ndkDirectory
2019-01-11 09:44:36 +08:00
}
}
tasks.whenTaskAdded { task ->
if ((task.name == 'javaPreCompileDebug' ||
task.name == 'javaPreCompileRelease')) {
task.dependsOn(goBuild)
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
2020-01-18 09:40:04 +08:00
implementation 'androidx.preference:preference:1.1.0'
2020-02-06 14:29:24 +08:00
implementation 'com.github.shadowsocks:plugin:1.3.4'
2020-01-18 09:40:04 +08:00
implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.1.0'
2019-06-20 09:36:40 +08:00
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
2020-01-18 09:40:04 +08:00
testImplementation 'junit:junit:4.13'
2019-06-20 09:36:40 +08:00
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
2019-01-11 09:44:36 +08:00
}
ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3, x86_64: 4]
if (getCurrentFlavor() == 'release') android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def offset = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
if (offset != null) output.versionCodeOverride = variant.versionCode + offset
}
}