Skip to content
Merged
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
16 changes: 10 additions & 6 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ buildscript {
apply from: "$buildscriptDir/../test-app-util.gradle"

repositories {
jcenter()
google()
jcenter()
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "com.android.tools.build:gradle:3.6.1"
classpath "com.android.tools.build:gradle:3.6.2"
}
}

Expand All @@ -20,8 +20,8 @@ repositories {
url("${findNodeModulesPath(rootDir, "react-native")}/android")
}

jcenter()
google()
jcenter()
}

apply plugin: "com.android.application"
Expand All @@ -35,8 +35,8 @@ apply from: file("${testAppDir}/test-app.gradle")
applyTestAppModule(project, "com.sample")

project.ext.react = [
enableFlipper: getFlipperVersion(rootDir),
enableHermes: true,
enableFlipper: getFlipperVersion(rootDir),
enableHermes: true,
]

android {
Expand Down Expand Up @@ -87,7 +87,11 @@ dependencies {
releaseImplementation files("$hermesPath/hermes-release.aar")
debugImplementation files("$hermesPath/hermes-debug.aar")

implementation "com.facebook.react:react-native:+"
if (buildReactNativeFromSource(rootDir)) {
implementation project(':ReactAndroid')
} else {
implementation "com.facebook.react:react-native:+"
}

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation "androidx.appcompat:appcompat:1.1.0"
Expand Down
24 changes: 24 additions & 0 deletions android/react-native-build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'de.undercouch:gradle-download-task:4.0.4'
}
}

allprojects {
repositories {
google()
jcenter()
}
configurations.all {
resolutionStrategy {
dependencySubstitution {
substitute module("com.facebook.react:react-native:+") with project(":ReactAndroid")
}
}
}
}
5 changes: 5 additions & 0 deletions android/test-app-util.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import java.nio.file.Paths

ext.buildReactNativeFromSource = { baseDir ->
def reactNativePath = findNodeModulesPath(baseDir, 'react-native')
return !file("${reactNativePath}/android").exists()
}

ext.findFile = { fileName ->
def currentDir = file(rootDir)
while (currentDir != null) {
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"peerDependencies": {
"react": "~16.8.6 || ~16.9.0 || ~16.11.0 || ~16.13.1",
"react-native": "^0.60.6 || ^0.61.5 || ^0.62.2 || ^0.63",
"react-native": "^0.60.6 || ^0.61.5 || ^0.62.2 || ^0.63 || 1000.0.0",
"react-native-macos": "^0.60 || ^0.61.39"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
},
"peerDependencies": {
"react": "~16.8.6 || ~16.9.0 || ~16.11.0 || ~16.13.1",
"react-native": "^0.60.6 || ^0.61.5 || ^0.62.2 || ^0.63",
"react-native": "^0.60.6 || ^0.61.5 || ^0.62.2 || ^0.63 || 1000.0.0",
"react-native-macos": "^0.60 || ^0.61.39"
},
"devDependencies": {
Expand Down
11 changes: 11 additions & 0 deletions test-app.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import groovy.json.JsonSlurper
import java.nio.file.Paths
import org.gradle.initialization.DefaultSettings

private static void apply(Settings settings) {
def projectDir = settings.findNodeModulesPath(settings.rootDir, "react-native-test-app")

if (settings.buildReactNativeFromSource(settings.rootDir)) {
def buildFile = Paths.get("${projectDir}/android/react-native-build.gradle")
settings.rootProject.buildFileName = settings.rootDir.toPath().relativize(buildFile)

def reactNativeDir = settings.findNodeModulesPath(settings.rootDir, "react-native")
settings.include(":ReactAndroid")
settings.project(":ReactAndroid")
.projectDir = new File("${reactNativeDir}/ReactAndroid")
}

settings.include(":app")
settings.project(":app")
.projectDir = new File("${projectDir}/android/app")
Expand Down