Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

getExtOrDefault KotlinVersionΒ #268

@nmgrinko

Description

@nmgrinko

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/react-native-text-input-mask/android/build.gradle b/node_modules/react-native-text-input-mask/android/build.gradle
index c94f33f..e799b3a 100644
--- a/node_modules/react-native-text-input-mask/android/build.gradle
+++ b/node_modules/react-native-text-input-mask/android/build.gradle
@@ -1,17 +1,17 @@
 apply plugin: 'com.android.library'
 apply plugin: 'kotlin-android'
 
-def safeExtGet(prop, fallback) {
-    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
+def getExtOrDefault(name) {
+    return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RNTextInputMask_' + name]
 }
 
 android {
-    compileSdkVersion safeExtGet('compileSdkVersion', 28)
-    buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
+    compileSdkVersion getExtOrDefault('compileSdkVersion')
+    buildToolsVersion getExtOrDefault('buildToolsVersion')
 
     defaultConfig {
-        minSdkVersion safeExtGet('minSdkVersion', 16)
-        targetSdkVersion safeExtGet('targetSdkVersion', 28)
+        minSdkVersion getExtOrDefault('minSdkVersion')
+        targetSdkVersion getExtOrDefault('targetSdkVersion')
         versionCode 1
         versionName "1.0.0"
     }
@@ -26,6 +26,8 @@ android {
 }
 
 buildscript {
+    def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNTextInputMask_kotlinVersion']
+
     ext {
         kotlinVersion = '1.4.31'
     }
@@ -36,7 +38,7 @@ buildscript {
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:4.1.3'
-        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${project.ext.kotlinVersion}"
+        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
     }
 }
 
@@ -50,8 +52,10 @@ repositories {
     }
 }
 
+def kotlin_version = getExtOrDefault('kotlinVersion')
+
 dependencies {
     implementation 'com.facebook.react:react-native:+'
     implementation 'com.redmadrobot:input-mask-android:6.0.0'
-    implementation "org.jetbrains.kotlin:kotlin-stdlib:${project.ext.kotlinVersion}"
+    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
 }
diff --git a/node_modules/react-native-text-input-mask/android/gradle.properties b/node_modules/react-native-text-input-mask/android/gradle.properties
new file mode 100644
index 0000000..d3512df
--- /dev/null
+++ b/node_modules/react-native-text-input-mask/android/gradle.properties
@@ -0,0 +1,5 @@
+RNTextInputMask_kotlinVersion = 1.5.20
+RNTextInputMask_compileSdkVersion = 28
+RNTextInputMask_buildToolsVersion = 28.0.3
+RNTextInputMask_minSdkVersion = 16
+RNTextInputMask_targetSdkVersion = 28
\ No newline at end of file

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions