feat: support publish to mvn center

This commit is contained in:
CaiHQ 2022-04-21 22:43:39 +08:00
parent 8f8c0f27df
commit 3bf91fe053
4 changed files with 104 additions and 16 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
gradle.properties
build
# Compiled class file
*.class

12
README.md Normal file
View File

@ -0,0 +1,12 @@
#说明
本项目fork自`https://github.com/ZZMarquis/gmhelper`
和`https://github.com/FISCO-BCOS/paillier-lib`
编译报错时需配置gradle.properties文件
```bash
NEXUS_USERNAME=_your_name_
NEXUS_PASSWORD=_your_passowrd_
signing.keyId=_your_own_key_id_
signing.password=_keyid_passowrd_
signing.secretKeyRingFile=/path/to/the/key.pgp
```

View File

@ -1,7 +1,11 @@
plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id 'signing'
}
group 'org.bdware.bdcontract'
version '0.1.0'
sourceCompatibility = 1.8
repositories {
@ -13,13 +17,8 @@ task copyLibs(type: Copy) {
into "./build/output/libs/"
}
//task copyJar(type: Exec, dependsOn: [":gmhelper:jar", ":gmhelper:copyLibs"]) {
// println("copyJar start")
// commandLine "cp", "./build/libs/$project.name-$version" + ".jar", "./build/output/gmhelper.jar"
//}
task copyJar(type: Copy, dependsOn: [":gmhelper:jar", ":gmhelper:copyLibs"]) {
from "./build/libs/$project.name-${project.version}.jar"
from "./build/libs/$project.name-${version}.jar"
into "./build/output"
rename { String fileName -> "gmhelper.jar" }
doFirst {
@ -31,6 +30,85 @@ dependencies {
api 'com.google.code.gson:gson:2.8.8'
api 'org.bouncycastle:bcpkix-jdk15on:1.69'
api 'org.bouncycastle:bcprov-jdk15on:1.69'
testImplementation 'junit:junit:4.13.2'
}
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 "gmhelper"
version "${version}"
from components.java
artifact sourceJar
artifact javadocJar
artifact classJar
pom {
name = "bdware-gmhelper"
description = "gmhelper"
url = "https://gitee.com/BDWare/gmhelper"
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/gmhelper.git"
developerConnection = "scm:git:https://gitee.com/BDWare/gmhelper.git"
url = "https://gitee.com/BDWare/gmhelper"
}
}
}
}
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
}

View File

@ -1,7 +1,7 @@
package org.zz.gmhelper;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bouncycastle.crypto.params.ECDomainParameters;
import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
import org.bouncycastle.crypto.params.ECPublicKeyParameters;
@ -13,7 +13,6 @@ import org.bouncycastle.pqc.math.linearalgebra.ByteUtils;
import java.math.BigInteger;
import java.security.KeyPair;
import java.util.Map;
/**
* SM2密钥对Bean
@ -30,11 +29,9 @@ public class SM2KeyPair {
}
public static SM2KeyPair fromJson(String jsonStr) {
Map<String, String> jo =
new Gson().fromJson(jsonStr, new TypeToken<Map<String, String>>() {
}.getType());
String publicKeyStr = jo.get("publicKey");
String privateKeyStr = jo.get("privateKey");
JsonObject jo = JsonParser.parseString(jsonStr).getAsJsonObject();
String publicKeyStr = jo.get("publicKey").getAsString();
String privateKeyStr = jo.get("privateKey").getAsString();
ECPublicKeyParameters point =
BCECUtil.createECPublicKeyFromStrParameters(
publicKeyStr, SM2Util.CURVE, SM2Util.DOMAIN_PARAMS);