From 0aaa804db571a8cee5066d9ca3b1a2e732757feb Mon Sep 17 00:00:00 2001 From: Mygod Date: Sun, 24 May 2020 05:45:10 +0800 Subject: [PATCH] Update dependencies --- app/build.gradle | 88 ------------------------ app/build.gradle.kts | 88 ++++++++++++++++++++++++ build.gradle | 31 --------- build.gradle.kts | 32 +++++++++ gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 2 + gradlew.bat | 4 ++ settings.gradle | 1 - settings.gradle.kts | 1 + 9 files changed, 128 insertions(+), 121 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index bae26c7..0000000 --- a/app/build.gradle +++ /dev/null @@ -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 - } -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..5316b53 --- /dev/null +++ b/app/build.gradle.kts @@ -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("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 + } + } +} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index acca36d..0000000 --- a/build.gradle +++ /dev/null @@ -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 -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..8e0bec1 --- /dev/null +++ b/build.gradle.kts @@ -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("clean") { + delete(rootProject.buildDir) +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 31a0802..a4f0001 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew index 2fe81a7..fbd7c51 100755 --- a/gradlew +++ b/gradlew @@ -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 diff --git a/gradlew.bat b/gradlew.bat index 24467a1..a9f778a 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -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% diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e7b4def..0000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..15a801b --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +include(":app")