Skip to content

Commit 192b5bf

Browse files
committed
refactor
1 parent ba753c6 commit 192b5bf

3 files changed

Lines changed: 35 additions & 12 deletions

File tree

apps/basic-example/android/app/build.gradle

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,19 @@ apply plugin: "com.android.application"
22
apply plugin: "org.jetbrains.kotlin.android"
33
apply plugin: "com.facebook.react"
44

5-
// Use RNRepo in CI builds
6-
if (["1", "true"].contains(System.getenv("CI"))) {
7-
apply plugin: "org.rnrepo.tools.prebuilds-plugin"
5+
def isCIEnabled() {
6+
return ["1", "true"].contains(System.getenv("CI")?.toLowerCase())
7+
}
8+
9+
// System.setProperty("DISABLE_RNREPO", "1") // Uncomment to disable RNRepo even in CI
10+
def isRNRepoEnabled() {
11+
return System.getenv("DISABLE_RNREPO") == null
12+
}
13+
14+
// Use RNRepo in CI builds.
15+
// Set DISABLE_RNREPO to any value to disable RNRepo.
16+
if (isCIEnabled() && isRNRepoEnabled()) {
17+
apply plugin: "org.rnrepo.tools.prebuilds-plugin"
818
}
919

1020
/**

apps/basic-example/android/build.gradle

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ buildscript {
1212
google()
1313
mavenCentral()
1414
}
15-
dependencies {
16-
classpath("com.android.tools.build:gradle")
17-
classpath("com.facebook.react:react-native-gradle-plugin")
18-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
19-
// RNRepo plugin in CI builds (plugin applied in app/build.gradle)
15+
// RNRepo plugin classpath for CI builds (plugin applied in app/build.gradle).
16+
// To disable RNRepo support, set DISABLE_RNREPO environment variable to ANY value.
17+
def rnrepoClasspath = {
2018
def rnrepoDir = new File(
2119
providers.exec {
2220
workingDir(rootDir)
2321
commandLine("node", "--print", "require.resolve('@rnrepo/build-tools/package.json')")
2422
}.standardOutput.asText.get().trim()
2523
).getParentFile().absolutePath
26-
classpath fileTree(dir: "${rnrepoDir}/gradle-plugin/build/libs", include: ["prebuilds-plugin.jar"])
24+
return fileTree(dir: "${rnrepoDir}/gradle-plugin/build/libs", include: ["prebuilds-plugin.jar"])
25+
}
26+
dependencies {
27+
classpath("com.android.tools.build:gradle")
28+
classpath("com.facebook.react:react-native-gradle-plugin")
29+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
30+
classpath rnrepoClasspath()
2731
}
2832
allprojects {
2933
project.pluginManager.withPlugin("com.facebook.react") {

apps/basic-example/ios/Podfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,17 @@ require Pod::Executable.execute_command('node', ['-p',
55
{paths: ["../../../node_modules"]},
66
)', __dir__]).strip
77

8-
# Use RNRepo in CI builds
9-
if %w[1 true].include?(ENV['CI'].to_s.downcase)
8+
def is_ci_enabled?
9+
%w[1 true].include?(ENV['CI'].to_s.downcase)
10+
end
11+
12+
# ENV['DISABLE_RNREPO'] = "1" # Uncomment to disable RNRepo even in CI
13+
def is_rnrepo_enabled?
14+
ENV['DISABLE_RNREPO'].nil?
15+
end
16+
17+
# Use RNRepo in CI builds. Set DISABLE_RNREPO to any value to disable RNRepo.
18+
if is_ci_enabled? && is_rnrepo_enabled?
1019
require Pod::Executable.execute_command('node', ['-p',
1120
'require.resolve(
1221
"@rnrepo/build-tools/cocoapods-plugin/lib/plugin.rb",
@@ -37,7 +46,7 @@ target 'BasicExample' do
3746
)
3847

3948
post_install do |installer|
40-
if %w[1 true].include?(ENV['CI'].to_s.downcase)
49+
if is_ci_enabled? && is_rnrepo_enabled?
4150
rnrepo_post_install(installer)
4251
end
4352
react_native_post_install(

0 commit comments

Comments
 (0)