move library to separate project
This commit is contained in:
parent
28d1f92a7e
commit
8cb8b0729a
|
@ -0,0 +1,195 @@
|
|||
// Copyright 2015-present Facebook. All Rights Reserved.
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'maven'
|
||||
|
||||
apply plugin: 'de.undercouch.download'
|
||||
|
||||
import de.undercouch.gradle.tasks.download.Download
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
// We download various C++ open-source dependencies into downloads.
|
||||
// We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
|
||||
// After that we build native code from src/main/jni with module path pointing at third-party-ndk.
|
||||
|
||||
def downloadsDir = new File("$buildDir/downloads")
|
||||
def thirdPartyNdkDir = new File("$buildDir/third-party-ndk")
|
||||
|
||||
task createNativeDepsDirectories {
|
||||
downloadsDir.mkdirs()
|
||||
thirdPartyNdkDir.mkdirs()
|
||||
}
|
||||
|
||||
task downloadRealmCore(type: Download) {
|
||||
src 'http://static.realm.io/downloads/core/realm-core-android-0.94.4.tar.gz'
|
||||
onlyIfNewer true
|
||||
overwrite false
|
||||
dest new File(downloadsDir, 'realm-core-android-0.94.4.tar.gz')
|
||||
}
|
||||
|
||||
task prepareRealmCore(type:Copy) {
|
||||
from tarTree(downloadRealmCore.dest)
|
||||
from 'src/main/jni/third-party/realm-core/Android.mk'
|
||||
into "$thirdPartyNdkDir/realm-core"
|
||||
}
|
||||
|
||||
task downloadJSCHeaders(type: Download) {
|
||||
def jscAPIBaseURL = 'https://svn.webkit.org/repository/webkit/!svn/bc/174650/trunk/Source/JavaScriptCore/API/'
|
||||
def jscHeaderFiles = ['JSBase.h', 'JSContextRef.h', 'JSObjectRef.h', 'JSRetainPtr.h', 'JSStringRef.h', 'JSValueRef.h', 'WebKitAvailability.h', 'JavaScriptCore.h', 'JavaScript.h', 'JSStringRefCF.h']
|
||||
def output = new File(downloadsDir, 'jsc')
|
||||
output.mkdirs()
|
||||
src(jscHeaderFiles.collect { headerName -> "$jscAPIBaseURL$headerName" })
|
||||
onlyIfNewer true
|
||||
overwrite false
|
||||
dest output
|
||||
}
|
||||
|
||||
// Create Android.mk library module based on so files from mvn + include headers fetched from webkit.org
|
||||
task prepareJSC(dependsOn: downloadJSCHeaders) << {
|
||||
copy {
|
||||
from zipTree(configurations.compile.fileCollection { dep -> dep.name == 'android-jsc' }.singleFile)
|
||||
from {downloadJSCHeaders.dest}
|
||||
from 'src/main/jni/third-party/jsc/Android.mk'
|
||||
include 'jni/**/*.so', '*.h', 'Android.mk'
|
||||
filesMatching('*.h', { fname -> fname.path = "JavaScriptCore/${fname.path}"})
|
||||
into "$thirdPartyNdkDir/jsc";
|
||||
}
|
||||
}
|
||||
|
||||
def getNdkBuildName() {
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
return "ndk-build.cmd"
|
||||
} else {
|
||||
return "ndk-build"
|
||||
}
|
||||
}
|
||||
|
||||
def findNdkBuildFullPath() {
|
||||
// we allow to provide full path to ndk-build tool
|
||||
if (hasProperty('ndk.command')) {
|
||||
return property('ndk.command')
|
||||
}
|
||||
// or just a path to the containing directory
|
||||
if (hasProperty('ndk.path')) {
|
||||
def ndkDir = property('ndk.path')
|
||||
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
|
||||
}
|
||||
if (System.getenv('ANDROID_NDK') != null) {
|
||||
def ndkDir = System.getenv('ANDROID_NDK')
|
||||
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
|
||||
}
|
||||
def ndkDir = android.hasProperty('plugin') ? android.plugin.ndkFolder :
|
||||
plugins.getPlugin('com.android.library').sdkHandler.getNdkFolder()
|
||||
if (ndkDir) {
|
||||
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
def getNdkBuildFullPath() {
|
||||
def ndkBuildFullPath = findNdkBuildFullPath()
|
||||
if (ndkBuildFullPath == null) {
|
||||
throw new GradleScriptException(
|
||||
"ndk-build binary cannot be found, check if you've set " +
|
||||
"\$ANDROID_NDK environment variable correctly or if ndk.dir is " +
|
||||
"setup in local.properties",
|
||||
null)
|
||||
}
|
||||
if (!new File(ndkBuildFullPath).canExecute()) {
|
||||
throw new GradleScriptException(
|
||||
"ndk-build binary " + ndkBuildFullPath + " doesn't exist or isn't executable.\n" +
|
||||
"Check that the \$ANDROID_NDK environment variable, or ndk.dir in local.proerties, is set correctly.\n" +
|
||||
"(On Windows, make sure you escape backslashes in local.properties or use forward slashes, e.g. C:\\\\ndk or C:/ndk rather than C:\\ndk)",
|
||||
null)
|
||||
}
|
||||
return ndkBuildFullPath
|
||||
}
|
||||
|
||||
task buildReactNdkLib(dependsOn: [prepareJSC], type: Exec) {
|
||||
inputs.file('src/main/jni')
|
||||
outputs.dir("$buildDir/react-ndk/all")
|
||||
commandLine getNdkBuildFullPath(),
|
||||
'NDK_PROJECT_PATH=null',
|
||||
"NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk",
|
||||
'NDK_OUT=' + temporaryDir,
|
||||
"NDK_LIBS_OUT=$buildDir/react-ndk/all",
|
||||
"THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk",
|
||||
'-C', file('src/main/jni').absolutePath,
|
||||
'-B',
|
||||
'NDK_LOG=1',
|
||||
'--jobs', Runtime.runtime.availableProcessors(),
|
||||
'V=1'
|
||||
}
|
||||
|
||||
task cleanReactNdkLib(type: Exec) {
|
||||
commandLine getNdkBuildFullPath(),
|
||||
'-C', file('src/main/jni').absolutePath,
|
||||
'clean'
|
||||
}
|
||||
|
||||
task packageReactNdkLibs(dependsOn: buildReactNdkLib, type: Copy) {
|
||||
from "$buildDir/react-ndk/all"
|
||||
exclude '**/libjsc.so'
|
||||
into "$buildDir/react-ndk/exported"
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.1"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 22
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
ndk {
|
||||
moduleName "reactnativejni"
|
||||
}
|
||||
|
||||
buildConfigField 'boolean', 'IS_INTERNAL_BUILD', 'false'
|
||||
}
|
||||
|
||||
sourceSets.main {
|
||||
jni.srcDirs = []
|
||||
jniLibs.srcDir "$buildDir/react-ndk/exported"
|
||||
res.srcDirs = ['src/main/res/devsupport', 'src/main/res/shell']
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
compileTask -> compileTask.dependsOn packageReactNdkLibs
|
||||
}
|
||||
|
||||
clean.dependsOn cleanReactNdkLib
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:23.0.1'
|
||||
compile 'com.android.support:recyclerview-v7:23.0.1'
|
||||
compile 'com.facebook.fresco:fresco:0.8.1'
|
||||
compile 'com.facebook.fresco:imagepipeline-okhttp:0.8.1'
|
||||
compile 'com.facebook.stetho:stetho:1.2.0'
|
||||
compile 'com.facebook.stetho:stetho-okhttp:1.2.0'
|
||||
compile 'com.fasterxml.jackson.core:jackson-core:2.2.3'
|
||||
compile 'com.google.code.findbugs:jsr305:3.0.0'
|
||||
compile 'com.squareup.okhttp:okhttp:2.5.0'
|
||||
compile 'com.squareup.okhttp:okhttp-ws:2.5.0'
|
||||
compile 'com.squareup.okio:okio:1.6.0'
|
||||
compile 'org.webkit:android-jsc:r174650'
|
||||
|
||||
testCompile "junit:junit:${JUNIT_VERSION}"
|
||||
testCompile "org.powermock:powermock-api-mockito:${POWERMOCK_VERSION}"
|
||||
testCompile "org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}"
|
||||
testCompile "org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}"
|
||||
testCompile "org.mockito:mockito-core:${MOCKITO_CORE_VERSION}"
|
||||
testCompile "org.easytesting:fest-assert-core:${FEST_ASSERT_CORE_VERSION}"
|
||||
testCompile("org.robolectric:robolectric:${ROBOLECTRIC_VERSION}")
|
||||
}
|
||||
|
||||
apply from: 'release.gradle'
|
|
@ -1,5 +1,3 @@
|
|||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
def config = project.hasProperty("react") ? project.react : [];
|
||||
|
||||
def bundleAssetName = config.bundleAssetName ?: "index.android.bundle"
|
||||
|
@ -38,13 +36,8 @@ task bundleDebugJsAndAssets(type: Exec) {
|
|||
|
||||
// set up the call to the react-native cli
|
||||
workingDir reactRoot
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
commandLine "cmd", "/c", "react-native", "bundle", "--platform", "android", "--dev", "true", "--entry-file",
|
||||
commandLine "react-native", "bundle", "--platform", "android", "--dev", "true", "--entry-file",
|
||||
entryFile, "--bundle-output", jsBundleFileDebug, "--assets-dest", resourcesDirDebug
|
||||
} else {
|
||||
commandLine "react-native", "bundle", "--platform", "android", "--dev", "true", "--entry-file",
|
||||
entryFile, "--bundle-output", jsBundleFileDebug, "--assets-dest", resourcesDirDebug
|
||||
}
|
||||
|
||||
enabled config.bundleInDebug ?: false
|
||||
}
|
||||
|
@ -63,13 +56,8 @@ task bundleReleaseJsAndAssets(type: Exec) {
|
|||
|
||||
// set up the call to the react-native cli
|
||||
workingDir reactRoot
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
commandLine "cmd","/c", "react-native", "bundle", "--platform", "android", "--dev", "false", "--entry-file",
|
||||
commandLine "react-native", "bundle", "--platform", "android", "--dev", "false", "--entry-file",
|
||||
entryFile, "--bundle-output", jsBundleFileRelease, "--assets-dest", resourcesDirRelease
|
||||
} else {
|
||||
commandLine "react-native", "bundle", "--platform", "android", "--dev", "false", "--entry-file",
|
||||
entryFile, "--bundle-output", jsBundleFileRelease, "--assets-dest", resourcesDirRelease
|
||||
}
|
||||
|
||||
enabled config.bundleInRelease ?: true
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.demo">
|
||||
<!-- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.reacttests">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
|
@ -10,8 +10,7 @@
|
|||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
@ -20,4 +19,11 @@
|
|||
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
|
||||
</application>
|
||||
|
||||
</manifest> -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.reacttests">
|
||||
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||
|
||||
<application />
|
||||
|
||||
</manifest>
|
|
@ -30,12 +30,12 @@ LOCAL_SRC_FILES := \
|
|||
src/object-store/parser/parser.cpp \
|
||||
src/object-store/parser/query_builder.cpp \
|
||||
src/object-store/impl/transact_log_handler.cpp \
|
||||
../../../../../../../vendor/base64.cpp
|
||||
vendor/base64.cpp
|
||||
|
||||
LOCAL_C_INCLUDES := src/object-store
|
||||
LOCAL_C_INCLUDES += src/object-store/parser
|
||||
LOCAL_C_INCLUDES += ../../../../../../../vendor
|
||||
LOCAL_C_INCLUDES += ../../../../../../../vendor/PEGTL
|
||||
LOCAL_C_INCLUDES += vendor
|
||||
LOCAL_C_INCLUDES += vendor/PEGTL
|
||||
LOCAL_C_INCLUDES += core/include
|
||||
|
||||
CXX11_FLAGS := -std=c++14
|
|
@ -0,0 +1 @@
|
|||
../../../../../../src
|
|
@ -0,0 +1 @@
|
|||
../../../../../../vendor
|
|
@ -6,6 +6,7 @@ buildscript {
|
|||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.3.1'
|
||||
classpath 'de.undercouch:gradle-download-task:1.2'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
@ -16,11 +17,5 @@ allprojects {
|
|||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
jcenter {
|
||||
url "http://dl.bintray.com/mkonicek/maven"
|
||||
}
|
||||
flatDir{
|
||||
dirs 'lib'
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,3 +18,5 @@
|
|||
# org.gradle.parallel=true
|
||||
|
||||
android.useDeprecatedNdk=true
|
||||
org.gradle.daemon=true
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
## This file is automatically generated by Android Studio.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must *NOT* be checked into Version Control Systems,
|
||||
# as it contains information specific to your local configuration.
|
||||
#
|
||||
# Location of the SDK. This is only used by Gradle.
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
#Mon Nov 30 14:31:09 PST 2015
|
||||
ndk.dir=/Users/ari/Library/Android/sdk/ndk-bundle
|
||||
sdk.dir=/Users/ari/Library/Android/sdk
|
|
@ -0,0 +1,3 @@
|
|||
rootProject.name = 'ReactTests'
|
||||
|
||||
include ':app'
|
|
@ -1,79 +0,0 @@
|
|||
apply plugin: "com.android.application"
|
||||
|
||||
/**
|
||||
* The react.gradle file registers two tasks: bundleDebugJsAndAssets and bundleReleaseJsAndAssets.
|
||||
* These basically call `react-native bundle` with the correct arguments during the Android build
|
||||
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
|
||||
* bundle directly from the development server. Below you can see all the possible configurations
|
||||
* and their defaults. If you decide to add a configuration block, make sure to add it before the
|
||||
* `apply from: "react.gradle"` line.
|
||||
*
|
||||
* project.ext.react = [
|
||||
* // the name of the generated asset file containing your JS bundle
|
||||
* bundleAssetName: "index.android.bundle",
|
||||
*
|
||||
* // the entry file for bundle generation
|
||||
* entryFile: "index.android.js",
|
||||
*
|
||||
* // whether to bundle JS and assets in debug mode
|
||||
* bundleInDebug: false,
|
||||
*
|
||||
* // whether to bundle JS and assets in release mode
|
||||
* bundleInRelease: true,
|
||||
*
|
||||
* // the root of your project, i.e. where "package.json" lives
|
||||
* root: "../../",
|
||||
*
|
||||
* // where to put the JS bundle asset in debug mode
|
||||
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
|
||||
*
|
||||
* // where to put the JS bundle asset in release mode
|
||||
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
|
||||
*
|
||||
* // where to put drawable resources / React Native assets, e.g. the ones you use via
|
||||
* // require('./image.png')), in debug mode
|
||||
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
|
||||
*
|
||||
* // where to put drawable resources / React Native assets, e.g. the ones you use via
|
||||
* // require('./image.png')), in release mode
|
||||
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
|
||||
*
|
||||
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
|
||||
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
|
||||
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
|
||||
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
|
||||
* // for example, you might want to remove it from here.
|
||||
* inputExcludes: ["android/**", "ios/**"]
|
||||
* ]
|
||||
*/
|
||||
|
||||
apply from: "react.gradle"
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.demo"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 22
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a", "x86"
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false // Set this to true to enable Proguard
|
||||
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: "libs", include: ["*.jar"])
|
||||
compile "com.android.support:appcompat-v7:23.0.1"
|
||||
compile "com.facebook.react:react-native:0.16.+"
|
||||
compile 'com.reacttests:app-debug@aar'
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 7.5 KiB |
|
@ -1,3 +0,0 @@
|
|||
<resources>
|
||||
<string name="app_name">Demo</string>
|
||||
</resources>
|
|
@ -1,8 +0,0 @@
|
|||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
|
@ -1,3 +0,0 @@
|
|||
rootProject.name = 'Demo'
|
||||
|
||||
include ':app'
|
|
@ -1,59 +0,0 @@
|
|||
/**
|
||||
* Sample React Native App
|
||||
* https://github.com/facebook/react-native
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var React = require('react-native');
|
||||
var {
|
||||
AppRegistry,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
TouchableNativeFeedback,
|
||||
} = React;
|
||||
|
||||
var JniToastAndroid = require('NativeModules').JniToastAndroid;
|
||||
|
||||
var Demo = React.createClass({
|
||||
buttonClicked: function() {
|
||||
JniToastAndroid.show("Hello Zepp", JniToastAndroid.LONG);
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>
|
||||
Calling JNI String from Javascript.
|
||||
</Text>
|
||||
<TouchableNativeFeedback
|
||||
style={styles.button}
|
||||
onPress={this.buttonClicked.bind(this)}>
|
||||
<View style={{backgroundColor: 'red'}}>
|
||||
<Text style={{margin: 5}}>Click Me :)</Text>
|
||||
</View>
|
||||
</TouchableNativeFeedback>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
var styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
welcome: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
instructions: {
|
||||
textAlign: 'center',
|
||||
color: '#333333',
|
||||
marginBottom: 5,
|
||||
},
|
||||
});
|
||||
|
||||
AppRegistry.registerComponent('Demo', () => Demo);
|
|
@ -1,195 +1,79 @@
|
|||
// Copyright 2015-present Facebook. All Rights Reserved.
|
||||
apply plugin: "com.android.application"
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'maven'
|
||||
/**
|
||||
* The react.gradle file registers two tasks: bundleDebugJsAndAssets and bundleReleaseJsAndAssets.
|
||||
* These basically call `react-native bundle` with the correct arguments during the Android build
|
||||
* cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
|
||||
* bundle directly from the development server. Below you can see all the possible configurations
|
||||
* and their defaults. If you decide to add a configuration block, make sure to add it before the
|
||||
* `apply from: "react.gradle"` line.
|
||||
*
|
||||
* project.ext.react = [
|
||||
* // the name of the generated asset file containing your JS bundle
|
||||
* bundleAssetName: "index.android.bundle",
|
||||
*
|
||||
* // the entry file for bundle generation
|
||||
* entryFile: "index.android.js",
|
||||
*
|
||||
* // whether to bundle JS and assets in debug mode
|
||||
* bundleInDebug: false,
|
||||
*
|
||||
* // whether to bundle JS and assets in release mode
|
||||
* bundleInRelease: true,
|
||||
*
|
||||
* // the root of your project, i.e. where "package.json" lives
|
||||
* root: "../../",
|
||||
*
|
||||
* // where to put the JS bundle asset in debug mode
|
||||
* jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
|
||||
*
|
||||
* // where to put the JS bundle asset in release mode
|
||||
* jsBundleDirRelease: "$buildDir/intermediates/assets/release",
|
||||
*
|
||||
* // where to put drawable resources / React Native assets, e.g. the ones you use via
|
||||
* // require('./image.png')), in debug mode
|
||||
* resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
|
||||
*
|
||||
* // where to put drawable resources / React Native assets, e.g. the ones you use via
|
||||
* // require('./image.png')), in release mode
|
||||
* resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
|
||||
*
|
||||
* // by default the gradle tasks are skipped if none of the JS files or assets change; this means
|
||||
* // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
|
||||
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
|
||||
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
|
||||
* // for example, you might want to remove it from here.
|
||||
* inputExcludes: ["android/**", "ios/**"]
|
||||
* ]
|
||||
*/
|
||||
|
||||
apply plugin: 'de.undercouch.download'
|
||||
|
||||
import de.undercouch.gradle.tasks.download.Download
|
||||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
// We download various C++ open-source dependencies into downloads.
|
||||
// We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
|
||||
// After that we build native code from src/main/jni with module path pointing at third-party-ndk.
|
||||
|
||||
def downloadsDir = new File("$buildDir/downloads")
|
||||
def thirdPartyNdkDir = new File("$buildDir/third-party-ndk")
|
||||
|
||||
task createNativeDepsDirectories {
|
||||
downloadsDir.mkdirs()
|
||||
thirdPartyNdkDir.mkdirs()
|
||||
}
|
||||
|
||||
task downloadRealmCore(type: Download) {
|
||||
src 'http://static.realm.io/downloads/core/realm-core-android-0.94.4.tar.gz'
|
||||
onlyIfNewer true
|
||||
overwrite false
|
||||
dest new File(downloadsDir, 'realm-core-android-0.94.4.tar.gz')
|
||||
}
|
||||
|
||||
task prepareRealmCore(type:Copy) {
|
||||
from tarTree(downloadRealmCore.dest)
|
||||
from 'src/main/jni/third-party/realm-core/Android.mk'
|
||||
into "$thirdPartyNdkDir/realm-core"
|
||||
}
|
||||
|
||||
task downloadJSCHeaders(type: Download) {
|
||||
def jscAPIBaseURL = 'https://svn.webkit.org/repository/webkit/!svn/bc/174650/trunk/Source/JavaScriptCore/API/'
|
||||
def jscHeaderFiles = ['JSBase.h', 'JSContextRef.h', 'JSObjectRef.h', 'JSRetainPtr.h', 'JSStringRef.h', 'JSValueRef.h', 'WebKitAvailability.h', 'JavaScriptCore.h', 'JavaScript.h', 'JSStringRefCF.h']
|
||||
def output = new File(downloadsDir, 'jsc')
|
||||
output.mkdirs()
|
||||
src(jscHeaderFiles.collect { headerName -> "$jscAPIBaseURL$headerName" })
|
||||
onlyIfNewer true
|
||||
overwrite false
|
||||
dest output
|
||||
}
|
||||
|
||||
// Create Android.mk library module based on so files from mvn + include headers fetched from webkit.org
|
||||
task prepareJSC(dependsOn: downloadJSCHeaders) << {
|
||||
copy {
|
||||
from zipTree(configurations.compile.fileCollection { dep -> dep.name == 'android-jsc' }.singleFile)
|
||||
from {downloadJSCHeaders.dest}
|
||||
from 'src/main/jni/third-party/jsc/Android.mk'
|
||||
include 'jni/**/*.so', '*.h', 'Android.mk'
|
||||
filesMatching('*.h', { fname -> fname.path = "JavaScriptCore/${fname.path}"})
|
||||
into "$thirdPartyNdkDir/jsc";
|
||||
}
|
||||
}
|
||||
|
||||
def getNdkBuildName() {
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
return "ndk-build.cmd"
|
||||
} else {
|
||||
return "ndk-build"
|
||||
}
|
||||
}
|
||||
|
||||
def findNdkBuildFullPath() {
|
||||
// we allow to provide full path to ndk-build tool
|
||||
if (hasProperty('ndk.command')) {
|
||||
return property('ndk.command')
|
||||
}
|
||||
// or just a path to the containing directory
|
||||
if (hasProperty('ndk.path')) {
|
||||
def ndkDir = property('ndk.path')
|
||||
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
|
||||
}
|
||||
if (System.getenv('ANDROID_NDK') != null) {
|
||||
def ndkDir = System.getenv('ANDROID_NDK')
|
||||
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
|
||||
}
|
||||
def ndkDir = android.hasProperty('plugin') ? android.plugin.ndkFolder :
|
||||
plugins.getPlugin('com.android.library').sdkHandler.getNdkFolder()
|
||||
if (ndkDir) {
|
||||
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
def getNdkBuildFullPath() {
|
||||
def ndkBuildFullPath = findNdkBuildFullPath()
|
||||
if (ndkBuildFullPath == null) {
|
||||
throw new GradleScriptException(
|
||||
"ndk-build binary cannot be found, check if you've set " +
|
||||
"\$ANDROID_NDK environment variable correctly or if ndk.dir is " +
|
||||
"setup in local.properties",
|
||||
null)
|
||||
}
|
||||
if (!new File(ndkBuildFullPath).canExecute()) {
|
||||
throw new GradleScriptException(
|
||||
"ndk-build binary " + ndkBuildFullPath + " doesn't exist or isn't executable.\n" +
|
||||
"Check that the \$ANDROID_NDK environment variable, or ndk.dir in local.proerties, is set correctly.\n" +
|
||||
"(On Windows, make sure you escape backslashes in local.properties or use forward slashes, e.g. C:\\\\ndk or C:/ndk rather than C:\\ndk)",
|
||||
null)
|
||||
}
|
||||
return ndkBuildFullPath
|
||||
}
|
||||
|
||||
task buildReactNdkLib(dependsOn: [prepareJSC], type: Exec) {
|
||||
inputs.file('src/main/jni')
|
||||
outputs.dir("$buildDir/react-ndk/all")
|
||||
commandLine getNdkBuildFullPath(),
|
||||
'NDK_PROJECT_PATH=null',
|
||||
"NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk",
|
||||
'NDK_OUT=' + temporaryDir,
|
||||
"NDK_LIBS_OUT=$buildDir/react-ndk/all",
|
||||
"THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk",
|
||||
'-C', file('src/main/jni').absolutePath,
|
||||
'-B',
|
||||
'NDK_LOG=1',
|
||||
'--jobs', Runtime.runtime.availableProcessors(),
|
||||
'V=1'
|
||||
}
|
||||
|
||||
task cleanReactNdkLib(type: Exec) {
|
||||
commandLine getNdkBuildFullPath(),
|
||||
'-C', file('src/main/jni').absolutePath,
|
||||
'clean'
|
||||
}
|
||||
|
||||
task packageReactNdkLibs(dependsOn: buildReactNdkLib, type: Copy) {
|
||||
from "$buildDir/react-ndk/all"
|
||||
exclude '**/libjsc.so'
|
||||
into "$buildDir/react-ndk/exported"
|
||||
}
|
||||
apply from: "react.gradle"
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.1"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.demo"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 22
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
ndk {
|
||||
moduleName "reactnativejni"
|
||||
abiFilters "armeabi-v7a", "x86"
|
||||
}
|
||||
|
||||
buildConfigField 'boolean', 'IS_INTERNAL_BUILD', 'false'
|
||||
}
|
||||
|
||||
sourceSets.main {
|
||||
jni.srcDirs = []
|
||||
jniLibs.srcDir "$buildDir/react-ndk/exported"
|
||||
res.srcDirs = ['src/main/res/devsupport', 'src/main/res/shell']
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
compileTask -> compileTask.dependsOn packageReactNdkLibs
|
||||
}
|
||||
|
||||
clean.dependsOn cleanReactNdkLib
|
||||
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false // Set this to true to enable Proguard
|
||||
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile 'com.android.support:appcompat-v7:23.0.1'
|
||||
compile 'com.android.support:recyclerview-v7:23.0.1'
|
||||
compile 'com.facebook.fresco:fresco:0.8.1'
|
||||
compile 'com.facebook.fresco:imagepipeline-okhttp:0.8.1'
|
||||
compile 'com.facebook.stetho:stetho:1.2.0'
|
||||
compile 'com.facebook.stetho:stetho-okhttp:1.2.0'
|
||||
compile 'com.fasterxml.jackson.core:jackson-core:2.2.3'
|
||||
compile 'com.google.code.findbugs:jsr305:3.0.0'
|
||||
compile 'com.squareup.okhttp:okhttp:2.5.0'
|
||||
compile 'com.squareup.okhttp:okhttp-ws:2.5.0'
|
||||
compile 'com.squareup.okio:okio:1.6.0'
|
||||
compile 'org.webkit:android-jsc:r174650'
|
||||
|
||||
testCompile "junit:junit:${JUNIT_VERSION}"
|
||||
testCompile "org.powermock:powermock-api-mockito:${POWERMOCK_VERSION}"
|
||||
testCompile "org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}"
|
||||
testCompile "org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}"
|
||||
testCompile "org.mockito:mockito-core:${MOCKITO_CORE_VERSION}"
|
||||
testCompile "org.easytesting:fest-assert-core:${FEST_ASSERT_CORE_VERSION}"
|
||||
testCompile("org.robolectric:robolectric:${ROBOLECTRIC_VERSION}")
|
||||
compile fileTree(dir: "libs", include: ["*.jar"])
|
||||
compile "com.android.support:appcompat-v7:23.0.1"
|
||||
compile "com.facebook.react:react-native:0.16.+"
|
||||
compile 'com.reacttests:app-debug@aar'
|
||||
}
|
||||
|
||||
apply from: 'release.gradle'
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import org.apache.tools.ant.taskdefs.condition.Os
|
||||
|
||||
def config = project.hasProperty("react") ? project.react : [];
|
||||
|
||||
def bundleAssetName = config.bundleAssetName ?: "index.android.bundle"
|
||||
|
@ -36,8 +38,13 @@ task bundleDebugJsAndAssets(type: Exec) {
|
|||
|
||||
// set up the call to the react-native cli
|
||||
workingDir reactRoot
|
||||
commandLine "react-native", "bundle", "--platform", "android", "--dev", "true", "--entry-file",
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
commandLine "cmd", "/c", "react-native", "bundle", "--platform", "android", "--dev", "true", "--entry-file",
|
||||
entryFile, "--bundle-output", jsBundleFileDebug, "--assets-dest", resourcesDirDebug
|
||||
} else {
|
||||
commandLine "react-native", "bundle", "--platform", "android", "--dev", "true", "--entry-file",
|
||||
entryFile, "--bundle-output", jsBundleFileDebug, "--assets-dest", resourcesDirDebug
|
||||
}
|
||||
|
||||
enabled config.bundleInDebug ?: false
|
||||
}
|
||||
|
@ -56,8 +63,13 @@ task bundleReleaseJsAndAssets(type: Exec) {
|
|||
|
||||
// set up the call to the react-native cli
|
||||
workingDir reactRoot
|
||||
commandLine "react-native", "bundle", "--platform", "android", "--dev", "false", "--entry-file",
|
||||
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||
commandLine "cmd","/c", "react-native", "bundle", "--platform", "android", "--dev", "false", "--entry-file",
|
||||
entryFile, "--bundle-output", jsBundleFileRelease, "--assets-dest", resourcesDirRelease
|
||||
} else {
|
||||
commandLine "react-native", "bundle", "--platform", "android", "--dev", "false", "--entry-file",
|
||||
entryFile, "--bundle-output", jsBundleFileRelease, "--assets-dest", resourcesDirRelease
|
||||
}
|
||||
|
||||
enabled config.bundleInRelease ?: true
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<!-- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.reacttests">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.demo">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
|
@ -10,7 +10,8 @@
|
|||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name">
|
||||
android:label="@string/app_name"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
@ -19,11 +20,4 @@
|
|||
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
|
||||
</application>
|
||||
|
||||
</manifest> -->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.reacttests">
|
||||
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||
|
||||
<application />
|
||||
|
||||
</manifest>
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
// package com.reacttests;
|
||||
|
||||
// import android.app.Activity;
|
||||
// import android.os.Bundle;
|
||||
// import android.view.KeyEvent;
|
||||
|
||||
// import com.facebook.react.LifecycleState;
|
||||
// import com.facebook.react.ReactInstanceManager;
|
||||
// import com.facebook.react.ReactRootView;
|
||||
// import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
||||
// import com.facebook.react.shell.MainReactPackage;
|
||||
// import com.facebook.soloader.SoLoader;
|
||||
|
||||
// public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
|
||||
|
||||
// private ReactInstanceManager mReactInstanceManager;
|
||||
// private ReactRootView mReactRootView;
|
||||
|
||||
// @Override
|
||||
// protected void onCreate(Bundle savedInstanceState) {
|
||||
// super.onCreate(savedInstanceState);
|
||||
// mReactRootView = new ReactRootView(this);
|
||||
|
||||
// mReactInstanceManager = ReactInstanceManager.builder()
|
||||
// .setApplication(getApplication())
|
||||
// .setBundleAssetName("index.android.bundle")
|
||||
// .setJSMainModuleName("index.android")
|
||||
// .addPackage(new MainReactPackage())
|
||||
// .setUseDeveloperSupport(BuildConfig.DEBUG)
|
||||
// .setInitialLifecycleState(LifecycleState.RESUMED)
|
||||
// .build();
|
||||
|
||||
// mReactRootView.startReactApplication(mReactInstanceManager, "ReactTests", null);
|
||||
|
||||
// setContentView(mReactRootView);
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
// if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {
|
||||
// mReactInstanceManager.showDevOptionsDialog();
|
||||
// return true;
|
||||
// }
|
||||
// return super.onKeyUp(keyCode, event);
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public void onBackPressed() {
|
||||
// if (mReactInstanceManager != null) {
|
||||
// mReactInstanceManager.onBackPressed();
|
||||
// } else {
|
||||
// super.onBackPressed();
|
||||
// }
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public void invokeDefaultOnBackPressed() {
|
||||
// super.onBackPressed();
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// protected void onPause() {
|
||||
// super.onPause();
|
||||
|
||||
// if (mReactInstanceManager != null) {
|
||||
// mReactInstanceManager.onPause();
|
||||
// }
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// protected void onResume() {
|
||||
// super.onResume();
|
||||
|
||||
// if (mReactInstanceManager != null) {
|
||||
// mReactInstanceManager.onResume(this);
|
||||
// }
|
||||
// }
|
||||
// }
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue