Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact(Android): convert example apps Groovy scripts to Kotlin #2126

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f57aa85
converted lib and example scripts to kotlin
alduzy May 9, 2024
1eb8276
fabric example scripts rewritten to kts
alduzy May 10, 2024
4dab18e
moved buildscript dependencies to settings
alduzy May 10, 2024
535d940
tests examples scripts rewritten to kotlin
alduzy May 10, 2024
aead09e
moved plugin application
alduzy May 10, 2024
d653bbb
Merge remote-tracking branch 'origin/main' into @alduzy/convert-groov…
alduzy May 10, 2024
0cfb8bc
Merge remote-tracking branch 'origin/main' into @alduzy/convert-groov…
alduzy May 10, 2024
09786f7
added missing plugin
alduzy May 13, 2024
7bab05b
Merge remote-tracking branch 'origin/main' into @alduzy/convert-groov…
alduzy May 13, 2024
f416871
lint fix
alduzy May 13, 2024
5d9adbd
moved back to previous error
alduzy May 13, 2024
c4f7cfa
Merge remote-tracking branch 'origin/main' into @alduzy/convert-groov…
alduzy Jun 3, 2024
af197f2
fix(Android): plugin apply syntax
alduzy Jun 3, 2024
8d88585
chore: updated gradle version
alduzy Jun 3, 2024
23d16db
fix: removed flipper
alduzy Jun 4, 2024
f7b2007
refactor: not using deprecated compileSdkVersion
alduzy Jun 4, 2024
2ffcf3c
reafctor: not using deprecated compileSdkVersion
alduzy Jun 4, 2024
edd3d5e
fix: safeExtGet
alduzy Jun 4, 2024
7a9177d
refactor: deprecated change
alduzy Jun 4, 2024
a9b709d
rewritten library scripts back to groovy
alduzy Jun 5, 2024
f7bd9ad
Merge remote-tracking branch 'origin/main' into @alduzy/convert-groov…
alduzy Jun 5, 2024
9bddf86
Merge remote-tracking branch 'origin/main' into @alduzy/convert-groov…
alduzy Jun 20, 2024
078c55c
fix: code formatting
alduzy Jun 20, 2024
ba513b2
Merge branch 'main' into @alduzy/convert-groovy-to-kotlin
alduzy Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"
import groovy.lang.Closure

plugins {
id ("com.android.application")
id ("org.jetbrains.kotlin.android")
id ("com.facebook.react")
}

/**
* This is the configuration block to customize your React Native Android app.
Expand Down Expand Up @@ -54,7 +58,7 @@ react {
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode
*/
def enableProguardInReleaseBuilds = false
val enableProguardInReleaseBuilds = false

