doric-cli add createLib
This commit is contained in:
1
doric-cli/assets-lib/android/.gitignore
vendored
Normal file
1
doric-cli/assets-lib/android/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
46
doric-cli/assets-lib/android/build.gradle
Normal file
46
doric-cli/assets-lib/android/build.gradle
Normal file
@@ -0,0 +1,46 @@
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
def model = new JsonSlurper().parse(new File(project.getProjectDir().parent + File.separator + "package.json"))
|
||||
def doricSDKVersion = model.dependencies.doric.replace("^", "").replace(">=","")
|
||||
|
||||
println("Doric Version:" + doricSDKVersion)
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.3'
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.allprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
|
||||
sourceSets {
|
||||
main.assets.srcDirs += "../dist"
|
||||
}
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api "pub.doric:core:$doricSDKVersion"
|
||||
}
|
0
doric-cli/assets-lib/android/consumer-rules.pro
Normal file
0
doric-cli/assets-lib/android/consumer-rules.pro
Normal file
21
doric-cli/assets-lib/android/proguard-rules.pro
vendored
Normal file
21
doric-cli/assets-lib/android/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="pub.doric.android.library">
|
||||
|
||||
</manifest>
|
@@ -0,0 +1,21 @@
|
||||
package pub.doric.library;
|
||||
|
||||
import com.github.pengfeizhou.jscore.JavaValue;
|
||||
|
||||
import pub.doric.DoricContext;
|
||||
import pub.doric.extension.bridge.DoricMethod;
|
||||
import pub.doric.extension.bridge.DoricPlugin;
|
||||
import pub.doric.extension.bridge.DoricPromise;
|
||||
import pub.doric.plugin.DoricJavaPlugin;
|
||||
|
||||
@DoricPlugin(name = "demoPlugin")
|
||||
public class DoricDemoPlugin extends DoricJavaPlugin {
|
||||
public DoricDemoPlugin(DoricContext doricContext) {
|
||||
super(doricContext);
|
||||
}
|
||||
|
||||
@DoricMethod
|
||||
public void call(DoricPromise promise) {
|
||||
promise.resolve(new JavaValue("This is from android"));
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package pub.doric.library;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import pub.doric.Doric;
|
||||
import pub.doric.DoricComponent;
|
||||
import pub.doric.DoricLibrary;
|
||||
import pub.doric.DoricRegistry;
|
||||
|
||||
@DoricComponent
|
||||
public class __$RawName__Library extends DoricLibrary {
|
||||
@Override
|
||||
public void load(DoricRegistry registry) {
|
||||
try {
|
||||
InputStream is = Doric.application().getAssets().open("bundle___$__.js");
|
||||
byte[] bytes = new byte[is.available()];
|
||||
is.read(bytes);
|
||||
String content = new String(bytes);
|
||||
registry.registerJSBundle("__$__", content);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
registry.registerNativePlugin(DoricDemoPlugin.class);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user