forked from paypal/paypal-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
249 lines (215 loc) · 9.94 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
buildscript {
ext.modules = [
"sdkVersionName" : "1.3.1-SNAPSHOT",
"demoAppVersionCode" : 4,
"androidMinSdkVersion": 21,
"androidTargetVersion": 30
]
ext.versions = [
"kotlin" : "1.8.21",
"compose": "1.4.7",
"hilt" : "2.44"
]
ext.deps = [
// Kotlin
"kotlinStdLib" : "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}",
// Android
"androidxCoreKtx" : "androidx.core:core-ktx:1.6.0",
"androidxAppcompat" : "androidx.appcompat:appcompat:1.3.1",
"material" : "com.google.android.material:material:1.4.0",
"constraintLayout" : "androidx.constraintlayout:constraintlayout:2.1.0",
"kotlinxAndroidCoroutines" : "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1",
"androidxLifecycleRuntimeKtx" : "androidx.lifecycle:lifecycle-runtime-ktx:2.4.1",
"androidxLifecycleCommonJava" : "androidx.lifecycle:lifecycle-common-java8:2.4.1",
"fragmentKtx" : "androidx.fragment:fragment-ktx:1.6.0",
// Jetpack Compose
// Ref: https://developer.android.com/jetpack/compose/setup#setup-compose
"composeMaterial3" : "androidx.compose.material3:material3",
"composeUi" : "androidx.compose.ui:ui",
"composeUiTestJUnit4" : "androidx.compose.ui:ui-test-junit4",
"composeUiTestManifest" : "androidx.compose.ui:ui-test-manifest",
"composeUiTooling" : "androidx.compose.ui:ui-tooling",
"composeUiToolingPreview" : "androidx.compose.ui:ui-tooling-preview",
"composeRuntimeLivedata" : "androidx.compose.runtime:runtime-livedata",
"composeFoundation" : "androidx.compose.foundation:foundation",
"composeMaterial" : "androidx.compose.material:material",
"composeConstraintLayout" : "androidx.constraintlayout:constraintlayout-compose",
"lifecycleViewModelCompose" : "androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1",
"lifecycleRuntimeCompose" : "androidx.lifecycle:lifecycle-runtime-compose:2.6.1",
"navigationCompose" : "androidx.navigation:navigation-compose:2.7.5",
"hiltNavigationCompose" : "androidx.hilt:hilt-navigation-compose:1.1.0",
// Jetpack
"preference" : "androidx.preference:preference-ktx:1.1.1",
// Networking
"retrofit" : "com.squareup.retrofit2:retrofit:2.9.0",
"gson" : "com.squareup.retrofit2:converter-gson:2.3.0",
"loggingInterceptor" : "com.squareup.okhttp3:logging-interceptor:4.9.2",
// Dependency Injection
"hilt" : "com.google.dagger:hilt-android:${versions.hilt}",
"hiltKapt" : "com.google.dagger:hilt-compiler:${versions.hilt}",
// Browser Switch
"browserSwitch" : "com.braintreepayments.api:browser-switch:2.3.1",
// Testing
"junit" : "junit:junit:4.13.2",
"androidxJUnit" : "androidx.test.ext:junit:1.1.5",
"androidxEspressoCore" : "androidx.test.espresso:espresso-core:3.4.0",
"androidxTestCore" : "androidx.test:core:1.5.0",
"androidxTestRunner" : "androidx.test:runner:1.5.2",
"androidxTestRules" : "androidx.test:rules:1.5.0",
"androidxTestUiAutomator" : "androidx.test.uiautomator:uiautomator:2.2.0",
"mockk" : "io.mockk:mockk:1.13.5",
"kotlinxAndroidCoroutinesTest": "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.1",
"robolectric" : "org.robolectric:robolectric:4.10.3",
"jsonAssert" : "org.skyscreamer:jsonassert:1.4.0",
"striktMockk" : "io.strikt:strikt-mockk:0.30.1",
"striktCore" : "io.strikt:strikt-core:0.30.1",
"json" : "org.json:json:20220320",
// PayPal
"nativeCheckout" : "com.paypal.checkout:android-sdk:1.2.1",
// Release modules
"cardPayments" : "com.paypal.android:card-payments:${modules.sdkVersionName}",
"paymentButtons" : "com.paypal.android:payment-buttons:${modules.sdkVersionName}",
"paypalWebPayments" : "com.paypal.android:paypal-web-payments:${modules.sdkVersionName}",
"paypalNativePayments" : "com.paypal.android:paypal-native-payments:${modules.sdkVersionName}",
"fraudProtection" : "com.paypal.android:fraud-protection:${modules.sdkVersionName}",
]
repositories {
google()
}
dependencies {
classpath "com.android.tools.build:gradle:7.4.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath "com.dicedmelon.gradle:jacoco-android:0.1.5"
classpath "com.google.dagger:hilt-android-gradle-plugin:${versions.hilt}"
}
}
plugins {
id "io.gitlab.arturbosch.detekt" version "${detektVersion}"
id 'org.jetbrains.kotlin.android' version '1.5.30' apply false
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
}
version modules.sdkVersionName // we add it here so that nexus automatically chooses staging or snapshot repo
nexusPublishing {
repositories {
sonatype {
username = System.getenv('SONATYPE_NEXUS_USERNAME') ?: ''
password = System.getenv('SONATYPE_NEXUS_PASSWORD') ?: ''
repositoryDescription = "Paypal Android SDK"
packageGroup = "com.paypal"
}
}
transitionCheckOptions {
// give nexus sonatype more time to close the staging repository
delayBetween.set(Duration.ofSeconds(20))
}
}
allprojects {
repositories {
google()
mavenCentral()
mavenLocal()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
url "https://cardinalcommerceprod.jfrog.io/artifactory/android"
credentials {
username cardinalUsername
password cardinalPassword
}
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
dependencies {
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:${detektVersion}"
detektPlugins "io.gitlab.arturbosch.detekt:detekt-rules-libraries:${detektVersion}"
}
detekt {
toolVersion = detektVersion
config = files("detekt/detekt-config.yml")
input = files(
"CorePayments/src",
"CardPayments/src",
"PayPalWebPayments/src",
"PayPalNativePayments/src",
"FraudProtection/src",
"Demo/src"
)
autoCorrect = project.hasProperty('detektAutoCorrect')
reports {
html {
enabled = true
destination = file("build/reports/detekt_report.html")
}
}
}
subprojects {
configurations.all {
resolutionStrategy {
eachDependency { details ->
if ('org.jacoco' == details.requested.group) {
details.useVersion "0.8.7"
}
}
}
}
}
subprojects {
group = "com.paypal.android"
}
task incrementSnapshotVersion {
doLast {
def topLevelGradleFile = file('./build.gradle')
def topLevelGradleFileText = topLevelGradleFile.getText('UTF-8')
def matcher = topLevelGradleFileText =~ /"sdkVersionName"\s*: "(.*)",/
def versionString = matcher[0][1]
def (major, minor, patch) = versionString.tokenize('.')
def patchInteger = (patch.endsWith('-SNAPSHOT') ? patch - '-SNAPSHOT' : patch).toInteger()
def newVersion = "$major.$minor.${patchInteger + 1}-SNAPSHOT"
def updatedScript =
topLevelGradleFileText.replaceFirst(/("sdkVersionName"\s*: )".*",/, '$1"' + newVersion + '",')
topLevelGradleFile.write(updatedScript, 'UTF-8')
}
}
//./gradlew -PversionParam=0.0.1 changeReleaseVersion
task changeReleaseVersion {
doLast {
def topLevelGradleFile = file('./build.gradle')
def topLevelGradleFileText = topLevelGradleFile.getText('UTF-8')
def updatedScript =
topLevelGradleFileText.replaceFirst(/("sdkVersionName"\s*: )".*",/, '$1"' + versionParam + '",')
topLevelGradleFile.write(updatedScript, 'UTF-8')
}
}
task getDemoAppVersionCode {
doLast {
def topLevelGradleFile = file('./build.gradle')
def topLevelGradleFileText = topLevelGradleFile.getText('UTF-8')
def matcher = topLevelGradleFileText =~ /"demoAppVersionCode"\s*: ([0-9]*),/
def versionCode = matcher[0][1].toInteger()
println(versionCode)
}
}
//./gradlew -PdemoAppVersionCodeParam=0.0.1 changeReleaseVersion
task setDemoAppVersionCode {
doLast {
def topLevelGradleFile = file('./build.gradle')
def topLevelGradleFileText = topLevelGradleFile.getText('UTF-8')
def updatedScript =
topLevelGradleFileText.replaceFirst(/("demoAppVersionCode"\s*: )[0-9]*,/, '$1' + demoAppVersionCodeParam + ',')
topLevelGradleFile.write(updatedScript, 'UTF-8')
}
}
//./gradlew -PversionParam=0.0.1 changeReleaseVersion
task updateCHANGELOGVersion {
doLast {
def date = new Date()
def formattedDate = date.format('yyyy-MM-dd')
def changelogFile = new File('CHANGELOG.md')
def changelogFileText = changelogFile.text.replaceFirst("## unreleased", "## " + versionParam + " ($formattedDate)")
changelogFile.write(changelogFileText)
}
}