feat: ⚡ setup kotlin
This commit is contained in:
parent
650b3a6a24
commit
0ca348f4b5
@ -1,9 +1,35 @@
|
|||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlin-android-extensions'
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNSAC_kotlinVersion']
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def safeExtGet(prop, fallback) {
|
def safeExtGet(prop, fallback) {
|
||||||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getExtOrDefault(name, defaultValue) {
|
||||||
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : defaultValue
|
||||||
|
}
|
||||||
|
|
||||||
|
def isNewArchitectureEnabled() {
|
||||||
|
// To opt-in for the New Architecture, you can either:
|
||||||
|
// - Set `newArchEnabled` to true inside the `gradle.properties` file
|
||||||
|
// - Invoke gradle with `-newArchEnabled=true`
|
||||||
|
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
|
||||||
|
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
||||||
|
}
|
||||||
|
|
||||||
def useExoplayerIMA = safeExtGet("RNVUseExoplayerIMA", false)
|
def useExoplayerIMA = safeExtGet("RNVUseExoplayerIMA", false)
|
||||||
|
|
||||||
println "useExoplayerIMA:" + useExoplayerIMA
|
println "useExoplayerIMA:" + useExoplayerIMA
|
||||||
@ -16,6 +42,10 @@ def configStringPath = (
|
|||||||
'useExoplayerIMA' + useExoplayerIMA \
|
'useExoplayerIMA' + useExoplayerIMA \
|
||||||
).md5()
|
).md5()
|
||||||
|
|
||||||
|
if (isNewArchitectureEnabled()) {
|
||||||
|
apply plugin: "com.facebook.react"
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'com.brentvatne.react'
|
namespace 'com.brentvatne.react'
|
||||||
compileSdkVersion safeExtGet('compileSdkVersion', 31)
|
compileSdkVersion safeExtGet('compileSdkVersion', 31)
|
||||||
@ -31,6 +61,15 @@ android {
|
|||||||
targetSdkVersion safeExtGet('targetSdkVersion', 28)
|
targetSdkVersion safeExtGet('targetSdkVersion', 28)
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
||||||
|
|
||||||
|
ndk {
|
||||||
|
abiFilters(*reactNativeArchitectures())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
packagingOptions {
|
||||||
|
exclude "**/libreact_render*.so"
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
@ -50,12 +89,39 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets.main {
|
||||||
|
java {
|
||||||
|
if (isNewArchitectureEnabled()) {
|
||||||
|
srcDirs += [
|
||||||
|
"src/fabric/java",
|
||||||
|
"${project.buildDir}/generated/source/codegen/java"
|
||||||
|
]
|
||||||
|
} else {
|
||||||
|
srcDirs += [
|
||||||
|
"src/oldarch/java"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def reactNativeArchitectures() {
|
||||||
|
def value = project.getProperties().get("reactNativeArchitectures")
|
||||||
|
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
|
maven {
|
||||||
|
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
||||||
|
url "$rootDir/../node_modules/react-native/android"
|
||||||
|
}
|
||||||
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def kotlin_version = getExtOrDefault('kotlinVersion', project.properties['RNSAC_kotlinVersion'])
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
|
implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
|
||||||
implementation('com.google.android.exoplayer:exoplayer:2.18.1') {
|
implementation('com.google.android.exoplayer:exoplayer:2.18.1') {
|
||||||
@ -76,4 +142,5 @@ dependencies {
|
|||||||
implementation 'com.google.android.exoplayer:extension-ima:2.18.1'
|
implementation 'com.google.android.exoplayer:extension-ima:2.18.1'
|
||||||
}
|
}
|
||||||
implementation "com.squareup.okhttp3:okhttp:" + '$OKHTTP_VERSION'
|
implementation "com.squareup.okhttp3:okhttp:" + '$OKHTTP_VERSION'
|
||||||
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
buildToolsVersion = "31.0.0"
|
buildToolsVersion = "31.0.0"
|
||||||
kotlinVersion = "1.6.10"
|
kotlinVersion = "1.6.20"
|
||||||
minSdkVersion = 21
|
minSdkVersion = 21
|
||||||
compileSdkVersion = 31
|
compileSdkVersion = 31
|
||||||
targetSdkVersion = 31
|
targetSdkVersion = 31
|
||||||
@ -20,6 +20,7 @@ buildscript {
|
|||||||
classpath("com.facebook.react:react-native-gradle-plugin")
|
classpath("com.facebook.react:react-native-gradle-plugin")
|
||||||
classpath("de.undercouch:gradle-download-task:5.0.1")
|
classpath("de.undercouch:gradle-download-task:5.0.1")
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlinVersion"
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user