Skip to content
Draft
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
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ and edit the following files to use RNRepo:

#### Android (Gradle)

1. **Add the RNRepo Maven repository and plugin to `android/build.gradle`:**
1. **Add the RNRepo plugin to `android/build.gradle`:**

```diff
buildscript {
Expand All @@ -85,13 +85,6 @@ and edit the following files to use RNRepo:
+ classpath fileTree(dir: "${rnrepoDir}/gradle-plugin/build/libs", include: ["prebuilds-plugin-*.jar"])
}
}

allprojects {
repositories {
...
+ maven { url "https://packages.rnrepo.org/releases" }
}
}
```

2. **Apply the plugin in `android/app/build.gradle`:**
Expand All @@ -103,8 +96,6 @@ and edit the following files to use RNRepo:
+ apply plugin: "org.rnrepo.tools.prebuilds-plugin"
```

⚠️ **Important:** The plugin must be applied **after** defining repositories. If you're using a non-standard project structure (not following the `rootProject/android/app` layout), ensure that the `repositories` block is defined before the plugin is applied, otherwise the plugin won't be able to find the RNRepo Maven repository and all packages will fall back to building from source.

#### iOS (CocoaPods)

**Include the RNRepo script at the top of your `ios/Podfile` and add the post-install hook:**
Expand Down
9 changes: 0 additions & 9 deletions packages/build-tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ buildscript {
+ classpath fileTree(dir: "${rnrepoDir}/gradle-plugin/build/libs", include: ["prebuilds-plugin-*.jar"])
}
}

apply plugin: "com.facebook.react.rootproject"

allprojects {
repositories {
+ maven { url "https://packages.rnrepo.org/releases" }
}
}

```

Then, apply the plugin in your `android/app/build.gradle` file:
Expand Down
2 changes: 1 addition & 1 deletion packages/build-tools/gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
group = 'org.rnrepo.tools'

