diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f50e6baa..9d241b91 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -33,36 +33,36 @@ jobs: # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: Checkout repository + uses: actions/checkout@v3 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) -# - name: Autobuild -# uses: github/codeql-action/autobuild@v2 + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality - # ℹ️ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - # If the Autobuild fails above, remove it and uncomment the following three lines. - # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 - # - run: | - # echo "Run, Build Application using script" - # ./location_of_script_within_repo/buildscript.sh + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun -# - name: Perform CodeQL Analysis -# uses: github/codeql-action/analyze@v2 + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml index 681132d2..7fa03ee3 100644 --- a/.github/workflows/sca-scan.yml +++ b/.github/workflows/sca-scan.yml @@ -7,9 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - name: Run Snyk to check for vulnerabilities - uses: snyk/actions/gradle@master + - uses: snyk/actions/setup@master + - run: snyk test env: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} - with: - args: --fail-on=all diff --git a/LICENSE b/LICENSE index 8e6d8312..0eb1a11a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2012 - 2023 Contentstack +Copyright (c) 2012 - 2024 Contentstack Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index fc429324..62856166 100644 --- a/README.md +++ b/README.md @@ -261,7 +261,7 @@ You can use advanced sync queries to fetch custom results while performing initi ### The MIT License (MIT) -Copyright © 2012-2023 [Contentstack](https://www.contentstack.com/). All Rights Reserved +Copyright © 2012-2024 [Contentstack](https://www.contentstack.com/). All Rights Reserved Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, diff --git a/SECURITY.md b/SECURITY.md index 3c4b0189..88da02e6 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,4 +1,4 @@ -## Security +# Security Contentstack takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations. @@ -14,14 +14,14 @@ You should receive a response within 24 hours. If for some reason you do not, pl Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: -* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) -* Full paths of source file(s) related to the manifestation of the issue -* The location of the affected source code (tag/branch/commit or direct URL) -* Any special configuration required to reproduce the issue -* Step-by-step instructions to reproduce the issue -* Proof-of-concept or exploit code (if possible) -* Impact of the issue, including how an attacker might exploit the issue +- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) +- Full paths of source file(s) related to the manifestation of the issue +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- Step-by-step instructions to reproduce the issue +- Proof-of-concept or exploit code (if possible) +- Impact of the issue, including how an attacker might exploit the issue This information will help us triage your report more quickly. -[https://www.contentstack.com/trust/](https://www.contentstack.com/trust/) \ No newline at end of file +[https://www.contentstack.com/trust/](https://www.contentstack.com/trust/) diff --git a/build.gradle b/build.gradle index 4fffe10f..dfe2f5ec 100644 --- a/build.gradle +++ b/build.gradle @@ -1,21 +1,24 @@ buildscript { - ext.jacoco_version = '0.8.8' + ext { + jacoco_version = '0.8.8' + agp_version = '8.2.1' + } repositories { - maven { url "https://plugins.gradle.org/m2/" } google() + maven { + url "https://plugins.gradle.org/m2/" + } mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:7.2.2" //7.0.4 - classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' + //classpath "com.android.tools.build:gradle:8.2.1" //8.2.1 + classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'io.github.gradle-nexus:publish-plugin:2.0.0-rc-1' classpath "org.jacoco:org.jacoco.core:$jacoco_version" } } -apply plugin: 'io.github.gradle-nexus.publish-plugin' -apply from: "${rootDir}/scripts/publish-root.gradle" - tasks.register('clean', Delete) { delete rootProject.buildDir } \ No newline at end of file diff --git a/contentstack/build.gradle b/contentstack/build.gradle index c086f8d9..06aa4346 100755 --- a/contentstack/build.gradle +++ b/contentstack/build.gradle @@ -1,27 +1,72 @@ -apply plugin: 'com.android.library' -apply plugin: 'jacoco' +plugins { + id "com.vanniktech.maven.publish" version "0.27.0" + id "com.android.library" +} -apply from: "${rootProject.projectDir}/scripts/publish-module.gradle" +import com.vanniktech.maven.publish.SonatypeHost -android { - compileSdk 33 - defaultConfig { - minSdk 19 - targetSdk 33 - versionCode 1 - versionName "1.0" - multiDexEnabled true - vectorDrawables.useSupportLibrary = true - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - signingConfig signingConfigs.debug +android.buildFeatures.buildConfig true + +mavenPublishing { + publishToMavenCentral(SonatypeHost.DEFAULT) + signAllPublications() + coordinates("com.contentstack.sdk", "android", "3.13.0") + + pom { + name = "contentstack-android" + description = "The Content Delivery SDK facilitates the retrieval of content from your Contentstack account, enabling seamless delivery to your web or mobile properties.." + inceptionYear = "2018" + packaging 'aar' + url = "https://github.com/contentstack/contentstack-android" + licenses { + license { + name = "The MIT License" + url = "https://github.com/contentstack/contentstack-android/blob/master/LICENSE" + distribution = "https://github.com/contentstack/contentstack-android/blob/master/LICENSE" + } + } + developers { + developer { + id = "ishaileshmishra" + name = "contentstack" + url = "https://github.com/contentstack/contentstack-android" + } + } + scm { + url = "scm:git@github.com:contentstack/contentstack-android" + connection = "scm:git:git://github.com/contentstack/contentstack-android.git" + developerConnection = "scm:git@github.com:contentstack/contentstack-android.git" + } } - buildTypes { - def localProperties = new Properties() - localProperties.load(new FileInputStream(rootProject.file("local.properties"))) +} + + +tasks.register('jacocoTestReport', JacocoReport) { + dependsOn['testDebugUnitTest', 'createDebugCoverageReport'] + reports { + html.enabled = true } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + afterEvaluate { + classDirectories.setFrom(files(classDirectories.files.collect { + fileTree(dir: it, exclude: '**com/contentstack/okhttp**') + fileTree(dir: it, exclude: '**com/contentstack/okio**') + fileTree(dir: it, exclude: '**com/contentstack/txtmark**') + })) + } +} + +android { + //namespace "com.contentstack.sdk" + packagingOptions { + exclude("META-INF/DEPENDENCIES") + exclude("META-INF/LICENSE") + exclude("META-INF/LICENSE.txt") + exclude("META-INF/license.txt") + exclude("META-INF/NOTICE") + exclude("META-INF/NOTICE.txt") + exclude("META-INF/notice.txt") + exclude("META-INF/ASL2.0") + exclude("META-INF/*.kotlin_module") } testOptions { @@ -30,20 +75,89 @@ android { includeNoLocationClasses = true } } - unitTests.returnDefaultValues = true } -} + signingConfigs { + debug { + storeFile file("/Users/shaileshmishra/keystore/key.keystore") + storePassword 'android' + keyAlias 'key0' + keyPassword 'android' + } + release { + storeFile file("/Users/shaileshmishra/keystore/key.keystore") + storePassword 'android' + keyAlias 'key0' + keyPassword 'android' + } + } + compileSdk 30 + defaultConfig { + // Required when setting minSdkVersion to 20 or lower + multiDexEnabled true + minSdkVersion 23 + versionCode 1 + versionName "1.0" + useLibrary 'org.apache.http.legacy' + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + signingConfig signingConfigs.release + } + + + def localProperties = new Properties() + localProperties.load(new FileInputStream(rootProject.file("local.properties"))) + buildTypes { + debug { + debuggable true + testCoverageEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + buildConfigField "String", "host", localProperties['host'] + buildConfigField "String", "APIKey", localProperties['APIKey'] + buildConfigField "String", "deliveryToken", localProperties['deliveryToken'] + buildConfigField "String", "environment", localProperties['environment'] + buildConfigField "String", "contentTypeUID", localProperties['contentType'] + buildConfigField "String", "assetUID", localProperties['assetUid'] + } + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + coreLibraryDesugaringEnabled true + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} +configurations { archives } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'com.android.volley:volley:1.2.1' - implementation 'androidx.test:core:1.5.0' + def multidex = "2.0.1" + def volley = "1.2.1" + def junit = "4.13.2" + configurations.configureEach { resolutionStrategy.force 'com.android.support:support-annotations:23.1.0' } + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation "com.android.volley:volley:$volley" + implementation "junit:junit:$junit" + // For AGP 7.4+ + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + androidTestImplementation 'androidx.test:core:1.5.0' + androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) +} +tasks.register('clearJar', Delete) { delete 'build/libs/contentstack.jar' } +tasks.register('unzip', Copy) { + def zipFile = file('build/intermediates/intermediate-jars/release/classes.jar') + def outputDir = file("${buildDir}/contentstack-jar") + from zipTree(zipFile) + into outputDir +} +tasks.register('createJar', Jar) { + archivesBaseName = "contentstack.jar" + from('build/contentstack-jar/') + include 'com/contentstack/' + //include 'META-INF/' } -java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} \ No newline at end of file +createJar.dependsOn(clearJar, unzip, build) diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java b/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java index a36735f3..5cca358e 100644 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java +++ b/contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java @@ -16,7 +16,6 @@ import androidx.test.InstrumentationRegistry; import androidx.test.core.app.ApplicationProvider; - @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class AssetTestCase { diff --git a/contentstack/src/androidTest/java/com/contentstack/sdk/QueryTestCase.java b/contentstack/src/androidTest/java/com/contentstack/sdk/QueryTestCase.java index 1fae20be..36996668 100644 --- a/contentstack/src/androidTest/java/com/contentstack/sdk/QueryTestCase.java +++ b/contentstack/src/androidTest/java/com/contentstack/sdk/QueryTestCase.java @@ -1,6 +1,5 @@ package com.contentstack.sdk; -import android.content.Context; import android.util.Log; import org.json.JSONArray; @@ -13,9 +12,6 @@ import static junit.framework.TestCase.assertEquals; -import androidx.test.InstrumentationRegistry; -import androidx.test.core.app.ApplicationProvider; - public class QueryTestCase { diff --git a/contentstack/src/main/java/com/contentstack/sdk/AssetsModel.java b/contentstack/src/main/java/com/contentstack/sdk/AssetsModel.java index 1ba82a22..ad68003b 100644 --- a/contentstack/src/main/java/com/contentstack/sdk/AssetsModel.java +++ b/contentstack/src/main/java/com/contentstack/sdk/AssetsModel.java @@ -11,7 +11,7 @@ */ class AssetsModel { - List objects = new ArrayList(); + List objects = new ArrayList<>(); public AssetsModel(JSONObject jsonObject, boolean isFromCache) { jsonObject = !isFromCache && jsonObject.opt("response") == null ? jsonObject : jsonObject.optJSONObject("response"); diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java b/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java index 5ba1f8b8..6d5e532d 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSConnectionRequest.java @@ -166,6 +166,7 @@ public void onRequestFailed(JSONObject error, int statusCode, ResultCallBack cal errorObject.setErrorCode(errorCode); errorObject.setErrorMessage(errorMessage); errorObject.setErrors(resultHashMap); + errorObject.setStatusCode(statusCode); if (this.callBackObject != null) { this.callBackObject.onRequestFail(ResponseType.NETWORK, errorObject); diff --git a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java index 73f8d3a0..cc87e7b1 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java +++ b/contentstack/src/main/java/com/contentstack/sdk/CSHttpConnection.java @@ -2,7 +2,6 @@ import android.text.TextUtils; import android.util.ArrayMap; -import android.util.Log; import com.android.volley.DefaultRetryPolicy; import com.android.volley.VolleyError; @@ -209,7 +208,7 @@ private String getParams(HashMap params) { } } catch (Exception e1) { - SDKUtil.showLog(TAG, "--------------------getQueryParam--||" + e1.toString()); + SDKUtil.showLog(TAG, "-getQueryParam--||" + e1.toString()); } } @@ -239,7 +238,7 @@ public void send() { } headers.put("Content-Type", "application/json"); headers.put("User-Agent", defaultUserAgent()); - headers.put("X-User-Agent", "contentstack-android/" + SDKConstant.SDK_VERSION); + headers.put("X-User-Agent", "contentstack-delivery-android/" + SDKConstant.SDK_VERSION); jsonObjectRequest = new JSONUTF8Request(requestId, url, requestJSON, response -> { this.responseJSON = response; if (this.responseJSON != null) { diff --git a/contentstack/src/main/java/com/contentstack/sdk/Config.java b/contentstack/src/main/java/com/contentstack/sdk/Config.java index 9711d67b..7d188ece 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Config.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Config.java @@ -2,6 +2,9 @@ import android.text.TextUtils; +import java.util.Objects; + + /** * Set Configuration for stack instance creation. * @@ -13,6 +16,7 @@ public class Config { protected String VERSION = "v3"; protected String environment = null; protected String branch = null; + protected String[] earlyAccess = null; /** @@ -43,13 +47,13 @@ public void setBranch(String branch) { * *

