mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
This commit introduces a new `grpc` module including the following key types: - BisqGrpcServer: The API implementation itself, along with generated gRPC Response/Reploy types defined in grpc/src/main/proto/grpc.proto. - BisqGrpcServerMain: A 'headless' / daemon-like entry point for running a Bisq node without the JavaFX desktop UI. - BisqGrpcClient: A simple, repl-style client for the API that allows the user to exercise the various endpoints as seen in the example below. In the `desktop` module, the BisqAppMain class has been modified to start a BisqGrpcServer instance if the `--desktopWithGrpcApi` option has been set to `true`. In the `core` module, a new `CoreApi` class has been introduced providing a kind of comprehensive facade for all Bisq functionality to be exposed via the RPC API. How to explore the proof of concept: 1. Run the main() method in BisqAppMain providing `--desktopWithGrpcApi=true` as a program argument or alternatively, run the main() method in BisqGrpcServerMain, where no special option is required. In either case, you'll notice the following entry in the log output: INFO bisq.grpc.BisqGrpcServer: Server started, listening on 8888 2. Now run the main() method in BisqGrpcClient. Once it has started up you are connected to the gRPC server started in step 1 above. To exercise the API, type `getVersion` via stdin and hit return. You should see the following response: INFO bisq.grpc.BisqGrpcClient - 1.2.4 Likewise, you can type `getBalance` and you'll see the following response: INFO bisq.grpc.BisqGrpcClient - 0.00 BTC and so forth for each of the implemented endpoints. For a list of implemented endpoints, see BisqGrpcServer.start(). Note once again that the code here is merely a proof of concept and should not be considered complete or production-ready in any way. In a subsequent commit, the `--desktopWithGrpcApi` option will be disabled in order to avoid any potential production use. The content of this commit is the result of squashing a number of commits originally authored by chimp1984 in the `chimp1984` fork's `grpc` branch. Co-authored-by: Chris Beams <chris@beams.io>
472 lines
16 KiB
Groovy
472 lines
16 KiB
Groovy
buildscript {
|
|
repositories {
|
|
jcenter()
|
|
}
|
|
dependencies {
|
|
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.10'
|
|
classpath 'com.google.gradle:osdetector-gradle-plugin:1.6.0'
|
|
classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0'
|
|
classpath files('gradle/witness/gradle-witness.jar')
|
|
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.10.RELEASE'
|
|
}
|
|
}
|
|
|
|
configure(rootProject) {
|
|
// remove the 'bisq-*' scripts and 'lib' dir generated by the 'installDist' task
|
|
task clean {
|
|
doLast {
|
|
delete fileTree(dir: rootProject.projectDir, include: 'bisq-*'), 'lib'
|
|
}
|
|
}
|
|
}
|
|
|
|
configure(subprojects) {
|
|
apply plugin: 'java'
|
|
apply plugin: 'com.google.osdetector'
|
|
|
|
sourceCompatibility = 1.10
|
|
|
|
ext { // in alphabetical order
|
|
bcVersion = '1.56'
|
|
bitcoinjVersion = 'a88d36d'
|
|
btcdCli4jVersion = '975ff5d4'
|
|
codecVersion = '1.9'
|
|
commonProtosVersion = '1.17.0'
|
|
easybindVersion = '1.0.3'
|
|
easyVersion = '4.0.1'
|
|
findbugsVersion = '3.0.2'
|
|
firebaseVersion = '6.2.0'
|
|
fontawesomefxVersion = '8.0.0'
|
|
fontawesomefxCommonsVersion = '9.1.2'
|
|
fontawesomefxMaterialdesignfontVersion = '2.0.26-9.1.2'
|
|
grpcVersion = '1.25.0'
|
|
guavaVersion = '20.0'
|
|
guiceVersion = '4.2.2'
|
|
hamcrestVersion = '1.3'
|
|
httpclientVersion = '4.5.3'
|
|
ioVersion = '2.4'
|
|
jacksonVersion = '2.8.10'
|
|
javafxVersion = '11.0.2'
|
|
jcsvVersion = '1.4.0'
|
|
jetbrainsAnnotationsVersion = '13.0'
|
|
jfoenixVersion = '9.0.6'
|
|
joptVersion = '5.0.3'
|
|
jsonsimpleVersion = '1.1.1'
|
|
junitVersion = '4.12'
|
|
jupiterVersion = '5.3.2'
|
|
kotlinVersion = '1.3.41'
|
|
knowmXchangeVersion = '4.3.3'
|
|
langVersion = '3.4'
|
|
logbackVersion = '1.1.10'
|
|
lombokVersion = '1.18.2'
|
|
mockitoVersion = '3.0.0'
|
|
nettyTcNativeVersion = '2.0.27.Final'
|
|
netlayerVersion = '0.6.5.2'
|
|
protobufVersion = '3.9.1'
|
|
pushyVersion = '0.13.2'
|
|
qrgenVersion = '1.3'
|
|
sarxosVersion = '0.3.12'
|
|
slf4jVersion = '1.7.22'
|
|
sparkVersion = '2.5.2'
|
|
springBootVersion = '1.5.10.RELEASE'
|
|
springVersion = '4.3.6.RELEASE'
|
|
|
|
os = osdetector.os == 'osx' ? 'mac' : osdetector.os == 'windows' ? 'win' : osdetector.os
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
maven { url 'https://jitpack.io' }
|
|
}
|
|
|
|
dependencies {
|
|
testCompile "junit:junit:$junitVersion"
|
|
}
|
|
|
|
tasks.withType(JavaCompile) {
|
|
options.encoding = 'UTF-8'
|
|
}
|
|
}
|
|
|
|
|
|
configure([project(':desktop'),
|
|
project(':monitor'),
|
|
project(':relay'),
|
|
project(':seednode'),
|
|
project(':statsnode'),
|
|
project(':pricenode'),
|
|
project(':grpc')]) {
|
|
|
|
apply plugin: 'application'
|
|
|
|
build.dependsOn installDist
|
|
installDist.destinationDir = file('build/app')
|
|
distZip.enabled = false
|
|
|
|
// the 'installDist' and 'startScripts' blocks below configure bisq executables to put
|
|
// generated shell scripts in the root project directory, such that users can easily
|
|
// discover and invoke e.g. ./bisq-desktop, ./bisq-seednode, etc.
|
|
// See https://stackoverflow.com/q/46327736 for details.
|
|
|
|
installDist {
|
|
doLast {
|
|
// copy generated shell scripts, e.g. `bisq-desktop` directly to the project
|
|
// root directory for discoverability and ease of use
|
|
|
|
copy {
|
|
from "$destinationDir/bin"
|
|
into rootProject.projectDir
|
|
}
|
|
// copy libs required for generated shell script classpaths to 'lib' dir under
|
|
// the project root directory
|
|
copy {
|
|
from "$destinationDir/lib"
|
|
into "${rootProject.projectDir}/lib"
|
|
}
|
|
|
|
// edit generated shell scripts such that they expect to be executed in the
|
|
// project root dir as opposed to a 'bin' subdirectory
|
|
def windowsScriptFile = file("${rootProject.projectDir}/bisq-${applicationName}.bat")
|
|
windowsScriptFile.text = windowsScriptFile.text.replace(
|
|
'set APP_HOME=%DIRNAME%..', 'set APP_HOME=%DIRNAME%')
|
|
|
|
def unixScriptFile = file("${rootProject.projectDir}/bisq-$applicationName")
|
|
unixScriptFile.text = unixScriptFile.text.replace(
|
|
'cd "`dirname \\"$PRG\\"`/.." >/dev/null', 'cd "`dirname \\"$PRG\\"`" >/dev/null')
|
|
|
|
if (osdetector.os != 'windows')
|
|
delete fileTree(dir: rootProject.projectDir, include: 'bisq-*.bat')
|
|
else
|
|
delete fileTree(dir: rootProject.projectDir, include: 'bisq-*', exclude: '*.bat')
|
|
}
|
|
}
|
|
|
|
startScripts {
|
|
// rename scripts from, e.g. `desktop` to `bisq-desktop`
|
|
applicationName = "bisq-$applicationName"
|
|
}
|
|
}
|
|
|
|
|
|
configure(project(':assets')) {
|
|
dependencies {
|
|
compile("com.github.bisq-network.bitcoinj:bitcoinj-core:$bitcoinjVersion") {
|
|
exclude(module: 'jsr305')
|
|
exclude(module: 'slf4j-api')
|
|
exclude(module: 'guava')
|
|
exclude(module: 'protobuf-java')
|
|
}
|
|
compile "com.google.guava:guava:$guavaVersion"
|
|
compile "org.slf4j:slf4j-api:$slf4jVersion"
|
|
compile "org.apache.commons:commons-lang3:$langVersion"
|
|
}
|
|
}
|
|
|
|
|
|
configure(project(':common')) {
|
|
apply plugin: 'com.google.protobuf'
|
|
|
|
sourceSets.main.java.srcDir "$buildDir/generated/source/proto/main/java"
|
|
|
|
protobuf {
|
|
protoc {
|
|
artifact = "com.google.protobuf:protoc:$protobufVersion"
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
|
|
compile "org.openjfx:javafx-base:$javafxVersion:$os"
|
|
compile "org.openjfx:javafx-graphics:$javafxVersion:$os"
|
|
compile "com.google.protobuf:protobuf-java:$protobufVersion"
|
|
compile 'com.google.code.gson:gson:2.7'
|
|
compile "org.springframework:spring-core:$springVersion"
|
|
compile "org.slf4j:slf4j-api:$slf4jVersion"
|
|
compile "ch.qos.logback:logback-core:$logbackVersion"
|
|
compile "ch.qos.logback:logback-classic:$logbackVersion"
|
|
compile "com.google.code.findbugs:jsr305:$findbugsVersion"
|
|
compile "com.google.guava:guava:$guavaVersion"
|
|
compile("com.google.inject:guice:$guiceVersion") {
|
|
exclude(module: 'guava')
|
|
}
|
|
compile("com.github.bisq-network.bitcoinj:bitcoinj-core:$bitcoinjVersion") {
|
|
exclude(module: 'jsr305')
|
|
exclude(module: 'slf4j-api')
|
|
exclude(module: 'guava')
|
|
exclude(module: 'protobuf-java')
|
|
}
|
|
compile "org.jetbrains:annotations:$jetbrainsAnnotationsVersion"
|
|
compile "org.bouncycastle:bcpg-jdk15on:$bcVersion"
|
|
compile "commons-io:commons-io:$ioVersion"
|
|
compile "org.apache.commons:commons-lang3:$langVersion"
|
|
compileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
}
|
|
}
|
|
|
|
|
|
configure(project(':p2p')) {
|
|
dependencies {
|
|
compile project(':common')
|
|
compile("com.github.JesusMcCloud.netlayer:tor.native:$netlayerVersion") {
|
|
exclude(module: 'slf4j-api')
|
|
}
|
|
compile("com.github.JesusMcCloud.netlayer:tor.external:$netlayerVersion") {
|
|
exclude(module: 'slf4j-api')
|
|
}
|
|
compile("org.apache.httpcomponents:httpclient:$httpclientVersion") {
|
|
exclude(module: 'commons-logging')
|
|
}
|
|
compile "net.sf.jopt-simple:jopt-simple:$joptVersion"
|
|
compile "org.fxmisc.easybind:easybind:$easybindVersion"
|
|
compileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
testCompile("org.mockito:mockito-core:$mockitoVersion")
|
|
}
|
|
}
|
|
|
|
|
|
configure(project(':core')) {
|
|
dependencies {
|
|
compile project(':assets')
|
|
compile project(':p2p')
|
|
compile "net.sf.jopt-simple:jopt-simple:$joptVersion"
|
|
compile("network.bisq.btcd-cli4j:btcd-cli4j-core:$btcdCli4jVersion") {
|
|
exclude(module: 'slf4j-api')
|
|
exclude(module: 'httpclient')
|
|
exclude(module: 'commons-lang3')
|
|
exclude(module: 'jackson-core')
|
|
exclude(module: 'jackson-annotations')
|
|
exclude(module: 'jackson-databind')
|
|
}
|
|
compile("network.bisq.btcd-cli4j:btcd-cli4j-daemon:$btcdCli4jVersion") {
|
|
exclude(module: 'slf4j-api')
|
|
exclude(module: 'httpclient')
|
|
exclude(module: 'commons-lang3')
|
|
exclude(module: 'jackson-core')
|
|
exclude(module: 'jackson-annotations')
|
|
exclude(module: 'jackson-databind')
|
|
}
|
|
compile "com.fasterxml.jackson.core:jackson-core:$jacksonVersion"
|
|
compile "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"
|
|
compile("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion") {
|
|
exclude(module: 'jackson-annotations')
|
|
}
|
|
|
|
compileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
|
|
testCompile "org.mockito:mockito-core:$mockitoVersion"
|
|
testCompile "org.springframework:spring-test:$springVersion"
|
|
testCompile "com.natpryce:make-it-easy:$easyVersion"
|
|
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: "$hamcrestVersion"
|
|
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
}
|
|
|
|
test {
|
|
systemProperty 'jdk.attach.allowAttachSelf', true
|
|
}
|
|
}
|
|
|
|
configure(project(':desktop')) {
|
|
apply plugin: 'com.github.johnrengelman.shadow'
|
|
apply plugin: 'witness'
|
|
apply from: '../gradle/witness/gradle-witness.gradle'
|
|
|
|
version = '1.2.4-SNAPSHOT'
|
|
|
|
mainClassName = 'bisq.desktop.app.BisqAppMain'
|
|
|
|
tasks.withType(AbstractArchiveTask) {
|
|
preserveFileTimestamps = false
|
|
reproducibleFileOrder = true
|
|
}
|
|
|
|
sourceSets.main.resources.srcDirs += ['src/main/java'] // to copy fxml and css files
|
|
|
|
dependencies {
|
|
compile project(':core')
|
|
compile project(':grpc')
|
|
compile "net.glxn:qrgen:$qrgenVersion"
|
|
compile "de.jensd:fontawesomefx:$fontawesomefxVersion"
|
|
compile "de.jensd:fontawesomefx-commons:$fontawesomefxCommonsVersion"
|
|
compile "de.jensd:fontawesomefx-materialdesignfont:$fontawesomefxMaterialdesignfontVersion"
|
|
compile "com.googlecode.jcsv:jcsv:$jcsvVersion"
|
|
compile "com.github.sarxos:webcam-capture:$sarxosVersion"
|
|
compile "org.openjfx:javafx-controls:$javafxVersion:$os"
|
|
compile "org.openjfx:javafx-fxml:$javafxVersion:$os"
|
|
compile "org.openjfx:javafx-swing:$javafxVersion:$os"
|
|
compile "com.jfoenix:jfoenix:$jfoenixVersion"
|
|
|
|
compileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
|
|
testCompile "org.mockito:mockito-core:$mockitoVersion"
|
|
testCompile "org.springframework:spring-test:$springVersion"
|
|
testCompile "com.natpryce:make-it-easy:$easyVersion"
|
|
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
}
|
|
|
|
test {
|
|
systemProperty 'jdk.attach.allowAttachSelf', true
|
|
}
|
|
}
|
|
|
|
|
|
configure(project(':monitor')) {
|
|
mainClassName = 'bisq.monitor.Monitor'
|
|
|
|
test {
|
|
useJUnitPlatform()
|
|
testLogging {
|
|
events "passed", "skipped", "failed"
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
compile project(':core')
|
|
compile "org.slf4j:slf4j-api:$slf4jVersion"
|
|
compile "ch.qos.logback:logback-core:$logbackVersion"
|
|
compile "ch.qos.logback:logback-classic:$logbackVersion"
|
|
compile "com.google.guava:guava:$guavaVersion"
|
|
|
|
compileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
|
|
testCompile "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
|
|
testCompile "org.junit.jupiter:junit-jupiter-params:$jupiterVersion"
|
|
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
testRuntime("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
|
|
}
|
|
}
|
|
|
|
|
|
configure(project(':pricenode')) {
|
|
apply plugin: "org.springframework.boot"
|
|
|
|
version = file("src/main/resources/version.txt").text.trim()
|
|
|
|
jar.manifest.attributes(
|
|
"Implementation-Title": project.name,
|
|
"Implementation-Version": version)
|
|
|
|
dependencies {
|
|
compile project(":core")
|
|
compile("org.knowm.xchange:xchange-bitcoinaverage:$knowmXchangeVersion")
|
|
compile("org.knowm.xchange:xchange-coinmarketcap:$knowmXchangeVersion")
|
|
compile("org.knowm.xchange:xchange-poloniex:$knowmXchangeVersion")
|
|
compile("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
|
|
compile("org.springframework.boot:spring-boot-starter-actuator")
|
|
}
|
|
|
|
task stage {
|
|
dependsOn assemble
|
|
}
|
|
}
|
|
|
|
|
|
configure(project(':relay')) {
|
|
mainClassName = 'bisq.relay.RelayMain'
|
|
|
|
dependencies {
|
|
compile project(':common')
|
|
compile "com.sparkjava:spark-core:$sparkVersion"
|
|
compile "com.turo:pushy:$pushyVersion"
|
|
compile "com.google.firebase:firebase-admin:$firebaseVersion"
|
|
compile "commons-codec:commons-codec:$codecVersion"
|
|
}
|
|
}
|
|
|
|
|
|
configure(project(':seednode')) {
|
|
apply plugin: 'com.github.johnrengelman.shadow'
|
|
|
|
mainClassName = 'bisq.seednode.SeedNodeMain'
|
|
|
|
dependencies {
|
|
compile project(':core')
|
|
compileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
testCompile "org.springframework:spring-test:$springVersion"
|
|
}
|
|
}
|
|
|
|
|
|
configure(project(':statsnode')) {
|
|
mainClassName = 'bisq.statistics.StatisticsMain'
|
|
|
|
dependencies {
|
|
compile project(':core')
|
|
compileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
}
|
|
}
|
|
|
|
configure(project(':grpc')) {
|
|
apply plugin: 'com.google.protobuf'
|
|
|
|
mainClassName = 'bisq.grpc.BisqGrpcServerMain'
|
|
|
|
// FIXME we dont want to have one src dir inside the other....
|
|
sourceSets.main.java.srcDir "$buildDir/generated/source/proto/main"
|
|
sourceSets.main.java.srcDir "$buildDir/generated/source/proto/main/java"
|
|
|
|
protobuf {
|
|
protoc {
|
|
artifact = "com.google.protobuf:protoc:$protobufVersion"
|
|
}
|
|
plugins {
|
|
grpc {
|
|
artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion"
|
|
}
|
|
}
|
|
generateProtoTasks {
|
|
all()*.plugins {
|
|
grpc {}
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
compile project(':core')
|
|
compile "com.google.protobuf:protobuf-java:$protobufVersion"
|
|
compile "com.google.api.grpc:proto-google-common-protos:$commonProtosVersion"
|
|
|
|
// FIXME Not clear which of the following libs have a newer version of guava which is not compatible with ours
|
|
compile ("io.grpc:grpc-alts:$grpcVersion") {
|
|
exclude(module: 'guava')
|
|
}
|
|
|
|
compile ("io.grpc:grpc-netty:$grpcVersion") {
|
|
exclude(module: 'guava')
|
|
}
|
|
|
|
|
|
compile ("io.grpc:grpc-protobuf:$grpcVersion") {
|
|
exclude(module: 'guava')
|
|
}
|
|
|
|
compile ("io.grpc:grpc-stub:$grpcVersion") {
|
|
exclude(module: 'guava')
|
|
}
|
|
|
|
// Used for TLS in HelloWorldServerTls
|
|
compile "io.netty:netty-tcnative-boringssl-static:${nettyTcNativeVersion}"
|
|
|
|
compileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
compileOnly "javax.annotation:javax.annotation-api:1.2"
|
|
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
|
|
testCompile "io.grpc:grpc-testing:${grpcVersion}"
|
|
testCompile "org.mockito:mockito-core:$mockitoVersion"
|
|
testCompile "org.springframework:spring-test:$springVersion"
|
|
testCompile "com.natpryce:make-it-easy:$easyVersion"
|
|
testCompileOnly "org.projectlombok:lombok:$lombokVersion"
|
|
testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
|
}
|
|
}
|