-
Notifications
You must be signed in to change notification settings - Fork 37
/
build.gradle
210 lines (175 loc) · 7.79 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
plugins {
alias(sharedLibs.plugins.android.application)
alias(sharedLibs.plugins.kotlin.android)
alias(sharedLibs.plugins.kotlin.parcelize)
alias(sharedLibs.plugins.kotlin.kapt)
}
android {
namespace "org.wordpress.android.fluxc.example"
compileSdkVersion rootProject.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
defaultConfig {
applicationId "org.wordpress.android.fluxc.example"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments += [
"room.schemaLocation":"$projectDir/schemas".toString(),
"room.incremental":"true",
"room.expandProjection":"true"]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
// Don't use the test orchestrator yet, some of our connected testsare sharing state to reduce network
// pressure on the API (authentication/fetch profile/fetch sites).
// Uncomment the next line to enable the Orchestrator.
// execution 'ANDROID_TEST_ORCHESTRATOR'
unitTests.includeAndroidResources = true
unitTests.all {
if (project.hasProperty('testsMaxHeapSize')) {
// maxHeapSize for tests is not limited unless we give an explicit value
// See https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html
maxHeapSize project.properties.get('testsMaxHeapSize')
}
}
}
lint {
lintConfig file("${project.rootDir}/config/lint/lint.xml")
enable += 'UnknownNullness'
}
buildFeatures {
buildConfig true
viewBinding true
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.15"
}
sourceSets {
// Adds exported schema location as test app assets.
getByName("androidTest").assets.srcDirs += "$projectDir/../fluxc/schemas"
}
}
if (["tests.properties", "tests.properties-extra"].any { file(it).exists() }) {
throw new InvalidUserDataException("'example/tests.properties' and 'example/tests.properties-extra' property files are deprecated. Please see 'example/properties-example/README.md' for details.")
}
android.buildTypes.all { buildType ->
// Add properties named "wp.xxx" to our BuildConfig
Properties apiProperties = loadPropertiesOrUseExampleProperties("api.properties",
"example app can't access WordPress.com servers")
apiProperties.any { property ->
if (property.key.toLowerCase().startsWith("wp.")) {
buildType.buildConfigField "String", property.key.replace("wp.", "").replace(".", "_").toUpperCase(),
"\"${property.value}\""
}
}
// Load test properties and add them to BuildConfig
Properties testProperties = loadPropertiesOrUseExampleProperties("tests.properties",
"tests won't pass")
testProperties.any { property ->
buildType.buildConfigField "String", property.key.replace(".", "_").toUpperCase(), "\"${property.value}\""
}
}
dependencies {
implementation project(':fluxc')
implementation project(':plugins:woocommerce')
implementation sharedLibs.androidx.appcompat
implementation sharedLibs.androidx.swiperefreshlayout
implementation sharedLibs.androidx.recyclerview
implementation sharedLibs.androidx.constraintlayout
implementation sharedLibs.androidx.annotation
implementation sharedLibs.androidx.lifecycle.runtime.ktx
implementation(sharedLibs.wordpress.utils) {
// Using official volley package
exclude group: "com.mcxiaoke.volley"
exclude group: "com.android.support"
}
implementation sharedLibs.google.gson
testImplementation sharedLibs.androidx.room.runtime
androidTestImplementation sharedLibs.androidx.room.runtime
androidTestImplementation sharedLibs.androidx.room.testing
// Dagger
implementation sharedLibs.google.dagger
kapt sharedLibs.google.dagger.compiler
compileOnly sharedLibs.glassfish.javax.annotation
implementation sharedLibs.google.dagger.android.support
kapt sharedLibs.google.dagger.android.processor
testImplementation sharedLibs.junit
testImplementation sharedLibs.kotlin.test.junit
testImplementation sharedLibs.robolectric
testImplementation sharedLibs.androidx.test.core
testImplementation sharedLibs.mockito.core
testImplementation sharedLibs.mockito.kotlin
testImplementation sharedLibs.assertj.core
testImplementation sharedLibs.androidx.arch.core.testing
implementation sharedLibs.androidx.compose.material
implementation sharedLibs.androidx.compose.ui.tooling
androidTestImplementation sharedLibs.assertj.core
androidTestImplementation sharedLibs.androidx.arch.core.testing
androidTestCompileOnly sharedLibs.glassfish.javax.annotation
// Test orchestrator
androidTestImplementation sharedLibs.androidx.test.runner
androidTestUtil sharedLibs.androidx.test.orchestrator
androidTestImplementation "com.goterl:lazysodium-android:5.0.2@aar"
androidTestImplementation "net.java.dev.jna:jna:5.5.0@aar"
// Debug dependencies
debugImplementation sharedLibs.facebook.flipper
debugImplementation sharedLibs.facebook.soloader
debugImplementation sharedLibs.facebook.flipper.network.plugin
// Coroutines
implementation platform("androidx.compose:compose-bom:2024.04.00")
implementation 'androidx.compose.material:material'
implementation sharedLibs.kotlinx.coroutines.core
implementation sharedLibs.kotlinx.coroutines.android
lintChecks sharedLibs.wordpress.lint
}
def loadPropertiesOrUseExampleProperties(fileName, warningDetail) {
Properties properties = new Properties()
File propertiesFile = file(propertiesFilePath(fileName))
if (propertiesFile.exists()) {
properties.load(new InputStreamReader(new FileInputStream(propertiesFile), "utf-8"))
} else {
def examplePropertiesFilePath = examplePropertiesFilePath(fileName)
logger.quiet("WARNING: you're using the '$examplePropertiesFilePath' file - $warningDetail")
properties.load(new InputStreamReader(new FileInputStream(file(examplePropertiesFilePath)), "utf-8"))
}
return properties
}
def propertiesFilePath(fileName) {
return "properties/$fileName"
}
def examplePropertiesFilePath(fileName) {
return "properties-example/$fileName"
}
tasks.register("combineTestsPropertiesWithExtraTestsProperties") {
doLast {
Properties properties = new Properties()
File testsProperties = file(propertiesFilePath("tests.properties"))
File testsPropertiesExtra = file(propertiesFilePath("tests.properties-extra"))
if (testsProperties.exists()) {
properties.load(new InputStreamReader(new FileInputStream(testsProperties), "utf-8"))
}
if (testsPropertiesExtra.exists()) {
properties.load(new InputStreamReader(new FileInputStream(testsPropertiesExtra), "utf-8"))
}
def comment = "This file is generated by combineTestsPropertiesWithExtraTestsProperties Gradle task which combines existing tests.properties file with tests.properties-extra file. It prioritizes the values in tests.properties-extra file"
properties.store(new FileOutputStream(testsProperties), comment)
}
}