// Fixed version in code - automatically appends -SNAPSHOT for local publishes
def baseVersion = '0.3.0'
def baseVersion = '0.3.1'
def isLocalPublish = project.gradle.startParameter.taskNames.any {
it.contains("MavenLocal")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class PrebuildsPlugin : Plugin<Project> {
logger.lifecycle("RN Repo plugin v${BuildConstants.PLUGIN_VERSION} is enabled")

// Check what packages are in project and which are we supporting
addRNRepoRepository(project)
getProjectPackages(project.rootProject.allprojects, extension)
loadDenyList(extension)
determineSupportedPackages(project, extension)
Expand Down Expand Up @@ -175,6 +176,12 @@ class PrebuildsPlugin : Plugin<Project> {
}
}

private fun addRNRepoRepository(project: Project) {
project.repositories.maven { repo ->
repo.url = project.uri("https://packages.rnrepo.org/releases")
}
}

private fun getProperty(
project: Project,
propertyName: String,
Expand Down
4 changes: 2 additions & 2 deletions packages/build-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rnrepo/build-tools",
"title": "RNRepo Prebuilds plugin",
"version": "0.1.0",
"version": "0.1.1-beta.0",
"description": "RNRepo plugin for handling prebuilt binaries of iOS and Android libraries",
"scripts": {
"build": "./gradle-plugin/gradlew build --no-daemon -p gradle-plugin",
Expand All @@ -19,7 +19,7 @@
"files": [
"cocoapods-plugin/",
"gradle-plugin/README.md",
"gradle-plugin/build/libs/prebuilds-plugin-0.3.0.jar",
"gradle-plugin/build/libs/prebuilds-plugin-0.3.1.jar",
"README.md"
],
"keywords": [
Expand Down
48 changes: 1 addition & 47 deletions packages/expo-config-plugin/__tests__/withRNRepoPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('withRNRepoPlugin', () => {
});

describe('Android: Project Build Gradle', () => {
it('should add classpath dependency and maven repository', () => {
it('should add classpath dependency', () => {
mockConfig.modResults.contents = `
buildscript {
dependencies {
Expand All @@ -47,8 +47,6 @@ describe('withRNRepoPlugin', () => {
withRNRepoPlugin(mockConfig);

expect(mockConfig.modResults.contents).toContain('def rnrepoDir = new File');
expect(mockConfig.modResults.contents).toContain('repositories {');
expect(mockConfig.modResults.contents).toContain('https://packages.rnrepo.org/releases');
});

it('should not duplicate classpath if already present', () => {
Expand All @@ -74,50 +72,6 @@ describe('withRNRepoPlugin', () => {
const classpathCount = (mockConfig.modResults.contents.match(/def rnrepoDir/g) || []).length;
expect(classpathCount).toBe(1);
});

it('should add maven repository to allprojects block', () => {
mockConfig.modResults.contents = `
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.4.2")
}
}
apply plugin: "com.facebook.react.rootproject"
`;

withRNRepoPlugin(mockConfig);

expect(mockConfig.modResults.contents).toContain('allprojects {');
expect(mockConfig.modResults.contents).toContain('maven { url "https://packages.rnrepo.org/releases" }');
});

it('should not duplicate maven repository', () => {
mockConfig.modResults.contents = `
buildscript {
repositories {
google()
mavenCentral()
}
}

allprojects {
repositories {
maven { url "https://packages.rnrepo.org/releases" }
}
}

apply plugin: "com.facebook.react.rootproject"
`;

withRNRepoPlugin(mockConfig);
const mavenCount = (mockConfig.modResults.contents.match(/packages\.rnrepo\.org/g) || []).length;

expect(mavenCount).toBe(1);
});
});

describe('Android: App Build Gradle', () => {
Expand Down
25 changes: 0 additions & 25 deletions packages/expo-config-plugin/src/withRNRepoPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ const rnrepoClasspathBlock = `def rnrepoDir = new File(
`;
const applyPluginrnrepo = 'apply plugin: "org.rnrepo.tools.prebuilds-plugin"';
const applyPluginFacebook = 'apply plugin: "com.facebook.react"';
const applyPluginFacebookRootProject =
'apply plugin: "com.facebook.react.rootproject"';
const mavenAllProjectsBlock = `
allprojects {
repositories {
maven { url "https://packages.rnrepo.org/releases" }
}
}`;
// iOS
const podfileRequire = `require Pod::Executable.execute_command('node', ['-p',
'require.resolve(
Expand All @@ -32,22 +24,6 @@ const podfileRequire = `require Pod::Executable.execute_command('node', ['-p',
const postInstallRegex = /(post_install do \|installer\|)/;
const postInstallRNRepo = `rnrepo_post_install(installer)`;

function withAllProjectsMavenRepository(config: ExpoConfig) {
return withProjectBuildGradle(config, (config) => {
const currentContents = config.modResults.contents;
const normalizedNewBlock = mavenAllProjectsBlock.replace(/\s+/g, '');
const normalizedContents = currentContents.replace(/\s+/g, '');

if (!normalizedContents.includes(normalizedNewBlock)) {
config.modResults.contents = currentContents.replace(
applyPluginFacebookRootProject,
`${mavenAllProjectsBlock}\n\n${applyPluginFacebookRootProject}`
);
}
return config;
});
}

function withClasspathDependency(config: ExpoConfig) {
return withProjectBuildGradle(config, (config) => {
const currentContents = config.modResults.contents;
Expand Down Expand Up @@ -110,7 +86,6 @@ function withRNRepoPodfile(config: ExpoConfig) {
export default function withRNRepoPlugin(config: ExpoConfig): ExpoConfig {
config = withClasspathDependency(config);
config = withRnrepoPluginApplication(config);
config = withAllProjectsMavenRepository(config);
config = withRNRepoPodfile(config);
return config;
}
11 changes: 1 addition & 10 deletions packages/website/src/components/GettingStarted.astro
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,14 @@ const standardBuildGradleChange = `buildscript {
+ ).getParentFile().absolutePath
+ classpath fileTree(dir: "\${rnrepoDir}/gradle-plugin/build/libs", include: ["prebuilds-plugin-*.jar"])
}
}

allprojects {
repositories {
...
+ maven { url "https://packages.rnrepo.org/releases" }
}
}`;
const standardBuildGradleChangesCopyText = `def rnrepoDir = new File(
providers.exec {
workingDir(rootDir)
commandLine("node", "--print", "require.resolve('@rnrepo/build-tools/package.json')")
}.standardOutput.asText.get().trim()
).getParentFile().absolutePath
classpath fileTree(dir: "\${rnrepoDir}/gradle-plugin/build/libs", include: ["prebuilds-plugin-*.jar"])
...
maven { url "https://packages.rnrepo.org/releases" }`;
classpath fileTree(dir: "\${rnrepoDir}/gradle-plugin/build/libs", include: ["prebuilds-plugin-*.jar"])`;

const standardBuildGradleChangesCodeHtml = await codeToHtml(
standardBuildGradleChange,
Expand Down