mirror of
https://gitee.com/BDWare/common
synced 2025-01-10 09:54:13 +00:00
optimize build.gradle
This commit is contained in:
parent
f9ce2aaff4
commit
59b3805018
18
build.gradle
18
build.gradle
@ -25,24 +25,16 @@ sourceCompatibility = 1.8
|
||||
|
||||
dependencies {
|
||||
api project(":gmhelper")
|
||||
|
||||
api 'berkeleydb:je:3.2.76'
|
||||
api 'com.fifesoft:rsyntaxtextarea:3.1.3'
|
||||
api 'commons-io:commons-io:2.11.0'
|
||||
api 'io.grpc:grpc-all:1.41.0'
|
||||
api 'io.netty:netty-all:4.1.52.Final'
|
||||
api 'io.prometheus:simpleclient:0.12.0'
|
||||
api 'io.netty:netty-all:4.1.42.Final'
|
||||
api 'org.antlr:antlr4:4.9.2'
|
||||
api 'org.apache.commons:commons-lang3:3.12.0'
|
||||
api 'org.apache.httpcomponents:httpclient:4.5.13'
|
||||
api 'org.apache.logging.log4j:log4j-core:2.15.0'
|
||||
api 'org.apache.logging.log4j:log4j-api:2.15.0'
|
||||
api 'org.apache.velocity:velocity-engine-core:2.3'
|
||||
api 'org.knowhowlab.osgi:sigar:1.6.5_01'
|
||||
api 'commons-codec:commons-codec:1.5'
|
||||
api 'org.apache.logging.log4j:log4j-core:2.17.0'
|
||||
api 'org.apache.logging.log4j:log4j-api:2.17.0'
|
||||
//api 'org.apache.velocity:velocity-engine-core:2.3'
|
||||
api 'org.rocksdb:rocksdbjni:6.22.1'
|
||||
|
||||
api fileTree(dir: 'lib', include: '*.jar')
|
||||
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
}
|
||||
|
||||
|
BIN
lib/DoipSDK-1.0.jar.backup
Normal file
BIN
lib/DoipSDK-1.0.jar.backup
Normal file
Binary file not shown.
@ -1,61 +0,0 @@
|
||||
package org.bdware.sc;
|
||||
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.runtime.RuntimeConstants;
|
||||
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
|
||||
import org.bdware.sc.util.JsonUtil;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ContractGenerator {
|
||||
static VelocityEngine ve = init();
|
||||
|
||||
public static String generateAPIContract(long availableDate, String url, String method, Map<String, String> header,
|
||||
Map<String, String> arg) {
|
||||
VelocityContext ctx = new VelocityContext();
|
||||
|
||||
Template script = ve.getTemplate("org/bdware/sc/sc/datacontract.vm");
|
||||
String[][] initList = {{"availableDate", availableDate + ""}, {"baseUrl", stringify(url)},
|
||||
{"method", stringify(method)}, {"headers", convertMap(header)}, {"arg", convertMap(arg)}};
|
||||
ctx.put("initList", initList);
|
||||
ctx.put("validate", "YancloudUtil.currentTimeMillis()>Global.availableDate");
|
||||
ctx.put("validateFailedMsg", "\"key expired\"");
|
||||
StringWriter writer = new StringWriter();
|
||||
script.merge(ctx, writer);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
private static VelocityEngine init() {
|
||||
VelocityEngine ve = new VelocityEngine();
|
||||
ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
|
||||
ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
|
||||
ve.init();
|
||||
return ve;
|
||||
}
|
||||
|
||||
public static String generateFTPContract(long availableDate) {
|
||||
VelocityContext ctx = new VelocityContext();
|
||||
Template script = ve.getTemplate("org/bdware/sc/sc/ftpcontract.vm");
|
||||
String[][] initList = {{"availableDate", availableDate + ""}};
|
||||
ctx.put("initList", initList);
|
||||
ctx.put("validate", "YancloudUtil.currentTimeMillis()>Global.availableDate");
|
||||
StringWriter writer = new StringWriter();
|
||||
script.merge(ctx, writer);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
private static String stringify(String url) {
|
||||
return JsonUtil.toJson(url);
|
||||
}
|
||||
|
||||
private static String convertMap(Map<String, String> arg) {
|
||||
if (arg == null) {
|
||||
arg = new HashMap<>();
|
||||
}
|
||||
return JsonUtil.toJson(arg);
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package org.bdware.sc;
|
||||
|
||||
import com.android.dx.cf.direct.DirectClassFile;
|
||||
import com.android.dx.cf.direct.StdAttributeFactory;
|
||||
import com.android.dx.command.dexer.DxContext;
|
||||
import com.android.dx.dex.DexOptions;
|
||||
import com.android.dx.dex.cf.CfOptions;
|
||||
import com.android.dx.dex.cf.CfTranslator;
|
||||
import com.android.dx.dex.file.ClassDefItem;
|
||||
import com.android.dx.dex.file.DexFile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class DX {
|
||||
public static byte[] clzsToDex(Map<String, byte[]> clzs) {
|
||||
try {
|
||||
DxContext context = new DxContext();
|
||||
DexOptions dexOptions = new DexOptions();
|
||||
dexOptions.minSdkVersion = 26;
|
||||
CfOptions cfOptions = new CfOptions();
|
||||
DexFile outputDex = new DexFile(dexOptions);
|
||||
for (String str : clzs.keySet()) {
|
||||
DirectClassFile dcf =
|
||||
new DirectClassFile(
|
||||
clzs.get(str),
|
||||
toInternalName(str) + ".class",
|
||||
cfOptions.strictNameCheck);
|
||||
dcf.setAttributeFactory(StdAttributeFactory.THE_ONE);
|
||||
ClassDefItem item =
|
||||
CfTranslator.translate(
|
||||
context, dcf, clzs.get(str), cfOptions, dexOptions, outputDex);
|
||||
outputDex.add(item);
|
||||
}
|
||||
return outputDex.toDex(null, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String toInternalName(String plain) {
|
||||
return plain.replaceAll("\\.", "/");
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ import org.rocksdb.RocksDBException;
|
||||
import org.rocksdb.RocksIterator;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -91,6 +92,15 @@ public abstract class StatusRecorder<T extends IDSerializable> {
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(T t) {
|
||||
try {
|
||||
status.remove(t.getID());
|
||||
db.delete((preFix + t.getID()).getBytes(StandardCharsets.UTF_8));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
List<T> getLast(int count) {
|
||||
List<T> ret = new ArrayList<>();
|
||||
Set<Long> set = new HashSet<>(versionIndex.requestLast(count));
|
||||
|
@ -1,15 +0,0 @@
|
||||
package org.bdware.sc.commParser;
|
||||
|
||||
public class BDLedgerAdapter {
|
||||
public Transaction tx;
|
||||
public org.bdware.bdledger.api.grpc.pb.CommonProto.Transaction ledgerChain;
|
||||
|
||||
public BDLedgerAdapter(org.bdware.bdledger.api.grpc.pb.CommonProto.Transaction chaintrans) {
|
||||
super();
|
||||
this.ledgerChain = chaintrans;
|
||||
this.tx = new Transaction();
|
||||
this.tx.Data = chaintrans.getData().toStringUtf8().getBytes();
|
||||
this.tx.SrcID = chaintrans.getFrom().toByteArray(); //本地库中SrcID可以是key
|
||||
this.tx.Txid = chaintrans.getHash().toByteArray();
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package org.bdware.sc.contractGen;
|
||||
|
||||
import org.apache.velocity.Template;
|
||||
import org.apache.velocity.VelocityContext;
|
||||
import org.apache.velocity.app.VelocityEngine;
|
||||
import org.apache.velocity.runtime.RuntimeConstants;
|
||||
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
|
||||
import org.bdware.sc.util.JsonUtil;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ContractGenerator {
|
||||
static VelocityEngine ve = init();
|
||||
|
||||
public static String generateAPIContract(Map<String, String> arg) {
|
||||
VelocityContext ctx = new VelocityContext();
|
||||
Template script = ve.getTemplate("org/bdware/sc/sc/contractGen/timeindexcontract.vm");
|
||||
ctx.put("indexData", arg.get("indexData"));
|
||||
ctx.put("datalen", arg.get("datalen"));
|
||||
ctx.put("sdkpath", arg.get("sdkpath"));
|
||||
ctx.put("syncbyheight", arg.get("syncbyheight"));
|
||||
StringWriter writer = new StringWriter();
|
||||
script.merge(ctx, writer);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
public static String generateIndexContract(long availableDate, String url, String method, Map<String, String> header,
|
||||
Map<String, String> arg) {
|
||||
VelocityContext ctx = new VelocityContext();
|
||||
|
||||
Template script = ve.getTemplate("com/yancloud/sc/indexcontract.vm");
|
||||
String onblock = "var hash = com.yancloud.sc.util.HashUtil.str16ToBytes(args);\n print(hash)";
|
||||
ctx.put("onBlock", onblock);
|
||||
StringWriter writer = new StringWriter();
|
||||
script.merge(ctx, writer);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
private static VelocityEngine init() {
|
||||
VelocityEngine ve = new VelocityEngine();
|
||||
ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
|
||||
ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
|
||||
ve.init();
|
||||
return ve;
|
||||
}
|
||||
|
||||
public static String generateFTPContract(long availableDate) {
|
||||
VelocityContext ctx = new VelocityContext();
|
||||
Template script = ve.getTemplate("org/bdware/sc/sc/ftpcontract.vm");
|
||||
String[][] initList = {{"availableDate", availableDate + ""}};
|
||||
ctx.put("initList", initList);
|
||||
ctx.put("validate", "YancloudUtil.currentTimeMillis()>Global.availableDate");
|
||||
StringWriter writer = new StringWriter();
|
||||
script.merge(ctx, writer);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
private static String stringify(String url) {
|
||||
return JsonUtil.toJson(url);
|
||||
}
|
||||
|
||||
private static String convertMap(Map<String, String> arg) {
|
||||
if (null == arg)
|
||||
arg = new HashMap<>();
|
||||
return JsonUtil.toJson(arg);
|
||||
}
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
package org.bdware.sc.contractGen;
|
||||
|
||||
import org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
import java.awt.*;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ContractGeneratorUI {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.osLookAndFeelDecorated;
|
||||
org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
InitGlobalFont(new Font("alias", Font.PLAIN, 15));
|
||||
|
||||
JFrame frame = new JFrame("索引生成");//创建Frame窗口
|
||||
JPanel checkbox_panel;
|
||||
final JCheckBox checkBox_time;
|
||||
final JCheckBox checkBox_account;
|
||||
checkbox_panel = new JPanel();//面板索引选择
|
||||
checkBox_time = new JCheckBox("时间索引");
|
||||
checkBox_account = new JCheckBox("账户索引");
|
||||
|
||||
checkbox_panel.add(checkBox_time);
|
||||
checkbox_panel.add(checkBox_account);
|
||||
|
||||
final JPanel input_sdk = new JPanel();//SDK包名;
|
||||
final JLabel sdk_label = new JLabel("SDK类名");
|
||||
final JTextField sdk = new JTextField(10);
|
||||
final JLabel datalen_label = new JLabel("数据长度");
|
||||
final JTextField data_length = new JTextField(10);
|
||||
final JCheckBox height_sync_cbox = new JCheckBox("使用高度同步");
|
||||
input_sdk.add(sdk_label);
|
||||
input_sdk.add(sdk);
|
||||
input_sdk.add(datalen_label);
|
||||
input_sdk.add(data_length);
|
||||
input_sdk.add(height_sync_cbox);
|
||||
|
||||
final JTabbedPane tab = new JTabbedPane();//选项卡
|
||||
final JPanel cards = new JPanel(); //卡片式布局的面板
|
||||
cards.add(input_sdk);
|
||||
cards.add(checkbox_panel);
|
||||
cards.add(tab);
|
||||
frame.add(cards);
|
||||
frame.setBounds(100, 200, 800, 800);
|
||||
frame.setVisible(true);
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
final Map<String, MainFrame> framemap = new HashMap<>();
|
||||
checkBox_time.addActionListener(e -> {
|
||||
System.out.println("performed");
|
||||
if (checkBox_time.isSelected()) {
|
||||
if (sdk.getText().length() != 0 && data_length.getText().length() != 0) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("indexData", "./RocksDB");
|
||||
map.put("datalen", data_length.getText());
|
||||
map.put("sdkpath", sdk.getText());
|
||||
if (height_sync_cbox.isSelected()) {
|
||||
map.put("syncbyheight", "true");
|
||||
}
|
||||
String res = ContractGenerator.generateAPIContract(map);
|
||||
MainFrame time_panel = new MainFrame();
|
||||
framemap.put("time", time_panel);
|
||||
time_panel.textfield.setText(res);
|
||||
tab.add(time_panel, "时间索引");
|
||||
try {
|
||||
File file = new File("./output/timeindex.yjs");
|
||||
file.createNewFile();
|
||||
FileWriter writer = new FileWriter(file);
|
||||
BufferedWriter out = new BufferedWriter(writer);
|
||||
out.write(res);
|
||||
out.close();
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tab.remove(framemap.get("time"));
|
||||
}
|
||||
});
|
||||
checkBox_account.addActionListener(e -> {
|
||||
if (checkBox_account.isSelected()) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("indexData", "./RocksDB");
|
||||
String res = ContractGenerator.generateAPIContract(map);
|
||||
MainFrame account_panel = new MainFrame();
|
||||
framemap.put("account", account_panel);
|
||||
account_panel.textfield.setText(res);
|
||||
tab.add(account_panel, "账户索引");
|
||||
try {
|
||||
File file = new File("./output/accountindex.yjs");
|
||||
file.createNewFile();
|
||||
FileWriter writer = new FileWriter(file);
|
||||
BufferedWriter out = new BufferedWriter(writer);
|
||||
out.write(res);
|
||||
out.close();
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
tab.remove(framemap.get("account"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一设置字体,父界面设置之后,所有由父界面进入的子界面都不需要再次设置字体
|
||||
*/
|
||||
private static void InitGlobalFont(Font font) {
|
||||
FontUIResource fontRes = new FontUIResource(font);
|
||||
for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements(); ) {
|
||||
Object key = keys.nextElement();
|
||||
Object value = UIManager.get(key);
|
||||
if (value instanceof FontUIResource) {
|
||||
UIManager.put(key, fontRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package org.bdware.sc.contractGen;
|
||||
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MainFrame extends JPanel {
|
||||
final RSyntaxTextArea textfield;
|
||||
JLabel sdk_label;
|
||||
JLabel datalen_label;
|
||||
|
||||
JPanel p1;
|
||||
JPanel p2;
|
||||
JButton generate;
|
||||
JButton reset;
|
||||
|
||||
public MainFrame() {
|
||||
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
|
||||
|
||||
p1 = new JPanel();//面板OnBlock
|
||||
p2 = new JPanel();//面板OnBlock
|
||||
|
||||
generate = new JButton("生成合约");
|
||||
reset = new JButton("重置内容");
|
||||
p2.add(generate);
|
||||
p2.add(reset);
|
||||
|
||||
this.textfield = new RSyntaxTextArea(30, 80);//height,width
|
||||
textfield.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
|
||||
textfield.setCodeFoldingEnabled(true);
|
||||
|
||||
JScrollPane scroll = new JScrollPane(textfield);
|
||||
scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
p1.add(scroll);
|
||||
this.add(p1);
|
||||
this.add(p2);
|
||||
|
||||
reset.addActionListener(arg0 -> {
|
||||
// TODO Auto-generated method stub
|
||||
textfield.setText("");
|
||||
});
|
||||
generate.addActionListener(e -> {
|
||||
// TODO Auto-generated method stub
|
||||
// use new file to generate yjs
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("indexData", "./RocksDB");
|
||||
String res = ContractGenerator.generateAPIContract(map);
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user