mirror of
https://github.com/wgtunnel/android.git
synced 2026-07-03 14:07:49 +02:00
2690ce29e1
Migrated app to a forked version of wireguard-android to enable development work on features that require changes to the core lib, like #107 #104 #87 #52 #6 Improved first launch flow by change vpn permission to only launch on first tunnel start Changed to proper database seeding strategy Updated README to account for GitHub packages auth requirement Migrated from deprecated UI components and libs Bump versions
47 lines
1.5 KiB
Kotlin
47 lines
1.5 KiB
Kotlin
import org.gradle.api.invocation.Gradle
|
|
import java.io.File
|
|
|
|
object BuildHelper {
|
|
private fun getCurrentFlavor(gradle: Gradle): String {
|
|
val taskRequestsStr = gradle.startParameter.taskRequests.toString()
|
|
val pattern: java.util.regex.Pattern =
|
|
if (taskRequestsStr.contains("assemble")) {
|
|
java.util.regex.Pattern.compile("assemble(\\w+)(Release|Debug)")
|
|
} else {
|
|
java.util.regex.Pattern.compile("bundle(\\w+)(Release|Debug)")
|
|
}
|
|
|
|
val matcher = pattern.matcher(taskRequestsStr)
|
|
val flavor =
|
|
if (matcher.find()) {
|
|
matcher.group(1).lowercase()
|
|
} else {
|
|
print("NO FLAVOR FOUND")
|
|
""
|
|
}
|
|
return flavor
|
|
}
|
|
|
|
fun getLocalProperty(key: String, file: String = "local.properties"): String? {
|
|
val properties = java.util.Properties()
|
|
val localProperties = File(file)
|
|
if (localProperties.isFile) {
|
|
java.io.InputStreamReader(java.io.FileInputStream(localProperties), Charsets.UTF_8).use { reader ->
|
|
properties.load(reader)
|
|
}
|
|
} else return null
|
|
return properties.getProperty(key)
|
|
}
|
|
|
|
fun isGeneralFlavor(gradle: Gradle): Boolean {
|
|
return getCurrentFlavor(gradle) == "general"
|
|
}
|
|
|
|
fun isReleaseBuild(gradle: Gradle): Boolean {
|
|
return (gradle.startParameter.taskNames.size > 0 &&
|
|
gradle.startParameter.taskNames[0].contains(
|
|
"Release",
|
|
))
|
|
}
|
|
}
|