apply plugin: 'com.android.application'
android {
namespace "com.termux.api"
compileSdk project.properties.compileSdkVersion.toInteger()
def appVersionName = System.getenv("TERMUX_API_APP__BUILD__APP_VERSION_NAME") ?: ""
def apkVersionTag = System.getenv("TERMUX_API_APP__BUILD__APK_VERSION_TAG") ?: ""
defaultConfig {
applicationId "com.termux.api"
minSdk project.properties.minSdkVersion.toInteger()
targetSdk project.properties.targetSdkVersion.toInteger()
versionCode 1002
versionName "0.53.0"
if (appVersionName) versionName = appVersionName
validateVersionName(versionName)
manifestPlaceholders.TERMUX_PACKAGE_NAME = "com.termux"
manifestPlaceholders.TERMUX_APP_NAME = "Termux"
manifestPlaceholders.TERMUX_API_APP_NAME = "Termux:API"
}
signingConfigs {
debug {
storeFile file('testkey_untrusted.jks')
keyAlias 'alias'
storePassword 'xrj45yWGLbsO7W0v'
keyPassword 'xrj45yWGLbsO7W0v'
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources false // Reproducible builds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
debug {
signingConfig signingConfigs.debug
}
}
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = new File("termux-api-app_" +
(apkVersionTag ? apkVersionTag : "v" + versionName + "+" + variant.buildType.name) + ".apk")
}
}
packagingOptions {
// Remove terminal-emulator and termux-shared JNI libs added via termux-shared dependency
exclude "lib/*/libtermux.so"
exclude "lib/*/liblocal-socket.so"
}
}
dependencies {
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
implementation "com.google.android.material:material:1.12.0"
implementation "androidx.biometric:biometric:1.2.0-alpha05"
implementation "androidx.media:media:1.7.0"
implementation "androidx.preference:preference:1.2.1"
implementation "com.termux.termux-app:termux-shared:8aca6dbbf4"
// Use if below libraries are published locally by termux-app with `./gradlew publishReleasePublicationToMavenLocal` and used with `mavenLocal()`.
// If updates are done, republish there and sync project with gradle files here
// https://github.com/termux/termux-app/wiki/Termux-Libraries
//implementation "com.termux:termux-shared:0.118.0"
implementation "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava"
}
task versionName {
doLast {
print android.defaultConfig.versionName
}
}
@SuppressWarnings("UnnecessaryQualifiedReference")
static def validateVersionName(String versionName) {
// https://semver.org/spec/v2.0.0.html#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
// ^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$
if (!java.util.regex.Pattern.matches("^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?\$", versionName))
throw new GradleException("The versionName '" + versionName + "' is not a valid version as per semantic version '2.0.0' spec in the format 'major.minor.patch(-prerelease)(+buildmetadata)'. https://semver.org/spec/v2.0.0.html.")
}