-
Notifications
You must be signed in to change notification settings - Fork 780
Expand file tree
/
Copy pathbuild.gradle
More file actions
133 lines (112 loc) · 4.6 KB
/
build.gradle
File metadata and controls
133 lines (112 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
apply plugin: 'com.android.application'
apply plugin: 'com.google.protobuf'
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 1000
versionName "0.51.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.txt'
}
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"
}
sourceSets {
main {
proto {
srcDir 'src/main/proto'
}
java {
srcDir 'src/main/java'
}
}
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:4.29.3'
}
plugins {
javalite {
artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
}
}
// this is a task which will generate classes for our proto files
generateProtoTasks {
all().each { task ->
task.builtins {
remove java
}
task.plugins {
javalite {}
}
}
}
}
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:9ee1c9d5ad"
// 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.protobuf:protobuf-lite:3.0.1'
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.")
}