Skip to content

Commit

Permalink
add fabric support for android
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderEggers committed Aug 6, 2022
1 parent 43ec19a commit 489b23b
Show file tree
Hide file tree
Showing 136 changed files with 14,264 additions and 3,575 deletions.
6 changes: 1 addition & 5 deletions .gitignore
Expand Up @@ -59,8 +59,4 @@ example/windows/**/ARM64
*.user

# Bundle artifact
*.jsbundle

# Ruby / CocoaPods
/example/ios/Pods/
/vendor/bundle/
*.jsbundle
2 changes: 2 additions & 0 deletions .npmignore
Expand Up @@ -26,7 +26,9 @@ coverage
.vscode
docs
example
fabric-example
node_modules
react-native.config.js

.eslintignore
.eslintrc
Expand Down
67 changes: 47 additions & 20 deletions android/build.gradle
@@ -1,39 +1,66 @@
buildscript {
repositories {
google()
mavenCentral()
}
repositories {
google()
gradlePluginPortal()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
}
dependencies {
classpath("com.android.tools.build:gradle:7.2.2")
}
}

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

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: 'com.android.library'
apply from: 'gradle-maven-push.gradle'
if (isNewArchitectureEnabled()) {
apply plugin: 'com.facebook.react'
}

android {
buildToolsVersion safeExtGet('buildToolsVersion', "31.0.0")
compileSdk safeExtGet('compileSdkVersion', 31)
ndkVersion safeExtGet('ndkVersion', "21.4.7075529")
compileSdk safeExtGet('compileSdkVersion', 31)

defaultConfig {
targetSdkVersion safeExtGet('targetSdkVersion', 31)
minSdkVersion safeExtGet('minSdkVersion', 21)
}
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 21)
targetSdkVersion safeExtGet('targetSdkVersion', 31)
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}

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

repositories {
google()
mavenCentral()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$projectDir/../node_modules/react-native/android"
}
mavenCentral()
google()
}

dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.airbnb.android:lottie:5.1.1"
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "com.airbnb.android:lottie:5.2.0"
}

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
codegenJavaPackageName = "com.airbnb.android.react.lottie"
}
}
150 changes: 75 additions & 75 deletions android/gradle-maven-push.gradle
Expand Up @@ -18,104 +18,104 @@ apply plugin: 'maven-publish'
apply plugin: 'signing'

def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
return !VERSION_NAME.contains("SNAPSHOT")
}

def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}

def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}

def getRepositoryUsername() {
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
}

def getRepositoryPassword() {
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
}

afterEvaluate { project ->
publishing {
publications {
mavenJava(MavenPublication) {
groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = VERSION_NAME

pom {
name = POM_NAME
packaging = POM_PACKAGING
description = POM_DESCRIPTION
url = POM_URL

scm {
url = POM_SCM_URL
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
}

licenses {
license {
name = POM_LICENSE_NAME
url = POM_LICENSE_URL
distribution = POM_LICENSE_DIST
publishing {
publications {
mavenJava(MavenPublication) {
groupId = GROUP
artifactId = POM_ARTIFACT_ID
version = VERSION_NAME

pom {
name = POM_NAME
packaging = POM_PACKAGING
description = POM_DESCRIPTION
url = POM_URL

scm {
url = POM_SCM_URL
connection = POM_SCM_CONNECTION
developerConnection = POM_SCM_DEV_CONNECTION
}

licenses {
license {
name = POM_LICENSE_NAME
url = POM_LICENSE_URL
distribution = POM_LICENSE_DIST
}
}

developers {
developer {
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
}
}
scm {
connection = 'scm:git:git://github.com/lottie-react-native/lottie-react-native.git'
developerConnection = 'scm:git:ssh://github.com/lottie-react-native/lottie-react-native.git'
url = 'https://github.com/lottie-react-native/lottie-react-native'
}
}
}
}

developers {
developer {
id = POM_DEVELOPER_ID
name = POM_DEVELOPER_NAME
}
}
scm {
connection = 'scm:git:git://github.com/lottie-react-native/lottie-react-native.git'
developerConnection = 'scm:git:ssh://github.com/lottie-react-native/lottie-react-native.git'
url = 'https://github.com/lottie-react-native/lottie-react-native'
}
}
}
}
repositories {
maven {
url = isReleaseBuild() ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl()

credentials {
username = getRepositoryUsername()
password = getRepositoryPassword()
repositories {
maven {
url = isReleaseBuild() ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl()

credentials {
username = getRepositoryUsername()
password = getRepositoryPassword()
}
}
}
}
}
}


signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign publishing.publications.mavenJava
}
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign publishing.publications.mavenJava
}

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.sourceFiles
}

artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
}
15 changes: 0 additions & 15 deletions android/gradle.properties
Expand Up @@ -24,21 +24,6 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.125.0

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

# Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false

# Maven distribution related project settings
VERSION_CODE=4
VERSION_NAME=1.2.0
Expand Down
Binary file modified android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions android/gradlew
Expand Up @@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
14 changes: 8 additions & 6 deletions android/gradlew.bat
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down

0 comments on commit 489b23b

Please sign in to comment.