-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
218 lines (185 loc) · 7.09 KB
/
build.gradle.kts
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
import java.io.FileInputStream
import java.util.*
plugins {
id("com.android.application")
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
id("dagger.hilt.android.plugin")
id("jacoco")
}
repositories {
}
android {
compileSdk = 33
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId = "org.kabiri.android.usbterminal"
minSdk = 23
targetSdk = 33
versionCode = System.getenv("CIRCLE_BUILD_NUM")?.toIntOrNull() ?: 13
versionName = "0.9.12${System.getenv("CIRCLE_BUILD_NUM") ?: ""}"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
val ksName = "keystore.properties"
val ksProp = loadKeyStore(ksName)
ksProp?.let {
create("release") {
keyAlias = ksProp.getProperty("release.keyAlias")
keyPassword = ksProp.getProperty("release.keyPassword")
storeFile = file(ksProp.getProperty("release.file"))
storePassword = ksProp.getProperty("release.storePassword")
}
}
}
buildTypes {
named("release") {
signingConfig = signingConfigs.findByName("release")
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
named("debug") {
isTestCoverageEnabled = true
}
}
testOptions {
animationsDisabled = true
managedDevices {
devices {
maybeCreate<com.android.build.api.dsl.ManagedVirtualDevice>("pixel2api30").apply {
device = "Pixel 2"
apiLevel = 30
systemImageSource = "google_atd"
}
}
}
}
namespace = "org.kabiri.android.usbterminal"
}
jacoco {
val jacoco_version: String by project
toolVersion = jacoco_version
reportsDirectory.set(layout.buildDirectory.dir("mergedReportDir"))
}
tasks.register<JacocoReport>("jacocoTestReport") {
dependsOn("testDebugUnitTest")
dependsOn("pixel2api30DebugAndroidTest")
reports {
xml.required.set(true)
html.required.set(true)
csv.required.set(false)
}
val fileFilter = listOf("**/R.class", "**/R$*.class", "**/BuildConfig.*", "**/Manifest*.*", "**/*Test*.*", "android/**/*.*")
val debugTree = fileTree("${buildDir}/tmp/kotlin-classes/debug") { exclude(fileFilter) }
val mainSrc = "${project.projectDir}/src/main/kotlin"
sourceDirectories.from(files(setOf(mainSrc)))
classDirectories.from(files(setOf(debugTree)))
executionData.from(fileTree(buildDir) { include(setOf(
"outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec",
"outputs/managed_device_code_coverage/pixel2api30/coverage.ec"
))})
}
sonarqube {
properties {
property("sonar.projectKey", System.getenv("SONAR_PROJECT_KEY"))
property("sonar.organization", System.getenv("SONAR_ORGANIZATION"))
property("sonar.host.url", System.getenv("SONAR_HOST_URL"))
}
}
tasks.register("generateGoogleServicesJson") {
doLast {
val jsonFileName = "google-services.json"
val fileContent = System.getenv("GOOGLE_SERVICES_JSON")
File(projectDir, jsonFileName).apply {
createNewFile(); writeText(fileContent)
println("generated $jsonFileName")
}
}
}
tasks.register("generateKsPropFile") {
doLast {
val configFileName = "keystore.properties"
File(projectDir, configFileName).apply {
createNewFile()
writeText("""
# Gradle signing properties for app module
release.file=${System.getenv("KS_PATH")}
release.storePassword=${System.getenv("KS_PASSWORD")}
release.keyAlias=${System.getenv("KS_KEY_ALIAS")}
release.keyPassword=${System.getenv("KS_KEY_PASSWORD")}
""".trimIndent())
println("generated ${this.path}")
}
}
}
tasks.register("generateAppDistKey") {
doLast {
val jsonFileName = "app-dist-key.json"
val fileContent = System.getenv("GOOGLE_APP_DIST_FASTLANE_SERVICE_ACCOUNT")
File(rootDir, jsonFileName).apply {
createNewFile()
writeText(fileContent)
println("generated ${this.path}")
}
}
}
fun loadKeyStore(name: String): Properties? {
val ksProp = Properties()
val ksPropFile = file(name)
return if (ksPropFile.exists()) {
ksProp.load(FileInputStream(ksPropFile))
ksProp
} else {
println("ERROR: local keystore file not found")
null
}
}
val firebase_bom_version: String by project
val hilt_version: String by project
dependencies {
implementation("androidx.appcompat:appcompat:1.6.0")
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
// Firebase
implementation(platform("com.google.firebase:firebase-bom:$firebase_bom_version"))
implementation("com.google.firebase:firebase-analytics-ktx")
implementation("com.google.firebase:firebase-crashlytics-ktx")
// Dependency Injection
implementation("com.google.dagger:hilt-android:$hilt_version")
kapt("com.google.dagger:hilt-compiler:$hilt_version")
// Coroutines
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.1")
implementation("androidx.activity:activity-compose:1.6.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1")
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
// hilt testing
// more info:
// https://developer.android.com/training/dependency-injection/hilt-testing
androidTestImplementation("com.google.dagger:hilt-android-testing:$hilt_version")
kaptAndroidTest("com.google.dagger:hilt-android-compiler:$hilt_version")
// unit test libs
testImplementation("junit:junit:4.13.2")
testImplementation("com.google.truth:truth:1.1.3")
// instrumented test libs
androidTestImplementation("androidx.test:core:1.5.0")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.ext:junit-ktx:1.1.5")
// Espresso
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
// Hamcrest for view matching
androidTestImplementation("org.hamcrest:hamcrest-library:2.2")
androidTestImplementation("androidx.test:runner:1.5.2")
androidTestImplementation("androidx.test:rules:1.5.0")
/**
* This library helps to automate some parts of the USB serial connection.
* For more information, visit: https://github.com/felHR85/UsbSerial
*/
implementation("com.github.felHR85:UsbSerial:6.1.0")
}