Example For Different Regions:
*
-     *               {@code
-     *               config.setRegion(ContentstackRegion.US);
-     *               config.setRegion(ContentstackRegion.EU);
-     *               config.setRegion(ContentstackRegion.AZURE_EU);
-     *               config.setRegion(ContentstackRegion.AZURE_NA);
-     *               }
-     *               
+ * {@code + * config.setRegion(ContentstackRegion.US); + * config.setRegion(ContentstackRegion.EU); + * config.setRegion(ContentstackRegion.AZURE_EU); + * config.setRegion(ContentstackRegion.AZURE_NA); + * } + * */ public ContentstackRegion setRegion(ContentstackRegion region) { this.region = region; @@ -61,6 +65,18 @@ public ContentstackRegion getRegion() { return this.region; } + public String[] getEarlyAccess() { + return this.earlyAccess; + } + + public Config earlyAccess(String[] earlyAccess) { + if (earlyAccess == null) { + Objects.requireNonNull("Null early access"); + } + this.earlyAccess = earlyAccess; + return this; + } + public enum ContentstackRegion {US, EU, AZURE_NA, AZURE_EU} /** diff --git a/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java b/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java index 19a7be25..97fe6402 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java +++ b/contentstack/src/main/java/com/contentstack/sdk/Contentstack.java @@ -7,9 +7,8 @@ import com.android.volley.RequestQueue; import com.android.volley.toolbox.Volley; -import org.jetbrains.annotations.NotNull; - import java.io.File; +import java.util.Objects; /** * Contains all Contentstack SDK Classes And Methods. @@ -44,7 +43,9 @@ private Contentstack(Context context) { * @return {@link Stack} instance.

Example :
 Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", "stag"); 
* @throws Exception the exception */ - public static Stack stack(@NotNull Context context, @NotNull String apiKey, @NotNull String deliveryToken, @NotNull String environment) throws Exception { + public static Stack stack(Context context, String apiKey, String deliveryToken, String environment) throws Exception { + checkIfNull(context, apiKey, deliveryToken, environment); + if (!TextUtils.isEmpty(apiKey) || !TextUtils.isEmpty(deliveryToken) || !TextUtils.isEmpty(environment)) { Config config = new Config(); config.setEnvironment(environment); @@ -55,6 +56,13 @@ public static Stack stack(@NotNull Context context, @NotNull String apiKey, @Not } } + private static void checkIfNull(Context context, String apiKey, String deliveryToken, String environment) { + Objects.requireNonNull(context, "can not be null"); + Objects.requireNonNull(apiKey, "can not be null"); + Objects.requireNonNull(deliveryToken, "can not be null"); + Objects.requireNonNull(environment, "can not be null"); + } + /** * Authenticates the stack api key of your stack. * This must be called before your stack uses Contentstack sdk. @@ -69,7 +77,9 @@ public static Stack stack(@NotNull Context context, @NotNull String apiKey, @Not * @return {@link Stack} instance.

Example :
 Config config = new Config(); config.setEnvironment("stag"); Stack stack = Contentstack.stack(context, "apiKey", "deliveryToken", config);
      * @throws Exception the exception
      */
-    public static Stack stack(@NotNull Context context, @NotNull String apiKey, @NotNull String deliveryToken, @NotNull String environment, @NotNull Config config) throws Exception {
+    public static Stack stack(Context context, String apiKey, String deliveryToken, String environment, Config config) throws Exception {
+        checkIfNull(context, apiKey, deliveryToken, environment);
+        Objects.requireNonNull(config, "Config can not be null");
         if (!TextUtils.isEmpty(apiKey) || !TextUtils.isEmpty(deliveryToken) || !TextUtils.isEmpty(environment)) {
             config.setEnvironment(environment);
             ctx = context;
@@ -87,6 +97,10 @@ private static Stack initializeStack(Context appContext, String apiKey, String d
         if (config.getBranch() != null) {
             stack.setHeader("branch", config.getBranch());
         }
+        if (config.getEarlyAccess() != null && config.getEarlyAccess().length > 0) {
+            String eaValues = String.join(",", config.earlyAccess).replace("\"", "");
+            stack.setHeader("x-header-ea", eaValues);
+        }
         stack.setConfig(config);
         initializeCache(appContext);
         return stack;
diff --git a/contentstack/src/main/java/com/contentstack/sdk/Error.java b/contentstack/src/main/java/com/contentstack/sdk/Error.java
index 9c73990a..b0c1bb87 100755
--- a/contentstack/src/main/java/com/contentstack/sdk/Error.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/Error.java
@@ -11,6 +11,16 @@ public class Error {
 
     String errorMessage = null;
     int errorCode = 0;
+
+    public int getStatusCode() {
+        return statusCode;
+    }
+
+    public void setStatusCode(int statusCode) {
+        this.statusCode = statusCode;
+    }
+
+    int statusCode = 0;
     HashMap errorHashMap = new HashMap<>();
 
     /**
diff --git a/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java b/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java
index 13e80796..1dbf54d2 100755
--- a/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/SDKConstant.java
@@ -9,7 +9,7 @@ public class SDKConstant {
     public static final boolean debug = false;
     public static boolean IS_NETWORK_AVAILABLE = true;
     public static String PROTOCOL = "https://";
-    public static String SDK_VERSION = "3.12.4";
+    public static String SDK_VERSION = "3.13.0";
     public final static int NO_NETWORK_CONNECTION = 408;
     public final static int TimeOutDuration = 30000; // timeout in millisecond
     public final static int NumRetry = 0;
diff --git a/contentstack/src/main/java/com/contentstack/sdk/Stack.java b/contentstack/src/main/java/com/contentstack/sdk/Stack.java
index 1671fb38..d5bcb87b 100755
--- a/contentstack/src/main/java/com/contentstack/sdk/Stack.java
+++ b/contentstack/src/main/java/com/contentstack/sdk/Stack.java
@@ -5,7 +5,6 @@
 import android.util.ArrayMap;
 import android.util.Log;
 
-import org.jetbrains.annotations.NotNull;
 import org.json.JSONException;
 import org.json.JSONObject;
 
@@ -51,7 +50,10 @@ public class Stack implements INotifyClass {
     protected Stack() {
     }
 
-    protected Stack(@NotNull String apiKey) {
+    protected Stack(String apiKey) {
+        if (apiKey==null){
+            Objects.requireNonNull("Please provide a valid ApiKey");
+        }
         this.stackApiKey = apiKey;
         if (this.localHeader == null) {
             this.localHeader = new ArrayMap<>();
@@ -224,7 +226,7 @@ public void setHeader(String key, String value) {
         }
     }
 
-    public void setHeaders(@NotNull ArrayMap headers) {
+    public void setHeaders(ArrayMap headers) {
         if (this.localHeader == null) {
             this.localHeader = new ArrayMap<>();
         }
@@ -289,17 +291,17 @@ private String getImageUrl() {
      *                 This call returns comprehensive information of all the content types available in a particular stack in your account.
      *                 

Example :
*
-     *                                                                                                                                                                                                                                                                                                                                                                                 JSONObject params = new JSONObject();
-     *                                                                                                                                                                                                                                                                                                                                                                                 params.put("include_snippet_schema", true);
-     *                                                                                                                                                                                                                                                                                                                                                                                 params.put("limit", 3);
-     *                                                                                                                                                                                                                                                                                                                                                                                 stack.getContentTypes(params, new ContentTypesCallback() {
-     *                                                                                                                                                                                                                                                                                                                                                                                 @Override  public void onCompletion(ContentTypesModel contentTypesModel, Error error) {
-     *                                                                                                                                                                                                                                                                                                                                                                                 if (error == null){
-     *                                                                                                                                                                                                                                                                                                                                                                                 // do your stuff.
-     *                                                                                                                                                                                                                                                                                                                                                                                 }
-     *                                                                                                                                                                                                                                                                                                                                                                                 }
-     *                                                                                                                                                                                                                                                                                                                                                                                 });
-     *                                                                                                                                                                                                                                                                                                                                                                                 
+ * JSONObject params = new JSONObject(); + * params.put("include_snippet_schema", true); + * params.put("limit", 3); + * stack.getContentTypes(params, new ContentTypesCallback() { + * @Override public void onCompletion(ContentTypesModel contentTypesModel, Error error) { + * if (error == null){ + * // do your stuff. + * } + * } + * }); + *
*/ public void getContentTypes(JSONObject params, final ContentTypesCallback callback) { try { @@ -350,9 +352,9 @@ private void fetchContentTypes(String urlString, JSONObject urlQueries, ArrayMap *

Example :
*
      *
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                         Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                         stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {}
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                         
+ * Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); + * stack.syncPaginationToken(pagination_token, new SyncResultCallBack()) {} + * */ public void sync(SyncResultCallBack syncCallBack) { @@ -402,7 +404,7 @@ public void syncPaginationToken(String paginationToken, SyncResultCallBack syncC * and the details of the content that was deleted or updated. *

Example :
*
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
+ * */ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { try { @@ -423,8 +425,8 @@ public void syncToken(String syncToken, SyncResultCallBack syncCallBack) { * *

Example :
*
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        stack.syncFromDate(start_date, new SyncResultCallBack()) { }
-     *                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
+ * stack.syncFromDate(start_date, new SyncResultCallBack()) { } + * */ public void syncFromDate(Date fromDate, SyncResultCallBack syncCallBack) { String startFromDate = convertUTCToISO(fromDate); @@ -494,7 +496,10 @@ public void syncLocale(Language language, SyncResultCallBack syncCallBack) { * However, if you do this, the subsequent syncs will only include the entries of the specified locales. * */ - public void syncLocale(@NotNull String localeCode, SyncResultCallBack syncCallBack) { + public void syncLocale(String localeCode, SyncResultCallBack syncCallBack) { + if (localeCode==null){ + Objects.requireNonNull("localeCode can not be null"); + } try { this.syncParams = new JSONObject(); this.syncParams.put("init", true); diff --git a/contentstack/src/main/java/com/contentstack/sdk/TestActivity.java b/contentstack/src/main/java/com/contentstack/sdk/TestActivity.java index 93f38c2a..c4c516c6 100755 --- a/contentstack/src/main/java/com/contentstack/sdk/TestActivity.java +++ b/contentstack/src/main/java/com/contentstack/sdk/TestActivity.java @@ -1,18 +1,13 @@ package com.contentstack.sdk; -import android.os.Bundle; - -import androidx.annotation.Nullable; -import androidx.appcompat.app.AppCompatActivity; - /** * @author Contentstack.com, Inc */ -public class TestActivity extends AppCompatActivity { - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } -} +//public class TestActivity extends AppCompatActivity { +// +// @Override +// protected void onCreate(@Nullable Bundle savedInstanceState) { +// super.onCreate(savedInstanceState); +// } +//} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8c0fb64a..033e24c4 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e5bcd27d..6b0e6c07 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,9 @@ -#Tue Dec 13 11:19:51 IST 2022 -#gradle-7.6-bin.zip distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +#distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +#distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 91a7e269..fcb6fca1 100755 --- a/gradlew +++ b/gradlew @@ -1,79 +1,126 @@ -#!/usr/bin/env bash +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum -warn ( ) { +warn () { echo "$*" -} +} >&2 -die ( ) { +die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -82,83 +129,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 8a0b282a..93e3f59f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,4 +1,20 @@ -@if "%DEBUG%" == "" @echo off +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -8,20 +24,24 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +55,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,44 +65,26 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/progaurd-rules.pro b/progaurd-rules.pro new file mode 100644 index 00000000..74e3df95 --- /dev/null +++ b/progaurd-rules.pro @@ -0,0 +1 @@ +-dontwarn java.lang.invoke.StringConcatFactory \ No newline at end of file diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle deleted file mode 100644 index 8b2f8df1..00000000 --- a/scripts/publish-module.gradle +++ /dev/null @@ -1,87 +0,0 @@ -apply plugin: 'maven-publish' -apply plugin: 'signing' - - -ext { - PUBLISH_GROUP_ID = 'com.contentstack.sdk' - PUBLISH_ARTIFACT_ID = 'android' - PUBLISH_VERSION = '3.12.4-SNAPSHOT' - POM_NAME = 'contentstack-android' - WEBSITE = 'http://www.contentstack.com' - PUBLISH_DESCRIPTION = 'The Content Delivery SDK is used to retrieve content from your Contentstack account and deliver it to your web or mobile properties.' - PUBLISH_URL = 'https://github.com/contentstack/contentstack-android' - PUBLISH_LICENSE_NAME = 'MIT License' - PUBLISH_LICENSE_URL = 'https://github.com/contentstack/contentstack-android/blob/master/LICENSE' - PUBLISH_DEVELOPER_ID = 'ishaileshmishra' - PUBLISH_DEVELOPER_NAME = 'Shailesh Mishra' - PUBLISH_DEVELOPER_EMAIL = 'mobile@contentstack.com' - PUBLISH_SCM_CONNECTION = 'scm:git@github.com:contentstack/contentstack-android' - SCM_DEVELOPER_CONNECTION = 'scm:git@github.com:contentstack/contentstack-android.git' - PUBLISH_SCM_URL = 'https://github.com/contentstack/contentstack-android/tree/master' -} - -tasks.register('androidSourcesJar', Jar) { - archiveClassifier.set('sources') - if (project.plugins.findPlugin("com.android.library")) { - from android.sourceSets.main.java.srcDirs - } else { - from sourceSets.main.java.srcDirs - } -} - -artifacts { - archives androidSourcesJar -} - - -afterEvaluate { - publishing { - publications { - aar(MavenPublication) { - groupId = PUBLISH_GROUP_ID - artifactId = PUBLISH_ARTIFACT_ID - version = PUBLISH_VERSION - if (project.plugins.findPlugin("com.android.library")) { - //from components.release - } else { - artifact("$buildDir/libs/${project.getName()}-${version}.jar") - } - artifact androidSourcesJar - pom { - name = POM_NAME - description = PUBLISH_DESCRIPTION - url = WEBSITE - - licenses { - license { - name = PUBLISH_LICENSE_NAME - url = PUBLISH_LICENSE_URL - } - } - developers { - developer { - id = PUBLISH_DEVELOPER_ID - name = PUBLISH_DEVELOPER_NAME - email = PUBLISH_DEVELOPER_EMAIL - } - } - scm { - connection = PUBLISH_SCM_CONNECTION - developerConnection = SCM_DEVELOPER_CONNECTION - url = PUBLISH_SCM_URL - } - } - } - } - } -} - - -ext["signing.keyId"] = rootProject.ext["signing.keyId"] -ext["signing.password"] = rootProject.ext["signing.password"] -ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"] - -signing { - sign publishing.publications -} - diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle deleted file mode 100644 index b7092b5b..00000000 --- a/scripts/publish-root.gradle +++ /dev/null @@ -1,52 +0,0 @@ -// Create variables with empty default values -ext["signing.keyId"] = '' -ext["signing.password"] = '' -ext["signing.secretKeyRingFile"] = '' -ext["ossrhUsername"] = '' -ext["ossrhPassword"] = '' -ext["sonatypeStagingProfileId"] = '' - -File secretPropsFile = project.rootProject.file('local.properties') -if (secretPropsFile.exists()) { - Properties p = new Properties() - new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } - p.each { name, value -> ext[name] = value } -} - -nexusPublishing { - repositories { -// sonatype { -// stagingProfileId = sonatypeStagingProfileId -// username = ossrhUsername -// password = ossrhPassword -// nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) -// snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/")) -// if (project.version.endsWith('-SNAPSHOT')) { -// snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots")) -// } else { -// nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) -// } -// } - -// sonatype { -// stagingProfileId = sonatypeStagingProfileId -// username = ossrhUsername -// password = ossrhPassword -// -// if (project.version.endsWith('-SNAPSHOT')) { -// snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots")) -// } else { -// nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) -// } -// } - - sonatype { - stagingProfileId = sonatypeStagingProfileId - username = ossrhUsername - password = ossrhPassword - //nexusUrl.set(uri("https://oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/")) - } - - } -} diff --git a/settings.gradle b/settings.gradle index b7965451..f699c255 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,18 +1,18 @@ pluginManagement { repositories { + google() mavenCentral() maven { url "https://plugins.gradle.org/m2/" } gradlePluginPortal() - google() } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { - mavenCentral() google() + mavenCentral() } } rootProject.name = "contentstack-android"