diff --git a/build.gradle b/build.gradle index edee227..5e107ef 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,17 @@ plugins { + id 'java' id 'java-library' + id 'maven-publish' + id 'signing' } - -group 'com.bdware.sc' -version '1.0-SNAPSHOT' - +group 'org.bdware.bdcontract' +version '1.0.0' sourceCompatibility = 1.8 + repositories { + mavenLocal() + maven { url 'https://maven.aliyun.com/repository/public' } mavenCentral() } @@ -31,11 +35,11 @@ sourceSets { } dependencies { - api project(":gmhelper") + api 'com.google.code.gson:gson:2.8.8' + api 'org.bdware.bdcontract:gmhelper:0.1.0' api 'javax.websocket:javax.websocket-api:1.1' - api 'log4j:log4j:1.2.17' - api 'org.apache.logging.log4j:log4j-core:2.14.1' - api 'org.apache.logging.log4j:log4j-api:2.14.1' + api 'org.apache.logging.log4j:log4j-core:2.17.2' + api 'org.apache.logging.log4j:log4j-api:2.17.2' api 'org.glassfish.tyrus.bundles:tyrus-standalone-client:1.17' testImplementation 'junit:junit:4.13.2' } @@ -69,4 +73,84 @@ task release(type: Zip, dependsOn: ["copyJar", "copyLibs"]) { duplicatesStrategy = DuplicatesStrategy.INCLUDE archiveFileName = "java-client-${projectIds.version}.zip" destinationDirectory = file('build/') +} + +task classJar(type: Jar, dependsOn: classes) { + classifier = "jar" +} +task sourceJar(type: Jar, dependsOn: classes) { + archiveClassifier = "sources" + classifier = "sources" + from sourceSets.main.allSource +} + +tasks.withType(Javadoc) { + options.addStringOption('Xdoclint:none', '-quiet') +} + +task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier = 'javadoc' + classifier = "javadoc" + exclude { + details -> details.file.getAbsolutePath().contains("/gm/") + } + from javadoc.destinationDir +} + +publishing { + publications { + mavenJava(MavenPublication) { + groupId project.group + artifactId "sdk-java" + version "${version}" + from components.java + artifact sourceJar + artifact javadocJar + artifact classJar + pom { + name = "bdware-sdk-java" + description = "sdk-java" + url = "https://gitee.com/BDWare/sdk-java" + licenses { + license { + name = "Mulan PSL v2" + url = "http://license.coscl.org.cn/MulanPSL2" + } + } + developers { + developer { + id = "dataware" + email = "caihq@pku.edu.cn" + } + } + scm { + connection = "scm:git:https://gitee.com/BDWare/sdk-java.git" + developerConnection = "scm:git:https://gitee.com/BDWare/sdk-java.git" + url = "https://gitee.com/BDWare/sdk-java" + } + } + + } + } + repositories { + maven { + name 'bdwareSnapshotRepository' + url 'https://oss.sonatype.org/content/repositories/snapshots' + credentials { + username = "${NEXUS_USERNAME}" + password = "${NEXUS_PASSWORD}" + } + } + maven { + name 'bdwareRepository' + url 'https://oss.sonatype.org/service/local/staging/deploy/maven2' + credentials { + username = "${NEXUS_USERNAME}" + password = "${NEXUS_PASSWORD}" + } + } + } +} +signing { + sign publishing.publications.mavenJava } \ No newline at end of file diff --git a/src/main/java/org/bdware/client/Main.java b/src/main/java/org/bdware/client/Main.java index 7f88e7c..5f79490 100644 --- a/src/main/java/org/bdware/client/Main.java +++ b/src/main/java/org/bdware/client/Main.java @@ -4,7 +4,6 @@ import com.google.gson.JsonObject; import org.bdware.client.ws.Action; import org.zz.gmhelper.SM2KeyPair; import org.zz.gmhelper.SM2Util; - public class Main { public static void main(String[] args) throws InterruptedException { if (args.length == 0 || args[0].equals("-h") || args[0].equals("--help")) { diff --git a/src/main/sdk/org/bdware/client/SmartContractHandler.java b/src/main/sdk/org/bdware/client/SmartContractHandler.java index 601e3b8..a3107dd 100644 --- a/src/main/sdk/org/bdware/client/SmartContractHandler.java +++ b/src/main/sdk/org/bdware/client/SmartContractHandler.java @@ -93,7 +93,7 @@ public abstract class SmartContractHandler implements Handler { @Override public void handle(JsonObject obj) { try { -// LOGGER.info("receive:" + obj); + LOGGER.info("receive:" + obj); if (!obj.has("action")) { LOGGER.warn("can't handle message without action: " + obj); } @@ -104,10 +104,12 @@ public abstract class SmartContractHandler implements Handler { } else { LOGGER.warn("can't handle action: " + methodName + " -> " + obj); } - } catch (SecurityException e) { + } catch (Exception e) { onUndefined(obj); } catch (Throwable t) { t.printStackTrace(); } } + + }