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
8 changes: 8 additions & 0 deletions dev-packages/e2e-tests/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,14 @@
env: env,
});

// Replace the dead OSSRH snapshots repo hardcoded by older RN Gradle plugins
// (oss.sonatype.org is EOL and intermittently 504s, breaking dependency resolution).
execSync(`${patchScriptsDir}/rn.patch.gradle.plugin.repo.js --app-dir .`, {

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.
This shell command depends on an uncontrolled
absolute path
.
This shell command depends on an uncontrolled
absolute path
.
Comment thread
antonis marked this conversation as resolved.
Dismissed
stdio: 'inherit',
cwd: appDir,
env: env,
});

// Patch the app
execSync(`patch --verbose --strip=0 --force --ignore-whitespace --fuzz 4 < ${patchScriptsDir}/rn.patch`, {
stdio: 'inherit',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env node

const fs = require('fs');
const path = require('path');
const { argv } = require('process');

const parseArgs = require('minimist');
const { debug } = require('@sentry/core');
debug.enable();

const args = parseArgs(argv.slice(2));
if (!args['app-dir']) {
throw new Error('Missing --app-dir');
}

// Sonatype's legacy OSSRH host (oss.sonatype.org) reached end-of-life on
// 2025-06-30 and is now unreliable — it intermittently answers with a
// `504 Gateway Time-out` instead of a clean `404`. The React Native Gradle
// plugin bundled with older RN versions (e.g. 0.71) hardcodes this host as a
// snapshots repository and injects it into every project's repository list.
// Gradle treats a 5xx from any declared repo as fatal (unlike a 404, which it
// skips), so a single 504 breaks resolution of ANY dependency (react-android,
// AGP lint, ...) even though those artifacts live on Maven Central / google().
//
// We pin a stable RN release, so the snapshots repo is only ever used for
// nightly (0.0.0-*) builds and serves no purpose here — remove it entirely so
// nothing in the resolution path depends on a Sonatype snapshots host.
const SNAPSHOT_REPO_LINE = /^[^\n]*mavenRepoFromUrl\("https:\/\/oss\.sonatype\.org\/content\/repositories\/snapshots\/"\)[^\n]*\n/m;

const dependencyUtilsPath = path.join(
args['app-dir'],
'node_modules',
'react-native-gradle-plugin',
'src',
'main',
'kotlin',
'com',
'facebook',
'react',
'utils',
'DependencyUtils.kt'
);

debug.log('Removing dead OSSRH snapshots repo from React Native Gradle plugin', dependencyUtilsPath);

if (!fs.existsSync(dependencyUtilsPath)) {
debug.log('DependencyUtils.kt not found, skipping patch (plugin likely already uses a live repo)');
} else {
const source = fs.readFileSync(dependencyUtilsPath, 'utf8');

if (!SNAPSHOT_REPO_LINE.test(source)) {
debug.log('DependencyUtils.kt does not reference the dead OSSRH host, nothing to patch');
} else {
const patched = source.replace(SNAPSHOT_REPO_LINE, '');
fs.writeFileSync(dependencyUtilsPath, patched);
debug.log('Removed dead OSSRH snapshots repo successfully!');
}
}
Loading