Skip to content

Commit

Permalink
<build>(project): first commit for structure. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyonRay authored Jul 31, 2024
1 parent 1c8048b commit d2b7729
Show file tree
Hide file tree
Showing 13 changed files with 1,791 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .ci/ci_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -e
LOG_INFO() {
local content=${1}
echo -e "\033[32m ${content}\033[0m"
}

get_sed_cmd()
{
local sed_cmd="sed -i"
if [ "$(uname)" == "Darwin" ];then
sed_cmd="sed -i .bkp"
fi
echo "$sed_cmd"
}

check_basic()
{
# build
bash gradlew build assemble
}

#LOG_INFO "------ download_build_chain---------"
#download_build_chain
LOG_INFO "------ check_basic---------"
check_basic
#LOG_INFO "------ check_ecdsa_evm_node---------"
#check_ecdsa_evm_node
#LOG_INFO "------ check_sm_evm_node---------"
#check_sm_evm_node

#bash <(curl -s https://codecov.io/bash)
26 changes: 26 additions & 0 deletions .github/workflows/ci_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: actions check

on: [push, pull_request]

jobs:
build:
name: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04, macos-12]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 5
- name: install macOS dependencies
if: runner.os == 'macOS'
run: brew install [email protected] openjdk@8
- name: install Ubuntu dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt install -y git curl libssl-dev default-jdk build-essential
- name: run integration testing
run: /bin/bash .ci/ci_check.sh
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

.idea
.vscode
.gradle
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# WeCross-Web3-Stub
# WeCross-Web3-Stub

