Skip to content

Commit

Permalink
Update codepush.gradle (#2471)
Browse files Browse the repository at this point in the history
* Update codepush.gradle 

config was receiving an ArrayList as a false case, but ArrayLists don't support get() method, so it should receive a Map instance.

* Fix get on null object

Add more verifications for config variable

---------

Co-authored-by: Anatoly Pristensky <[email protected]>
Co-authored-by: MikhailSuendukov <[email protected]>
Co-authored-by: Dima <[email protected]>
  • Loading branch information
4 people committed Jun 27, 2024
1 parent ca3fd56 commit 5addacb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions android/codepush.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import java.nio.file.Paths;

def config = project.extensions.findByName("react") ?: []
def bundleAssetName = config.bundleAssetName.get() ?: "index.android.bundle"
def config = project.extensions.findByName("react") ?: [:]
def bundleAssetName = config.bundleAssetName ? config.bundleAssetName.get() : "index.android.bundle"

// because elvis operator
def elvisFile(thing) {
Expand All @@ -24,7 +24,7 @@ android.buildTypes.each { buildType ->
}

gradle.projectsEvaluated {
def debuggableVariants = config.debuggableVariants.get() ?: ['debug']
def debuggableVariants = config.debuggableVariants ? config.debuggableVariants.get() : ['debug']

android.applicationVariants.all { variant ->
// No code push for debuggable variants
Expand All @@ -49,8 +49,8 @@ gradle.projectsEvaluated {
def jsBundleFile;

// Additional node commandline arguments
def nodeExecutableAndArgs = config.nodeExecutableAndArgs.get() ?: ["node"]
def extraPackagerArgs = config.extraPackagerArgs.get() ?: []
def nodeExecutableAndArgs = config.nodeExecutableAndArgs ? config.nodeExecutableAndArgs.get(): ["node"]
def extraPackagerArgs = config.extraPackagerArgs ? config.extraPackagerArgs.get() : []

// Make this task run right after the bundle task
def generateBundledResourcesHash;
Expand All @@ -77,11 +77,11 @@ gradle.projectsEvaluated {
runBefore("merge${targetName}Assets", generateBundledResourcesHash)
} else {
def jsBundleDirConfigName = "jsBundleDir${targetName}"
jsBundleDir = elvisFile(config."$jsBundleDirConfigName").get() ?:
jsBundleDir = elvisFile(config."$jsBundleDirConfigName") ? elvisFile(config."$jsBundleDirConfigName").get():
file("$buildDir/intermediates/assets/${targetPath}")

def resourcesDirConfigName = "resourcesDir${targetName}"
resourcesDir = elvisFile(config."${resourcesDirConfigName}").get() ?:
resourcesDir = elvisFile(config."${resourcesDirConfigName}") ? elvisFile(config."${resourcesDirConfigName}").get():
file("$buildDir/intermediates/res/merged/${targetPath}")

// In case version of 'Android Plugin for Gradle'' is lower than 1.3.0
Expand Down

0 comments on commit 5addacb

Please sign in to comment.