-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathbuild.gradle
211 lines (180 loc) · 9.38 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
buildscript {
repositories {
mavenCentral()
google()
maven {
url = "https://plugins.gradle.org/m2/"
}
jcenter()
}
// We are restricted to room version 2.2.6 since we still offer Java 7 support. Upgrading to
// newer versions of room that require Java 8 will introduce a breaking change to our SDK
def java7SafeRoomVersion = "2.2.6"
// On M1 Macs, switch room version to 2.4.0 to fix java.lang.ExceptionInInitializerError
def m1MacSafeRoomVersion = "2.4.0"
// The 'CI' build variable will evaluate to 'true' when build script is executed via GitHub Actions
// Ref: https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
def roomVersion = System.getenv('CI') ? java7SafeRoomVersion : m1MacSafeRoomVersion
ext.versions = [
"kotlin" : "1.5.32",
"androidxTest" : "1.4.0",
"powermock" : '2.0.9',
"powermockLegacy": "1.7.4",
// NEXT MAJOR VERSION: Use a single up-to-date room version once we remove Java 7 support in favor of Java 11
"room" : roomVersion,
"playServices" : "19.1.0"
]
ext.deps = [
"appCompat" : "androidx.appcompat:appcompat:1.3.1",
"annotation" : "androidx.annotation:annotation:1.2.0",
"coreKtx" : "androidx.core:core-ktx:1.1.0",
// NEXT_MAJOR_VERSION: upgrade to 2.4.0 (or latest) when Java 7 support is explicitly dropped
"lifecycleRuntime" : "androidx.lifecycle:lifecycle-runtime:2.3.0",
"kotlinStdLib" : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}",
"kotlinTest" : "org.jetbrains.kotlin:kotlin-test-junit:${versions.kotlin}",
// This library doesn't seem to follow the versioning pattern of the other jetbrains
// kotlin libraries. Make sure to keep this dependency in line with the kotlin version used.
"kotlinCoroutinesCore" : "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2",
"browserSwitch" : "com.braintreepayments.api:browser-switch:2.3.2",
"cardinal" : "org.jfrog.cardinalcommerce.gradle:cardinalmobilesdk:2.2.7-2",
"samsungPay" : "com.samsung.android.spay:sdk:2.5.01",
"playServicesWallet" : "com.google.android.gms:play-services-wallet:${versions.playServices}",
// NEXT_MAJOR_VERSION: upgrade to 2.7.1 (or latest) when Java 7 support is explicitly dropped
"workKtx" : "androidx.work:work-runtime-ktx:2.7.0-alpha05",
"workTesting" : "androidx.work:work-testing:2.5.0",
"roomCompiler" : "androidx.room:room-compiler:${versions.room}",
"roomRuntime" : "androidx.room:room-runtime:${versions.room}",
"androidxTestRules" : "androidx.test:rules:${versions.androidxTest}",
"androidxTestRunner" : "androidx.test:runner:${versions.androidxTest}",
"androidxTestCore" : "androidx.test:core:${versions.androidxTest}",
"junit" : "junit:junit:4.13",
"junitTest" : "androidx.test.ext:junit:1.1.3",
"robolectric" : "org.robolectric:robolectric:4.1",
"dexmakerMockito" : "com.google.dexmaker:dexmaker-mockito:1.2",
"mockitoCore" : "org.mockito:mockito-core:3.6.0",
"jsonAssert" : "org.skyscreamer:jsonassert:1.5.0",
"assertJ" : "com.squareup.assertj:assertj-android:1.1.1",
"mockk" : "io.mockk:mockk:1.12.0",
"powermockJunit" : "org.powermock:powermock-module-junit4:${versions.powermock}",
"powermockRule" : "org.powermock:powermock-module-junit4-rule:${versions.powermock}",
"powermockMockito" : "org.powermock:powermock-api-mockito2:${versions.powermock}",
"powermockClassloading" : "org.powermock:powermock-classloading-xstream:${versions.powermock}",
// Legacy versions of the powermock libraries are required until 3DS and Visa Checkout tests can be updated to resolve robolectric/powermock test issues
"powermockJunitLegacy" : "org.powermock:powermock-module-junit4:${versions.powermockLegacy}",
"powermockRuleLegacy" : "org.powermock:powermock-module-junit4-rule:${versions.powermockLegacy}",
"powermockMockitoLegacy" : "org.powermock:powermock-api-mockito:${versions.powermockLegacy}",
"powermockClassloadingLegacy": "org.powermock:powermock-classloading-xstream:${versions.powermockLegacy}",
]
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.2'
classpath 'de.marcphilipp.gradle:nexus-publish-plugin:0.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5'
classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.7.20'
classpath 'org.jetbrains.dokka:android-documentation-plugin:1.7.20'
}
}
plugins {
id 'org.jetbrains.dokka' version '1.7.10'
id 'io.codearte.nexus-staging' version '0.21.2'
id 'de.marcphilipp.nexus-publish' version '0.4.0' apply false
}
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') ?: ''
ext["signing.password"] = System.getenv('SIGNING_KEY_PASSWORD') ?: ''
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_KEY_FILE') ?: ''
allprojects {
repositories {
mavenCentral()
google()
}
}
version '4.26.0'
ext {
compileSdkVersion = 33
minSdkVersion = 21
versionCode = 164
targetSdkVersion = 33
versionName = version
}
nexusStaging {
packageGroup = project.hasProperty('nexusPackageGroup') ? project.getProperty('nexusPackageGroup') : 'com.braintreepayments'
// give nexus sonatype more time to close the staging repository
delayBetweenRetriesInMillis = 20000
username = System.getenv('SONATYPE_USERNAME')
password = System.getenv('SONATYPE_PASSWORD')
}
subprojects {
repositories {
maven {
url "https://cardinalcommerceprod.jfrog.io/artifactory/android"
credentials {
username 'braintree_team_sdk'
password 'AKCp8jQcoDy2hxSWhDAUQKXLDPDx6NYRkqrgFLRc3qDrayg6rrCbJpsKKyMwaykVL8FWusJpp'
}
}
flatDir {
dirs "${rootDir}/libs"
}
jcenter()
}
}
dokkaHtmlMultiModule.configure {
// redirect dokka output to GitHub pages root directory
outputDirectory.set(project.file("docs"))
}
task changeGradleReleaseVersion {
doLast {
def gradleFile = new File('build.gradle')
def gradleFileText = gradleFile.text.replaceFirst("\\nversion '\\d+\\.\\d+\\.\\d+(-.*)?'", "\nversion '" + versionParam + "'")
gradleFile.write(gradleFileText)
}
}
task changeREADMEVersion {
doLast {
def readmeFile = new File('README.md')
def readmeFileText = readmeFile.text.replaceFirst(":card:\\d+\\.\\d+\\.\\d+'", ":card:" + versionParam + "'")
readmeFile.write(readmeFileText)
}
}
task changeMigrationGuideVersion {
doLast {
def migrationGuideFile = new File('v4_MIGRATION_GUIDE.md')
def migrationGuideFileText = migrationGuideFile.text.replaceAll(":\\d+\\.\\d+\\.\\d+(-.*)?'", ":" + versionParam + "'")
migrationGuideFile.write(migrationGuideFileText)
def newMigrationGuideFile = new File('v4.9.0+_MIGRATION_GUIDE.md')
def newMigrationGuideFileText = newMigrationGuideFile.text.replaceAll(":\\d+\\.\\d+\\.\\d+(-.*)?'", ":" + versionParam + "'")
newMigrationGuideFile.write(newMigrationGuideFileText)
}
}
task updateCHANGELOGVersion {
doLast {
def changelogFile = new File('CHANGELOG.md')
def changelogFileText = changelogFile.text.replaceFirst("## unreleased", "## " + versionParam)
changelogFile.write(changelogFileText)
}
}
task incrementSNAPSHOTVersion {
doLast {
def gradleFile = new File('build.gradle')
def (major, minor, patch) = versionParam.tokenize('.')
def patchInteger = patch.toInteger()
def newVersion = "$major.$minor.${patchInteger + 1}-SNAPSHOT"
def gradleFileText = gradleFile.text.replaceFirst("\\nversion '\\d+\\.\\d+\\.\\d+(-.*)?'", "\nversion '" + newVersion + "'")
gradleFile.write(gradleFileText)
// update README snapshot version
def readmeFile = new File('README.md')
def readmeFileText = readmeFile.text.replaceFirst(":card:\\d+\\.\\d+\\.\\d+-SNAPSHOT'", ":card:" + newVersion + "'")
readmeFile.write(readmeFileText)
}
}
task incrementVersionCode {
doLast {
def gradleFile = new File('build.gradle')
def versionText = gradleFile.text.find("versionCode = \\d+")
def params = versionText.split("=")
def newVersionCode = params[1].trim().toInteger() + 1
def gradleFileText = gradleFile.text.replaceFirst("versionCode = \\d+", "versionCode = " + newVersionCode)
gradleFile.write(gradleFileText)
}
}