Update dependencies

This commit is contained in:
Mygod 2020-05-24 05:45:10 +08:00
parent e8cd1f3dff
commit 0aaa804db5
9 changed files with 128 additions and 121 deletions

View file

@ -1,88 +0,0 @@
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"
}
}
def javaVersion = JavaVersion.VERSION_1_8
android {
compileSdkVersion 29
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
kotlinOptions.jvmTarget = javaVersion
defaultConfig {
applicationId "com.github.shadowsocks.plugin.v2ray"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion 29
versionCode 1030100
versionName "1.3.1"
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
}
}
sourceSets.main.jniLibs.srcDirs += new File(projectDir, "build/go")
}
task goBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
println "Warning: Building on Windows is not supported"
} else {
executable "/bin/bash"
args "go-build.bash", minSdkVersion
environment "ANDROID_HOME", android.sdkDirectory
environment "ANDROID_NDK_HOME", android.ndkDirectory
}
}
tasks.whenTaskAdded { task ->
if ((task.name == 'javaPreCompileDebug' ||
task.name == 'javaPreCompileRelease')) {
task.dependsOn(goBuild)
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.preference:preference:1.1.0'
implementation 'com.github.shadowsocks:plugin:1.3.4'
implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
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
}
}

88
app/build.gradle.kts Normal file
View file

@ -0,0 +1,88 @@
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")
}
}
val minSdk = 21
android {
val javaVersion = JavaVersion.VERSION_1_8
compileSdkVersion(29)
compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
kotlinOptions.jvmTarget = javaVersion.toString()
defaultConfig {
applicationId = "com.github.shadowsocks.plugin.v2ray"
minSdkVersion(minSdk)
targetSdkVersion(29)
versionCode = 1030100
versionName = "1.3.1"
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", minSdk)
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:1.3.4")
implementation("com.takisoft.preferencex:preferencex-simplemenu:1.1.0")
testImplementation("junit:junit:4.13")
androidTestImplementation("androidx.test:runner:1.2.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.2.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
}
}
}

View file

@ -1,31 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.github.ben-manes.versions'
buildscript {
ext {
kotlinVersion = '1.3.61'
minSdkVersion = 21
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.27.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
allprojects {
repositories {
google()
jcenter()
mavenLocal()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

32
build.gradle.kts Normal file
View file

@ -0,0 +1,32 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.github.ben-manes.versions") version "0.28.0"
}
buildscript {
val kotlinVersion = "1.3.72"
extra.set("kotlinVersion", kotlinVersion)
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.0.0-rc01")
classpath("com.github.ben-manes:gradle-versions-plugin:0.28.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}
allprojects {
repositories {
google()
jcenter()
mavenLocal()
}
}
tasks.register<Delete>("clean") {
delete(rootProject.buildDir)
}

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
gradlew vendored
View file

@ -82,6 +82,7 @@ esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath

4
gradlew.bat vendored
View file

@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@ -81,6 +84,7 @@ set CMD_LINE_ARGS=%*
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

View file

@ -1 +0,0 @@
include ':app'

1
settings.gradle.kts Normal file
View file

@ -0,0 +1 @@
include(":app")