react-native icon indicating copy to clipboard operation
react-native copied to clipboard

RN75 Upgrade - RNGP no longer allows me to exclusively use corporate Maven registry

Open henrygrant opened this issue 5 months ago • 0 comments

Description

My company blocks access to typical public maven registries like MavenCentral, GradlePluginPortal, etc. We host an internal Nexus Maven registry that proxies all of those public registries through it.

We do a similar thing for NPM, and in that case we just set the registry's url in our .npmrc file and call it a day. This is not the case for Maven.

Currently we're on React Native 74 and have historically done 2 things in order to force our project to use our internal registry exclusively:

First, we created an init.gradle file that overrides repositories and plugin repositories with ours. React Native Gradle Plugin (and perhaps other gradle-files-buried-in-node-modules) doesn't seem to respect this configuration, and I've never been able to figure out a Gradle-based way to handle it. This leads me to the second piece of our solution, which is just shoving our repository url into RNGP's settings.gradle.kts's repositories{} block.

This works up until React Native 75, where something has changed but I can't seem to tell what. I now consistently get the below error both in my company's project and this example project, where gson, guava, kotlin-stdlib, and javapoet are trying to hit public registries and ignoring both my init.gradle and my edits to RNGP's settings.gradle.kts.

Does anyone who works on React Native Gradle Plugin have a suggestion here? I really wish there was some kind of configuration I could pass to React Native Gradle Plugin to override it's looking in public repositories exclusively, but that is more of a feature request. RNGP not respecting init.gradle seems to be more of a bug though, as that should be overriding any gradle configuration of any lower project.

Steps to reproduce

Hard to test from your end as I don't imagine you have a nexus registry to use. I did reproduce the issue in the reproducer.

  1. Block access to MavenCentral, GradlePluginPortal, GoogleMaven, etc
  2. Replace url in init.gradle and postinstall.sh with your registry
  3. yarn
  4. yarn android

React Native Version

0.75.2

Affected Platforms

Runtime - Android, Build - MacOS

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 14.6.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 76.88 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.2
    path: ~/.nvm/versions/node/v18.18.2/bin/node
  Yarn:
    version: 3.6.4
    path: ~/.nvm/versions/node/v18.18.2/bin/yarn
  npm:
    version: 9.8.1
    path: ~/.nvm/versions/node/v18.18.2/bin/npm
  Watchman:
    version: 2023.12.04.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK:
    API Levels:
      - "28"
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 31.0.0
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
    System Images:
      - android-31 | Google APIs ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-33 | Google Play ARM 64 v8a
      - android-35 | Google Play Experimental 16k Page Size ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2411.12169540
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /usr/bin/javac
  Ruby:
    version: 3.2.2
    path: /opt/homebrew/opt/ruby/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.2
    wanted: 0.75.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)
Repository names before: [Google, Gradle Central Plugin Repository, MavenRepo, maven]
Repository names after: [REDACTED]
8 actionable tasks: 8 executed

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 


FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all artifacts for configuration 'classpath'.
> Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.9.24.
  Required by:
      unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin
      unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin > project :gradle-plugin:shared
   > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.9.24.
      > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-stdlib/1.9.24/kotlin-stdlib-1.9.24.pom'.
         > Could not HEAD 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.9.24/kotlin-stdlib-1.9.24.pom'. Received status code 503 from server: Service Unavailable
> Could not resolve com.google.code.gson:gson:2.8.9.
  Required by:
      unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin
      unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin > project :gradle-plugin:shared
   > Could not resolve com.google.code.gson:gson:2.8.9.
      > Could not get resource 'https://plugins.gradle.org/m2/com/google/code/gson/gson/2.8.9/gson-2.8.9.pom'.
         > Could not HEAD 'https://repo.maven.apache.org/maven2/com/google/code/gson/gson/2.8.9/gson-2.8.9.pom'. Received status code 503 from server: Service Unavailable
> Could not resolve com.google.guava:guava:31.0.1-jre.
  Required by:
      unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin
      unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin > project :gradle-plugin:shared
   > Could not resolve com.google.guava:guava:31.0.1-jre.
      > Could not get resource 'https://plugins.gradle.org/m2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.pom'.
         > Could not HEAD 'https://repo.maven.apache.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.pom'. Received status code 503 from server: Service Unavailable
> Could not resolve com.squareup:javapoet:1.13.0.
  Required by:
      unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin
   > Could not resolve com.squareup:javapoet:1.13.0.
      > Could not get resource 'https://plugins.gradle.org/m2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.pom'.
         > Could not HEAD 'https://repo.maven.apache.org/maven2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.pom'. Received status code 503 from server: Service Unavailable

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 21s
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with an exception. * What went wrong:
Could not resolve all artifacts for configuration 'classpath'.
> Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.9.24. Required by: unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin > project :gradle-plugin:shared > Could not resolve org.jetbrains.kotlin:kotlin-stdlib:1.9.24. > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-stdlib/1.9.24/kotlin-stdlib-1.9.24.pom'. > Could not HEAD 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.9.24/kotlin-stdlib-1.9.24.pom'. Received status code 503 from server: Service Unavailable
> Could not resolve com.google.code.gson:gson:2.8.9. Required by: unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin > project :gradle-plugin:shared > Could not resolve com.google.code.gson:gson:2.8.9. > Could not get resource 'https://plugins.gradle.org/m2/com/google/code/gson/gson/2.8.9/gson-2.8.9.pom'. > Could not HEAD 'https://repo.maven.apache.org/maven2/com/google/code/gson/gson/2.8.9/gson-2.8.9.pom'. Received status code 503 from server: Service Unavailable
> Could not resolve com.google.guava:guava:31.0.1-jre. Required by: unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin > project :gradle-plugin:shared > Could not resolve com.google.guava:guava:31.0.1-jre. > Could not get resource 'https://plugins.gradle.org/m2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.pom'. > Could not HEAD 'https://repo.maven.apache.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.pom'. Received status code 503 from server: Service Unavailable
> Could not resolve com.squareup:javapoet:1.13.0. Required by: unspecified:unspecified:unspecified > project :gradle-plugin:settings-plugin > Could not resolve com.squareup:javapoet:1.13.0. > Could not get resource 'https://plugins.gradle.org/m2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.pom'. > Could not HEAD 'https://repo.maven.apache.org/maven2/com/squareup/javapoet/1.13.0/javapoet-1.13.0.pom'. Received status code 503 from server: Service Unavailable * Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org. BUILD FAILED in 21s.
info Run CLI with --verbose flag for more details.

Reproducer

https://github.com/henrygrant/rn-private-reg/tree/broken-75

Screenshots and Videos

No response

henrygrant avatar Sep 06 '24 19:09 henrygrant