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
6 changes: 3 additions & 3 deletions packages/cli/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ subprojects {
jcenter()
mavenLocal()
maven {
url("$rootDir/../../../node_modules/react-native/android")
url("$rootDir/../../node_modules/react-native/android")
}
maven {
url("$rootDir/../../../node_modules/react-native/android")
url("$rootDir/../../node_modules/react-native/android")
}
maven {
url("$rootDir/../../../node_modules/jsc-android/dist")
url("$rootDir/../../node_modules/jsc-android/dist")
}
maven { url 'https://jitpack.io' }
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/android/react-native-brownfield/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ apply plugin: 'com.kezong.fat-aar'

project.ext.react = [
entryFile: "index.js",
root: "../..",
root: "../../..",
jsBundleDirRelease: "$buildDir/generated/assets/react/release",
enableHermes: false,
enableVmCleanup: false
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../../node_modules/react-native/react.gradle"

android {
sourceSets {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ rootProject.name='ReactNativeBrownfield'
include ':react-native-brownfield'

include ':react-native-brownfield-core'
project(':react-native-brownfield-core').projectDir = new File(rootProject.projectDir, '../../../node_modules/@callstack/react-native-brownfield/android')
project(':react-native-brownfield-core').projectDir = new File(rootProject.projectDir, '../../node_modules/@callstack/react-native-brownfield/android')

26 changes: 25 additions & 1 deletion packages/cli/src/commands/build-android.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import path from 'path';
import {execSync} from 'child_process';
import {BuildPlatform} from '../types';
import copyFiles from '../tools/copyFiles';
import {createBuildDir, bundleJS, getBuildDir} from '../tools/helpers';

export default function buildAndroid(args: BuildPlatform) {
export default async function buildAndroid(args: BuildPlatform) {
const rootDir = process.cwd();
const buildDir = getBuildDir(rootDir);
const libraryPath = path.join(
path.dirname(require.resolve('@react-native-brownfield/cli')),
'android',
);

createBuildDir(buildDir);

Expand All @@ -13,4 +20,21 @@ export default function buildAndroid(args: BuildPlatform) {
rootDir,
buildDir,
});

try {
await copyFiles(libraryPath, `${buildDir}/android`);
} catch (e) {
console.log(e);
return;
}

try {
const result = execSync(
'./gradlew bundleReleaseAar -x bundleReleaseJsAndAssets',
);
console.log(result.toString());
} catch (e) {
console.error(e);
return;
}
}
8 changes: 8 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import commander from 'commander';
import buildIOSArtifact from './commands/build-ios';
import buildAndroid from './commands/build-android';

const program = new commander.Command();
program.version(
Expand All @@ -17,4 +18,11 @@ program
.option('--useNpm', 'use npm instead of yarn')
.action(buildIOSArtifact);

program
.command('build-android')
.description('build android')
.option('-e, --entryFile <entryFile>', 'Remove recursively')
.option('--useNpm', 'use npm instead of yarn')
.action(buildAndroid);

program.parse(process.argv);