[![CodeFactor](https://www.codefactor.io/repository/github/webankblockchain/WeCross-Web3-Stub/badge)](https://www.codefactor.io/repository/github/webankblockchain/WeCross-Web3-Stub) [![Build Status](https://travis-ci.org/WeBankBlockchain/WeCross-Web3-Stub.svg?branch=dev)](https://travis-ci.org/WeBankBlockchain/WeCross-Web3-Stub) [![Latest release](https://img.shields.io/github/release/WeBankBlockchain/WeCross-Web3-Stub.svg)](https://github.com/WeBankBlockchain/WeCross-Web3-Stub/releases/latest)
[![License](https://img.shields.io/github/license/WeBankBlockchain/WeCross-Web3-Stub)](https://www.apache.org/licenses/LICENSE-2.0) [![Language](https://img.shields.io/badge/Language-Java-blue.svg)](https://www.java.com)

WeCross Web3 Stub是[WeCross](https://github.com/WeBankBlockchain/WeCross)用于适配[Web3J](https://github.com/hyperledger/web3j/)4.9.8及以上版本的插件。

279 changes: 279 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
plugins {
id 'java'
id 'idea'
id 'eclipse'
id 'maven'
id 'jacoco'
id 'maven-publish'

id 'org.ajoberstar.grgit' version '4.1.1'
id 'com.diffplug.spotless' version '6.13.0'
id 'com.github.johnrengelman.shadow' version '6.1.0'
}
apply plugin: 'com.diffplug.spotless'
apply plugin: 'com.github.johnrengelman.shadow'

group 'com.webank.wecross'
version '1.5.0'

sourceCompatibility = 1.8
targetCompatibility = 1.8

// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
maven { url "https://maven.aliyun.com/nexus/content/groups/public/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
}

spotless {
java {
target 'src/*/java/**/*.java'
removeUnusedImports()
googleJavaFormat()
formatAnnotations()
}

format 'misc', {
target '**/*.gradle', '**/*.md', '**/.gitignore'
}
format 'xml', {
target '**/*.xml'
}
}

task copyHooks(type: Copy) {
println 'copyHooks task'
from("hooks") {
include "**"
}
into ".git/hooks"
}

configurations {
all*.exclude group: 'org.java-websocket', module: 'Java-WebSocket'
all*.exclude group: 'org.antlr', module: '*'
all*.exclude group: 'de.vandermeer', module: '*'
all*.exclude group: 'com.alibaba', module: 'druid'
all*.exclude group: 'org.apache.httpcomponents', module: 'httpclient'
all*.exclude group: 'io.reactivex', module: 'rxjava'
all*.exclude group: 'org.ethereum', module: 'solcJ-all'
all*.exclude group: 'ch.qos.logback', module: 'logback-classic'
all*.exclude group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl'
all*.exclude group: 'com.alibaba', module: 'fastjson'

integTestImplementation.extendsFrom implementation
integTestTestImplementation.extendsFrom testImplementation
}

configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
exclude group: 'org.yaml', module: 'snakeyaml'
}

def log4j_version = '2.22.1'
List logger = [
"org.apache.logging.log4j:log4j-api:$log4j_version",
"org.apache.logging.log4j:log4j-core:$log4j_version",
"org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version",
//"org.apache.logging.log4j:log4j-to-slf4j:$log4j_version",
"org.apache.logging.log4j:log4j-web:$log4j_version",
"org.apache.logging.log4j:log4j-jul:$log4j_version"
]

dependencies {
implementation logger
implementation('com.webank:wecross-java-stub:1.4.0') {
exclude group: "io.netty"
exclude group: 'org.fisco-bcos', module: 'tcnative'
}
// implementation('org.fisco-bcos.java-sdk:fisco-bcos-sdk-abi:2.10.0-SNAPSHOT')

// Use JUnit test framework
testImplementation 'junit:junit:4.13.2'
}

sourceSets {

main {
resources {
exclude '**/*.toml'
exclude '**/*.xml'
exclude '**/*.properties'
exclude '**/*.yml'
exclude '**/*.crt'
exclude '**/*.key'
}
}

// Add the integration test directory
integTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}

resources {
srcDir file('src/integTest/resources')
}
}
}

shadowJar {
dependsOn(copyHooks)
dependencies {
//排除掉io.netty:.*,不打包进fat jar
exclude(dependency('io.netty:.*'))
}
mergeServiceFiles()
minimize{
//不优化处理io.grpc:.*,直接打进fat jar
exclude(dependency('io.grpc:.*'))
}
}


task makeJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar, dependsOn: shadowJar) {

destinationDir file('dist/apps')
archiveName project.name + "-" + project.version + '.jar'
exclude '**/*.xml'
exclude '**/*.toml'
exclude '**/*.properties'
exclude '**/*.yml'
exclude '**/performance/guomi/*'

manifest {
try {
def repo = grgit.open(dir: file('.').canonicalPath)
if (repo != null) {
def date = new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
def branch = repo.branch.getCurrent().getName()
def commit = repo.head().getAbbreviatedId(40)

attributes(["Implementation-Timestamp": date,
"Git-Branch" : branch,
"Git-Commit" : commit
])

logger.info(" Commit : ")
logger.info(" => date: {}", date)
logger.info(" => branch: {}", branch)
logger.info(" => commit: {}", commit)
}
} catch (Exception e) {
// logger.warn(' .git not exist, cannot found commit info')
}
}

dependencies {
exclude(dependency('io.netty:.*'))
}
from zipTree(shadowJar.archivePath)
}

jar.enabled = false
project.tasks.assemble.dependsOn(makeJar)

task integTest(type: Test) {
description = 'Runs integration tests.'

testClassesDirs = sourceSets.integTest.output.classesDirs
classpath = sourceSets.integTest.runtimeClasspath
mustRunAfter test
}

// clean dist and log dir
task cleanDistAndLogDir(type: Delete) {
delete 'dist'
delete 'log'
delete 'out'
}

tasks.clean.dependsOn(tasks.cleanDistAndLogDir)

test {
testLogging {
showStandardStreams = true
events 'passed', 'skipped', 'failed'
}

}

integTest {
testLogging {
showStandardStreams = true
events 'passed', 'skipped', 'failed'
}

}

jacocoTestReport {
reports {
xml.enabled true
html.enabled true
//html.destination file("${buildDir}/jacocoHtml")
}
}

ext {
if (!project.hasProperty("NEXUS_USERNAME")) {
NEXUS_USERNAME = "xxx"
}

if (!project.hasProperty("NEXUS_PASSWORD")) {
NEXUS_PASSWORD = "xxx"
}
}

publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'com.webank'
artifactId = 'wecross-Web3-stub'
from components.java
artifacts = [shadowJar]

// https://docs.gradle.org/current/dsl/org.gradle.api.publish.maven.MavenPublication.html
pom {
name = "WeCross-Web3-Stub"
description = "Stub interface for WeCross"
url = "https://github.com/WeBankBlockchain/WeCross"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "Shareong"
name = "Shareong"
email = "[email protected]"
}
}
scm {
connection = "scm:git:git://github.com/WeBankBlockchain/WeCross.git"
developerConnection = "scm:git:ssh://github.com/WeBankBlockchain/WeCross.git"
url = "https://github.com/WeBankBlockchain/WeCross"
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl

credentials {
username = NEXUS_USERNAME
password = NEXUS_PASSWORD
}

}
}
}
Binary file added docs/images/menu_logo_wecross.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit d2b7729

Please sign in to comment.