ByeDPIAndroid/app/build.gradle.kts

152 lines
4.3 KiB
Plaintext
Raw Normal View History

2024-08-08 23:04:25 +00:00
import com.android.build.gradle.internal.tasks.factory.dependsOn
2024-02-22 18:06:02 +00:00
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
android {
namespace = "io.github.dovecoteescapee.byedpi"
compileSdk = 34
defaultConfig {
applicationId = "io.github.dovecoteescapee.byedpi"
minSdk = 21
2024-02-22 18:06:02 +00:00
targetSdk = 34
2024-08-11 02:13:13 +00:00
versionCode = 7
versionName = "1.0.2"
2024-02-22 18:06:02 +00:00
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
buildConfig = true
}
2024-02-22 18:06:02 +00:00
buildTypes {
release {
buildConfigField("String", "VERSION_NAME", "\"${defaultConfig.versionName}\"")
2024-02-22 18:06:02 +00:00
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
debug {
buildConfigField("String", "VERSION_NAME", "\"${defaultConfig.versionName}-debug\"")
}
2024-02-22 18:06:02 +00:00
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
externalNativeBuild {
cmake {
path = file("src/main/cpp/CMakeLists.txt")
version = "3.22.1"
}
}
buildFeatures {
viewBinding = true
}
2024-08-12 14:31:48 +00:00
// https://android.izzysoft.de/articles/named/iod-scan-apkchecks?lang=en#blobs
dependenciesInfo {
// Disables dependency metadata when building APKs.
includeInApk = false
// Disables dependency metadata when building Android App Bundles.
includeInBundle = false
}
2024-02-22 18:06:02 +00:00
}
dependencies {
implementation(files("libs/tun2socks.aar"))
2024-08-04 22:21:39 +00:00
implementation("androidx.fragment:fragment-ktx:1.8.2")
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.appcompat:appcompat:1.7.0")
2024-02-22 18:06:02 +00:00
implementation("androidx.preference:preference-ktx:1.2.1")
implementation("com.takisoft.preferencex:preferencex:1.1.0")
2024-08-04 22:21:39 +00:00
implementation("com.google.android.material:material:1.12.0")
2024-02-22 18:06:02 +00:00
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
2024-08-04 22:21:39 +00:00
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.4")
implementation("androidx.lifecycle:lifecycle-service:2.8.4")
2024-02-22 18:06:02 +00:00
testImplementation("junit:junit:4.13.2")
2024-08-04 22:21:39 +00:00
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
2024-02-22 18:06:02 +00:00
}
abstract class BaseTun2SocksTask : DefaultTask() {
@get:InputDirectory
val tun2socksDir: File
get() = project.file("libs/tun2socks")
2024-02-22 18:06:02 +00:00
@get:OutputFile
val tun2socksOutput: File
get() = project.file("libs/tun2socks.aar")
@Internal
protected fun isUpToDate(): Boolean {
2024-02-22 18:06:02 +00:00
if (tun2socksOutput.exists()) {
val lastModified = tun2socksOutput.lastModified()
return !tun2socksDir.walkTopDown().any {
it.isFile && it.lastModified() > lastModified
}
}
return false
}
}
abstract class GetGomobileBind : BaseTun2SocksTask() {
@TaskAction
fun getBind() {
if (isUpToDate()) {
logger.lifecycle("No changes detected, skipping getBind.")
2024-02-22 18:06:02 +00:00
return
}
2024-02-22 18:06:02 +00:00
project.exec {
workingDir = tun2socksDir
commandLine("go", "get", "golang.org/x/mobile/bind")
2024-02-22 18:06:02 +00:00
}
}
}
abstract class BuildTun2Socks : BaseTun2SocksTask() {
@TaskAction
fun buildTun2Socks() {
if (isUpToDate()) {
logger.lifecycle("No changes detected, skipping buildTun2Socks.")
return
}
project.exec {
workingDir = tun2socksDir
commandLine(
"gomobile", "bind",
"-target", "android",
"-androidapi", "21",
"-o", tun2socksOutput,
"-trimpath",
"./engine"
)
}
}
}
2024-08-08 23:04:25 +00:00
val getGomobileBind = tasks.register<GetGomobileBind>("getGomobileBind") {
group = "build"
description = "Get gomobile bind for compiling tun2socks"
}
2024-08-08 23:04:25 +00:00
val buildTun2Socks = tasks.register<BuildTun2Socks>("buildTun2Socks") {
2024-02-22 18:06:02 +00:00
group = "build"
description = "Build tun2socks for Android"
2024-08-08 23:04:25 +00:00
dependsOn(getGomobileBind)
2024-02-22 18:06:02 +00:00
}
2024-08-08 23:04:25 +00:00
tasks.preBuild.dependsOn(buildTun2Socks)