Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
177 changes: 138 additions & 39 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,27 +1,125 @@
// buildscript {
// // Buildscript is evaluated before everything else so we can't use getExtOrDefault
// def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["RNIterable_kotlinVersion"]

// repositories {
// google()
// mavenCentral()
// }

// dependencies {
// classpath "com.android.tools.build:gradle:7.2.1"
// // noinspection DifferentKotlinGradleVersion
// classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// }
// }

// def reactNativeArchitectures() {
// def value = rootProject.getProperties().get("reactNativeArchitectures")
// return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
// }

// def isNewArchitectureEnabled() {
// return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
// }

// apply plugin: "com.android.library"
// apply plugin: "kotlin-android"

// if (isNewArchitectureEnabled()) {
// apply plugin: "com.facebook.react"
// }

// def getExtOrDefault(name) {
// return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNIterable_" + name]
// }

// def getExtOrIntegerDefault(name) {
// return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNIterable_" + name]).toInteger()
// }

// def supportsNamespace() {
// def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
// def major = parsed[0].toInteger()
// def minor = parsed[1].toInteger()

// // Namespace support was added in 7.3.0
// return (major == 7 && minor >= 3) || major >= 8
// }

// android {
// if (supportsNamespace()) {
// namespace "com.iterable.reactnative"

// sourceSets {
// main {
// manifest.srcFile "src/main/AndroidManifestNew.xml"
// }
// }
// }

// compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

// defaultConfig {
// minSdkVersion getExtOrIntegerDefault("minSdkVersion")
// targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")

// }

// buildTypes {
// release {
// minifyEnabled false
// }
// }

// lintOptions {
// disable "GradleCompatible"
// }

// compileOptions {
// sourceCompatibility JavaVersion.VERSION_1_8
// targetCompatibility JavaVersion.VERSION_1_8
// }
// }

// repositories {
// mavenCentral()
// google()
// }

// def kotlin_version = getExtOrDefault("kotlinVersion")

// dependencies {
// // For < 0.71, this will be from the local maven repo
// // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
// //noinspection GradleDynamicVersion
// implementation "com.facebook.react:react-native:+"
// implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// api "com.iterable:iterableapi:3.5.2"
// // api project(":iterableapi") // links to local android SDK repo rather than by release
// }

def isNewArchitectureEnabled() {
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

buildscript {
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["RNIterable_kotlinVersion"]
ext.getExtOrDefault = {name ->
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RNIterable_' + name]
}

repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
classpath "com.android.tools.build:gradle:8.7.2"
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
}
}

def reactNativeArchitectures() {
def value = rootProject.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"
Expand All @@ -30,40 +128,23 @@ if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNIterable_" + name]
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNIterable_" + name]).toInteger()
}

def supportsNamespace() {
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
def major = parsed[0].toInteger()
def minor = parsed[1].toInteger()

// Namespace support was added in 7.3.0
return (major == 7 && minor >= 3) || major >= 8
}

android {
if (supportsNamespace()) {
namespace "com.iterable.reactnative"

sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
}
}
}
namespace "com.iterable.reactnative"

compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
}

buildFeatures {
buildConfig true
}

buildTypes {
Expand All @@ -80,6 +161,20 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

sourceSets {
main {
// java.srcDirs += [
// "generated/java",
// "generated/jni"
// ]
if (isNewArchitectureEnabled()) {
java.srcDirs += ['src/newarch']
} else {
java.srcDirs += ['src/oldarch']
}
}
}
}

repositories {
Expand All @@ -90,12 +185,16 @@ repositories {
def kotlin_version = getExtOrDefault("kotlinVersion")

dependencies {
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "com.facebook.react:react-android"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
api "com.iterable:iterableapi:3.5.2"
// api project(":iterableapi") // links to local android SDK repo rather than by release
}

// if (isNewArchitectureEnabled()) {
// react {
// jsRootDir = file("../src/api/")
// libraryName = "RNIterableAPISpec"
// codegenJavaPackageName = "com.iterable.reactnative"
// }
// }

12 changes: 6 additions & 6 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
RNIterable_kotlinVersion=1.7.0
RNIterable_minSdkVersion=21
RNIterable_targetSdkVersion=31
RNIterable_compileSdkVersion=31
RNIterable_ndkversion=21.4.7075529
RNIterable_kotlinVersion=2.0.21
RNIterable_minSdkVersion=24
RNIterable_targetSdkVersion=34
RNIterable_compileSdkVersion=35
RNIterable_ndkversion=27.1.12297006
android.useAndroidX=true
android.enableJetifier=true
android.enableJetifier=true
2 changes: 0 additions & 2 deletions android/src/main/AndroidManifestNew.xml

This file was deleted.

Loading