/**
* The preferred build flavor of JavaScriptCore (JSC)
Expand All @@ -67,71 +71,71 @@ def enableProguardInReleaseBuilds = false
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
val jscFlavor = "org.webkit:android-jsc:+"

android {
ndkVersion rootProject.ext.ndkVersion

buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion

namespace "com.swmansion.rnscreens.example"
ndkVersion = rootProject.extra["ndkVersion"] as String
compileSdk = rootProject.extra["compileSdkVersion"] as Int
namespace = "com.swmansion.rnscreens.example"
defaultConfig {
applicationId "com.swmansion.rnscreens.example"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testBuildType System.getProperty('testBuildType', 'release')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
applicationId = "com.swmansion.rnscreens.example"
minSdkVersion(rootProject.extra["minSdkVersion"] as Int)
targetSdkVersion(rootProject.extra["targetSdkVersion"] as Int)
versionCode = 1
versionName = "1.0"
testBuildType = System.getProperty("testBuildType", "release")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
getByName("debug") {
storeFile = file("debug.keystore")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
}
release {
storeFile file("rns-example-keystore.jks")
storePassword "12345678"
keyAlias "react-native-screens-example"
keyPassword "12345678"
create("release") {
storeFile = file("rns-example-keystore.jks")
storePassword = "12345678"
keyAlias = "react-native-screens-example"
keyPassword = "12345678"
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
getByName("debug") {
signingConfig = signingConfigs.getByName("debug")
}
release {
getByName("release") {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
isMinifyEnabled = enableProguardInReleaseBuilds
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")

signingConfig signingConfigs.release
signingConfig = signingConfigs.getByName("release")
// Detox-specific additions to pro-guard
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
proguardFile("${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro")
}
}
}
val hermesEnabled: String by project

dependencies {
androidTestImplementation('com.wix:detox:+') {
androidTestImplementation("com.wix:detox:+") {
// Both rn-screens and detox are using this class
// https://github.com/wix/Detox/issues/2848
exclude group: 'com.google.android.material'
exclude(group = "com.google.android.material")
}
implementation "androidx.appcompat:appcompat:1.6.1"
implementation("androidx.appcompat:appcompat:1.6.1")

// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
implementation(jscFlavor)
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply (from = "../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle")
val applyNativeModules: Closure<Any> = extra.get("applyNativeModulesAppBuildGradle") as Closure<Any>
applyNativeModules(project)
2 changes: 1 addition & 1 deletion Example/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
# directive in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
Expand Down
18 changes: 8 additions & 10 deletions Example/android/build.gradle → Example/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.22"
}
val buildToolsVersion: String by extra("34.0.0")
val compileSdkVersion: Int by extra(34)
val minSdkVersion: Int by extra(23)
val targetSdkVersion: Int by extra(34)
val ndkVersion: String by extra("26.1.10909125")
val kotlinVersion: String by extra("1.9.22")
repositories {
google()
mavenCentral()
Expand All @@ -26,9 +24,9 @@ buildscript {
allprojects {
repositories {
maven {
url("$rootDir/../node_modules/detox/Detox-android")
url = uri("$rootDir/../node_modules/detox/Detox-android")
}
}
}

apply plugin: "com.facebook.react.rootproject"
apply (plugin= "com.facebook.react.rootproject")
4 changes: 0 additions & 4 deletions Example/android/settings.gradle

This file was deleted.

8 changes: 8 additions & 0 deletions Example/android/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import groovy.lang.Closure

rootProject.name = "ScreensExample"
apply(from = "../node_modules/@react-native-community/cli-platform-android/native_modules.gradle")
val applyNativeModules: Closure<Any> = extra.get("applyNativeModulesSettingsGradle") as Closure<Any>
applyNativeModules(settings)
include(":app")
includeBuild("../node_modules/@react-native/gradle-plugin")
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"
import groovy.lang.Closure

plugins {
id ("com.android.application")
id ("com.facebook.react")
id ("org.jetbrains.kotlin.android")
}

/**
* This is the configuration block to customize your React Native Android app.
Expand Down Expand Up @@ -54,7 +58,7 @@ react {
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
def enableProguardInReleaseBuilds = false
val enableProguardInReleaseBuilds = false

/**
* The preferred build flavor of JavaScriptCore (JSC)
Expand All @@ -67,42 +71,43 @@ def enableProguardInReleaseBuilds = false
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
val jscFlavor = "org.webkit:android-jsc:+"

android {
ndkVersion rootProject.ext.ndkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion
ndkVersion = rootProject.extra["ndkVersion"] as String
buildToolsVersion = rootProject.extra["buildToolsVersion"] as String
compileSdk = rootProject.extra["compileSdkVersion"] as Int

namespace "com.fabrictestexample"
namespace = "com.fabricexample"
defaultConfig {
applicationId "com.fabrictestexample"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
applicationId = "com.fabricexample"
minSdkVersion(rootProject.extra["minSdkVersion"] as Int)
targetSdkVersion(rootProject.extra["targetSdkVersion"] as Int)
versionCode = 1
versionName = "1.0"
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
getByName("debug") {
storeFile = file("debug.keystore")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
getByName("debug") {
signingConfig = signingConfigs.getByName("debug")
}
release {
getByName("release") {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig = signingConfigs.getByName("debug")
isMinifyEnabled = enableProguardInReleaseBuilds
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
}
}
val hermesEnabled: String by project

dependencies {
// The version of react-native is set by the React Native Gradle Plugin
Expand All @@ -111,8 +116,10 @@ dependencies {
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
implementation(jscFlavor)
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply (from = "../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle")
val applyNativeModules: Closure<Any> = extra.get("applyNativeModulesAppBuildGradle") as Closure<Any>
applyNativeModules(project)
2 changes: 1 addition & 1 deletion FabricExample/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
# directive in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
Expand Down
21 changes: 0 additions & 21 deletions FabricExample/android/build.gradle

This file was deleted.

21 changes: 21 additions & 0 deletions FabricExample/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
buildscript {
extra.apply {
set("buildToolsVersion", "34.0.0")
set("minSdkVersion", 23)
set("compileSdkVersion", 34)
set("targetSdkVersion", 34)
set("ndkVersion", "26.1.10909125")
set("kotlinVersion", "1.9.22")
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
}

apply(plugin = "com.facebook.react.rootproject")
4 changes: 0 additions & 4 deletions FabricExample/android/settings.gradle

This file was deleted.

8 changes: 8 additions & 0 deletions FabricExample/android/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import groovy.lang.Closure

rootProject.name = "FabricExample"
apply(from = "../node_modules/@react-native-community/cli-platform-android/native_modules.gradle")
val applyNativeModules: Closure<Any> = extra.get("applyNativeModulesSettingsGradle") as Closure<Any>
applyNativeModules(settings)
include(":app")
includeBuild("../node_modules/@react-native/gradle-plugin")
Loading
Loading