Skip to content

Commit

Permalink
Merge pull request #3 from oguzkocer/react-native-composite-and-binar…
Browse files Browse the repository at this point in the history
…y-build-support-remote-hermes

Use remote hermes dependency in react-native-bridge/android
  • Loading branch information
oguzkocer authored Mar 12, 2021
2 parents ff509eb + 170b257 commit 3f5b35d
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 69 deletions.
16 changes: 8 additions & 8 deletions packages/react-native-aztec/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ def addDependenciesToPom(pom) {
def dependenciesNode = asNode().getAt('dependencies')[0] ?: asNode().appendNode('dependencies')

// Iterate over the implementation dependencies, adding a <dependency> node for each
configurations.implementation.allDependencies.findAll { it instanceof ExternalDependency }.each {
if (it.name != 'unspecified') {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
configurations.implementation.allDependencies
.findAll { it instanceof ExternalDependency && it.name != 'unspecified' }
.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}

2 changes: 1 addition & 1 deletion packages/react-native-bridge/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
willPublishReactNativeBridgeBinary = gradle.ext.willPublishReactNativeBridgeBinary
willPublishReactNativeBridgeBinary = properties["publishReactNativeBridgeVersion"]?.trim() as boolean
}
repositories {
jcenter()
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ android {
repositories {
google()
jcenter()
maven {
url "https://dl.bintray.com/wordpress-mobile/maven"
}
maven { url "https://dl.bintray.com/wordpress-mobile/maven" }
maven { url "https://jitpack.io" }
maven { url "https://a8c-libs.s3.amazonaws.com/android" }
}

dependencies {
Expand All @@ -95,6 +94,7 @@ dependencies {
implementation "com.github.wordpress-mobile:react-native-screens:${readHashedVersion('../../../react-native-editor/package.json', 'react-native-screens', 'dependencies')}"
implementation "com.github.wordpress-mobile:react-native-safe-area-context:${readHashedVersion('../../../react-native-editor/package.json', 'react-native-safe-area-context', 'dependencies')}"
implementation "com.github.wordpress-mobile:react-native-reanimated:${readHashedVersion('../../../react-native-editor/package.json', 'react-native-reanimated', 'dependencies')}"
runtimeOnly "org.wordpress-mobile:hermes-release-mirror:0.61.5"
} else {
api 'com.facebook.react:react-native:+'
api project(':@wordpress_react-native-aztec')
Expand All @@ -108,8 +108,8 @@ dependencies {
api project(':react-native-screens')
api project(':react-native-safe-area-context')
api project(':react-native-reanimated')
debugRuntimeOnly project(":hermes-debug")
releaseRuntimeOnly project(":hermes-release")
debugRuntimeOnly "org.wordpress-mobile:hermes-debug-mirror:0.61.5"
releaseRuntimeOnly "org.wordpress-mobile:hermes-release-mirror:0.61.5"
}
}

Expand Down Expand Up @@ -164,14 +164,21 @@ def addDependenciesToPom(pom) {
pom.withXml {
def dependenciesNode = asNode().getAt('dependencies')[0] ?: asNode().appendNode('dependencies')

// Iterate over the implementation dependencies, adding a <dependency> node for each
configurations.implementation.allDependencies.findAll { it instanceof ExternalDependency }.each {
if (it.name != 'unspecified') {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
def addDependencies = { configuration, addExtraNode = {} ->
configuration.allDependencies
.findAll { it instanceof ExternalDependency && it.name != 'unspecified' }
.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
addExtraNode(dependencyNode)
}
}

addDependencies(configurations.implementation)
addDependencies(configurations.runtimeOnly) { dependencyNode ->
dependencyNode.appendNode('scope', 'runtime')
}
}
}
Expand Down
66 changes: 23 additions & 43 deletions packages/react-native-bridge/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,28 @@ include ':react-native-bridge'
include ':@wordpress_react-native-aztec'
project(':@wordpress_react-native-aztec').projectDir = new File(rootProject.projectDir, '../../react-native-aztec/android')

def publishReactNativeBridgeVersion = properties["publishReactNativeBridgeVersion"]
gradle.ext.willPublishReactNativeBridgeBinary = publishReactNativeBridgeVersion?.trim() as boolean
assert file("../../../node_modules").exists() : "node_modules folder is missing. Please run `npm install` from the root Gutenberg project"

// Only add these modules/projects if we are not building to publish a binary.
// TODO: This is a very fragile check. Since the `settings.gradle` file is part of initialization,
// it'll not work for even simple tasks such as `./gradlew clean` unless the
// `publishReactNativeBridgeVersion` property is passed. It's a necessary check for the moment,
// however by moving the Hermes binary to remote and maybe using dependency substitution for the
// included projects, we can get rid of it.
if (!gradle.ext.willPublishReactNativeBridgeBinary) {
/*
IMPORTANT: DO NOT add hermes modules if we are building a binary to publish.
If these modules are added, it'll cause the `com.facebook.hermes.BuildConfig` file to be
included in the binary which will then result in a duplicate class error.
This seems to happen even if these modules are not added as a dependency.
*/
include ':hermes-debug'
include ':hermes-release'

assert file("../../../node_modules").exists() : "node_modules folder is missing. Please run `npm install` from the root Gutenberg project"

include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-linear-gradient/android')
include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-svg/android')
include ':react-native-aztec'
project(':react-native-aztec').projectDir = new File(rootProject.projectDir, '../../../packages/react-native-aztec/android')
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-video/android-exoplayer')
include ':@react-native-community_slider'
project(':@react-native-community_slider').projectDir = new File(rootProject.projectDir, '../../../node_modules/@react-native-community/slider/src/android')
include ':react-native-get-random-values'
project(':react-native-get-random-values').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-get-random-values/android')
include ':@react-native-community_masked-view'
project(':@react-native-community_masked-view').projectDir = new File(rootProject.projectDir, '../../../node_modules/@react-native-community/masked-view/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-gesture-handler/android')
include ':react-native-screens'
project(':react-native-screens').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-screens/android')
include ':react-native-safe-area-context'
project(':react-native-safe-area-context').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-safe-area-context/android')
include ':react-native-reanimated'
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-reanimated/android')
}
include ':react-native-linear-gradient'
project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-linear-gradient/android')
include ':react-native-svg'
project(':react-native-svg').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-svg/android')
include ':react-native-aztec'
project(':react-native-aztec').projectDir = new File(rootProject.projectDir, '../../../packages/react-native-aztec/android')
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-video/android-exoplayer')
include ':@react-native-community_slider'
project(':@react-native-community_slider').projectDir = new File(rootProject.projectDir, '../../../node_modules/@react-native-community/slider/src/android')
include ':react-native-get-random-values'
project(':react-native-get-random-values').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-get-random-values/android')
include ':@react-native-community_masked-view'
project(':@react-native-community_masked-view').projectDir = new File(rootProject.projectDir, '../../../node_modules/@react-native-community/masked-view/android')
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-gesture-handler/android')
include ':react-native-screens'
project(':react-native-screens').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-screens/android')
include ':react-native-safe-area-context'
project(':react-native-safe-area-context').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-safe-area-context/android')
include ':react-native-reanimated'
project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../../../node_modules/react-native-reanimated/android')

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 3f5b35d

Please sign in to comment.