-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathbuild.gradle
251 lines (205 loc) · 7.57 KB
/
build.gradle
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
apply plugin: 'com.android.application'
apply plugin: 'com.google.devtools.ksp'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
def commitSHA1 = 'COMMIT_SHA1'
def gitRemote = 'GIT_REMOTE'
dependencies {
// Data and domain modules
implementation project(':owncloudDomain')
implementation project(':owncloudData')
// Kotlin
implementation libs.kotlin.stdlib
implementation libs.kotlinx.coroutines.core
// Android X
implementation libs.androidx.annotation
implementation libs.androidx.appcompat
implementation libs.androidx.biometric
implementation libs.androidx.constraintlayout
implementation libs.androidx.core.ktx
implementation libs.androidx.fragment.ktx
implementation libs.androidx.legacy.support
implementation libs.androidx.lifecycle.common.java8
implementation libs.androidx.lifecycle.extensions
implementation libs.androidx.lifecycle.livedata.ktx
implementation libs.androidx.lifecycle.runtime.ktx
implementation libs.androidx.lifecycle.viewmodel.ktx
implementation libs.androidx.preference.ktx
implementation libs.androidx.room.runtime
implementation libs.androidx.sqlite.ktx
implementation libs.androidx.work.runtime.ktx
implementation(libs.androidx.browser) { because "CustomTabs required for OAuth2 and OIDC" }
implementation(libs.androidx.enterprise.feedback) { because "MDM feedback" }
// Image loading
implementation libs.coil
implementation libs.glide
implementation libs.glide.vector
// Zooming Android ImageView.
implementation libs.photoview
// Koin dependency injector
implementation libs.koin.androidx.workmanager
implementation libs.koin.core
// Miscellaneous
implementation libs.disklrucache
implementation libs.media3.exoplayer
implementation libs.media3.ui
implementation libs.floatingactionbutton
implementation libs.material
implementation libs.patternlockview
// Markdown Preview
implementation libs.bundles.markwon
// Timber
implementation libs.timber
// Tests
testImplementation project(":owncloudTestUtil")
testImplementation libs.androidx.arch.core.testing
testImplementation libs.junit4
testImplementation libs.kotlinx.coroutines.test
testImplementation libs.mockk
// Instrumented tests
androidTestImplementation project(":owncloudTestUtil")
androidTestImplementation libs.androidx.annotation
androidTestImplementation libs.androidx.arch.core.testing
androidTestImplementation libs.androidx.test.core
androidTestImplementation libs.androidx.test.ext.junit
androidTestImplementation libs.androidx.test.rules
androidTestImplementation libs.androidx.test.runner
androidTestImplementation libs.androidx.test.uiautomator
androidTestImplementation libs.bundles.espresso
androidTestImplementation libs.dexopener
androidTestImplementation(libs.mockk.android) { exclude module: "objenesis" }
// Debug
debugImplementation libs.androidx.fragment.testing
debugImplementation libs.androidx.test.monitor
debugImplementation libs.stetho
// Detekt
detektPlugins libs.detekt.formatting
detektPlugins libs.detekt.libraries
}
android {
compileSdkVersion sdkCompileVersion
defaultConfig {
minSdkVersion sdkMinVersion
targetSdkVersion sdkTargetVersion
testInstrumentationRunner "com.owncloud.android.utils.OCTestAndroidJUnitRunner"
versionCode = 44000101
versionName = "4.5.0-beta.1"
buildConfigField "String", gitRemote, "\"" + getGitOriginRemote() + "\""
buildConfigField "String", commitSHA1, "\"" + getLatestGitHash() + "\""
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
sourceSets {
androidTest.java.srcDirs += "src/test-common/java"
test.java.srcDirs += "src/test-common/java"
}
lint {
abortOnError true
htmlOutput file('../lint-app-report.html')
ignoreWarnings false
xmlReport false
}
signingConfigs {
release {
if (System.env.OC_RELEASE_KEYSTORE) {
storeFile file(System.env.OC_RELEASE_KEYSTORE) // use an absolute path
storePassword System.env.OC_RELEASE_KEYSTORE_PASSWORD
keyAlias System.env.OC_RELEASE_KEY_ALIAS
keyPassword System.env.OC_RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
if (System.env.OC_RELEASE_KEYSTORE) {
signingConfig signingConfigs.release
}
}
debug {
applicationIdSuffix ".debug"
}
}
flavorDimensions "management"
productFlavors {
original {
dimension "management"
}
mdm {
dimension "management"
}
}
applicationVariants.all { variant ->
def appName = System.env.OC_APP_NAME
setOutputFileName(variant, appName, project)
}
testOptions {
packagingOptions {
jniLibs {
useLegacyPackaging = true
}
}
unitTests.returnDefaultValues = true
animationsDisabled = true
}
buildFeatures {
viewBinding true
}
packagingOptions {
resources.excludes.add("META-INF/*")
}
namespace "com.owncloud.android"
testNamespace "com.owncloud.android.test"
}
// Updates output file names of a given variant to format
// [appName].[variant.versionName].[OC_BUILD_NUMBER]-[variant.name].apk.
//
// OC_BUILD_NUMBER is an environment variable read directly in this method. If undefined, it's not added.
//
// @param variant Build variant instance which output file name will be updated.
// @param appName String to use as first part of the new file name. May be undefined, the original
// project.archivesBaseName property will be used instead.
// @param callerProject Caller project.
def setOutputFileName(variant, appName, callerProject) {
logger.info("Setting new name for output of variant $variant.name")
def originalFile = variant.outputs[0].outputFile
def originalName = originalFile.name
println "originalName is $originalName"
def newName = ""
if (appName) {
newName += appName
} else {
newName += "owncloud"
}
def versionName = "$variant.mergedFlavor.versionName"
if (variant.mergedFlavor.manifestPlaceholders.versionName != null) {
versionName = "$variant.mergedFlavor.manifestPlaceholders.versionName"
}
if (variant.buildType.manifestPlaceholders.versionName != null) {
versionName = "$variant.buildType.manifestPlaceholders.versionName"
}
newName += "_$versionName"
def buildNumber = System.env.OC_BUILD_NUMBER
if (buildNumber) {
newName += "_$buildNumber"
}
newName += originalName.substring(callerProject.archivesBaseName.length())
println "$variant.name: newName is $newName"
variant.outputs.all {
outputFileName = newName
}
}
static def getLatestGitHash() {
def process = "git rev-parse --short HEAD".execute()
return process.text.toString().trim()
}
static def getGitOriginRemote() {
def process = "git remote -v".execute()
def values = process.text.toString().trim().split("\\r\\n|\\n|\\r")
def found = values.find { it.startsWith("origin") && it.endsWith("(push)") }
return found.replace("origin", "").replace("(push)", "").replace(".git", "").trim()
}