Skip to content

Commit 8063ab9

Browse files
committed
chore: add DISABLE_RNREPO support to CI build configurations in Podfile and Gradle files
1 parent 11d2460 commit 8063ab9

3 files changed

Lines changed: 38 additions & 14 deletions

File tree

FabricExample/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
/**

FabricExample/android/build.gradle

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
// RNRepo plugin classpath for CI builds (plugin applied in app/build.gradle).
2+
// To disable RNRepo support, set DISABLE_RNREPO environment variable to ANY value.
3+
def rnrepoClasspath() {
4+
def rnrepoDir = new File(
5+
providers.exec {
6+
workingDir(rootDir)
7+
commandLine("node", "--print", "require.resolve('@rnrepo/build-tools/package.json')")
8+
}.standardOutput.asText.get().trim()
9+
).getParentFile().absolutePath
10+
return fileTree(dir: "${rnrepoDir}/gradle-plugin/build/libs", include: ["prebuilds-plugin.jar"])
11+
}
12+
113
buildscript {
214
ext {
315
buildToolsVersion = "36.0.0"
@@ -15,14 +27,7 @@ buildscript {
1527
classpath("com.android.tools.build:gradle")
1628
classpath("com.facebook.react:react-native-gradle-plugin")
1729
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
18-
// RNRepo plugin in CI builds (plugin applied in app/build.gradle)
19-
def rnrepoDir = new File(
20-
providers.exec {
21-
workingDir(rootDir)
22-
commandLine("node", "--print", "require.resolve('@rnrepo/build-tools/package.json')")
23-
}.standardOutput.asText.get().trim()
24-
).getParentFile().absolutePath
25-
classpath fileTree(dir: "${rnrepoDir}/gradle-plugin/build/libs", include: ["prebuilds-plugin.jar"])
30+
classpath rnrepoClasspath()
2631
}
2732
}
2833

FabricExample/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: [process.argv[1]]},
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",
@@ -39,7 +48,7 @@ target 'FabricExample' do
3948
)
4049

4150
post_install do |installer|
42-
if %w[1 true].include?(ENV['CI'].to_s.downcase)
51+
if is_ci_enabled? && is_rnrepo_enabled?
4352
rnrepo_post_install(installer)
4453
end
4554
react_native_post_install(

0 commit comments

Comments
 (0)