Skip to content

Commit 97ca436

Browse files
feat: gcp support implementation
1 parent 6b17ad9 commit 97ca436

File tree

5 files changed

+66
-90
lines changed

5 files changed

+66
-90
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ lib/
4545
src/androidTest/java/com/builtio/contentstack/ApplicationTest.java
4646
src/main/res/
4747
contentstack/src/androidTest/java/com/contentstack/sdk/SyncTestCase.java
48+
49+
# key file
50+
key.keystore

contentstack/build.gradle

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ plugins {
44
}
55

66
import com.vanniktech.maven.publish.SonatypeHost
7+
78
android.buildFeatures.buildConfig true
89

910
mavenPublishing {
1011
publishToMavenCentral(SonatypeHost.DEFAULT)
1112
signAllPublications()
12-
coordinates("com.contentstack.sdk", "android", "3.14.0")
13+
coordinates("com.contentstack.sdk", "android", "3.13.0")
1314

1415
pom {
1516
name = "contentstack-android"
@@ -39,7 +40,23 @@ mavenPublishing {
3940
}
4041
}
4142

43+
44+
tasks.register('jacocoTestReport', JacocoReport) {
45+
dependsOn['testDebugUnitTest', 'createDebugCoverageReport']
46+
reports {
47+
html.enabled = true
48+
}
49+
afterEvaluate {
50+
classDirectories.setFrom(files(classDirectories.files.collect {
51+
fileTree(dir: it, exclude: '**com/contentstack/okhttp**')
52+
fileTree(dir: it, exclude: '**com/contentstack/okio**')
53+
fileTree(dir: it, exclude: '**com/contentstack/txtmark**')
54+
}))
55+
}
56+
}
57+
4258
android {
59+
//namespace "com.contentstack.sdk"
4360
packagingOptions {
4461
exclude("META-INF/DEPENDENCIES")
4562
exclude("META-INF/LICENSE")
@@ -52,12 +69,10 @@ android {
5269
exclude("META-INF/*.kotlin_module")
5370
}
5471

55-
5672
testOptions {
5773
unitTests.all {
5874
jacoco {
5975
includeNoLocationClasses = true
60-
excludes = ['jdk.internal.*']
6176
}
6277
}
6378
}
@@ -77,6 +92,7 @@ android {
7792
}
7893
compileSdk 30
7994
defaultConfig {
95+
// Required when setting minSdkVersion to 20 or lower
8096
multiDexEnabled true
8197
minSdkVersion 23
8298
versionCode 1
@@ -94,6 +110,7 @@ android {
94110
debuggable true
95111
testCoverageEnabled true
96112
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
113+
97114
buildConfigField "String", "host", localProperties['host']
98115
buildConfigField "String", "APIKey", localProperties['APIKey']
99116
buildConfigField "String", "deliveryToken", localProperties['deliveryToken']
@@ -115,12 +132,14 @@ android {
115132
}
116133
configurations { archives }
117134
dependencies {
135+
def multidex = "2.0.1"
118136
def volley = "1.2.1"
119137
def junit = "4.13.2"
120138
configurations.configureEach { resolutionStrategy.force 'com.android.support:support-annotations:23.1.0' }
121139
implementation fileTree(include: ['*.jar'], dir: 'libs')
122140
implementation "com.android.volley:volley:$volley"
123141
implementation "junit:junit:$junit"
142+
// For AGP 7.4+
124143
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
125144
testImplementation 'junit:junit:4.13.2'
126145
androidTestImplementation 'androidx.test:core:1.5.0'
@@ -139,5 +158,6 @@ tasks.register('createJar', Jar) {
139158
archivesBaseName = "contentstack.jar"
140159
from('build/contentstack-jar/')
141160
include 'com/contentstack/'
161+
//include 'META-INF/'
142162
}
143163
createJar.dependsOn(clearJar, unzip, build)

contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,17 @@ public void test_AZURE_NA() throws Exception {
178178
stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config);
179179
}
180180

181+
@Test
182+
public void test_GCP_NA() throws Exception {
183+
Config config = new Config();
184+
String DEFAULT_API_KEY = BuildConfig.APIKey;
185+
String DEFAULT_DELIVERY_TOKEN = BuildConfig.deliveryToken;
186+
String DEFAULT_ENV = BuildConfig.environment;
187+
String DEFAULT_HOST = BuildConfig.host;
188+
config.setHost(DEFAULT_HOST);
189+
config.setRegion(Config.ContentstackRegion.GCP_NA);
190+
Context appContext = InstrumentationRegistry.getTargetContext();
191+
stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config);
192+
}
193+
181194
}

contentstack/src/main/java/com/contentstack/sdk/Config.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public void setBranch(String branch) {
5252
* config.setRegion(ContentstackRegion.EU);
5353
* config.setRegion(ContentstackRegion.AZURE_EU);
5454
* config.setRegion(ContentstackRegion.AZURE_NA);
55+
* config.setRegion(ContentstackRegion.GCP_NA);
5556
* }
5657
* </pre>
5758
*/
@@ -77,7 +78,7 @@ public Config earlyAccess(String[] earlyAccess) {
7778
return this;
7879
}
7980

80-
public enum ContentstackRegion {US, EU, AZURE_NA, AZURE_EU}
81+
public enum ContentstackRegion {US, EU, AZURE_NA, AZURE_EU, GCP_NA}
8182

8283
/**
8384
* Config constructor

0 commit comments

Comments
 (0)