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 'haveno-*' scripts and 'lib' dir generated by the 'installDist' task
    task clean {
        doLast {
            delete fileTree(dir: rootProject.projectDir, include: 'haveno-*'), 'lib'
        }
    }
}

configure(subprojects) {
    apply plugin: 'java'
    apply plugin: 'com.google.osdetector'

    sourceCompatibility = 1.10

    ext { // in alphabetical order
        bcVersion = '1.63'
        bitcoinjVersion = '2a80db4'
        codecVersion = '1.13'
        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'
        gsonVersion = '2.8.5'
        guavaVersion = '28.2-jre'
        moneroJavaVersion = '0.5.5'
        httpclient5Version = '5.0'
        guiceVersion = '4.2.2'
        hamcrestVersion = '1.3'
        httpclientVersion = '4.5.12'
        httpcoreVersion = '4.4.13'
        ioVersion = '2.6'
        jacksonVersion = '2.12.1'
        javafxVersion = '15'
        javaxAnnotationVersion = '1.2'
        jcsvVersion = '1.4.0'
        jetbrainsAnnotationsVersion = '13.0'
        jfoenixVersion = '9.0.10'
        joptVersion = '5.0.4'
        jsonsimpleVersion = '1.1.1'
        jsonrpc4jVersion = '1.6.0.bisq.1'
        junitVersion = '4.12'
        jupiterVersion = '5.7.0'
        kotlinVersion = '1.3.41'
        knowmXchangeVersion = '4.4.2'
        langVersion = '3.11'
        logbackVersion = '1.1.11'
        loggingVersion = '1.2'
        lombokVersion = '1.18.12'
        mockitoVersion = '3.5.15'
        netlayerVersion = '8db4a13' // Commit ID from https://github.com/bisq-network/netlayer/commits/externaltor
        protobufVersion = '3.10.0'
        protocVersion = protobufVersion
        pushyVersion = '0.13.2'
        qrgenVersion = '1.3'
        slf4jVersion = '1.7.30'
        sparkVersion = '2.5.2'
        springBootVersion = '1.5.10.RELEASE'

        os = osdetector.os == 'osx' ? 'mac' : osdetector.os == 'windows' ? 'win' : osdetector.os
    }

    repositories {
        mavenCentral()
        //mavenLocal()
        maven { url 'https://jitpack.io' }
        maven { url 'https://mvnrepository.com' }
    }

    dependencies {
        testCompile "junit:junit:$junitVersion"
    }

    tasks.withType(JavaCompile) {
        options.encoding = 'UTF-8'
    }
}


configure([project(':cli'),
           project(':daemon'),
           project(':desktop'),
           project(':monitor'),
           project(':relay'),
           project(':seednode'),
           project(':statsnode'),
           project(':pricenode'),
           project(':inventory'),
           project(':apitest')]) {

    apply plugin: 'application'

    build.dependsOn installDist
    installDist.destinationDir = file('build/app')
    distZip.enabled = false

    // the 'installDist' and 'startScripts' blocks below configure haveno executables to put
    // generated shell scripts in the root project directory, such that users can easily
    // discover and invoke e.g. ./haveno-desktop, ./haveno-seednode, etc.
    // See https://stackoverflow.com/q/46327736 for details.

    installDist {
        doLast {
            // copy generated shell scripts, e.g. `haveno-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}/haveno-${applicationName}.bat")
            windowsScriptFile.text = windowsScriptFile.text.replace(
                'set APP_HOME=%DIRNAME%..', 'set APP_HOME=%DIRNAME%')

            def unixScriptFile = file("${rootProject.projectDir}/haveno-$applicationName")
            unixScriptFile.text = unixScriptFile.text.replace(
                'cd "`dirname \\"$PRG\\"`/.." >/dev/null', 'cd "`dirname \\"$PRG\\"`" >/dev/null')

            if (applicationName == 'desktop') {
                def script = file("${rootProject.projectDir}/haveno-$applicationName")
                script.text = script.text.replace(
                    'DEFAULT_JVM_OPTS=""', 'DEFAULT_JVM_OPTS="-XX:MaxRAM=4g"')
            }

            if (applicationName == 'apitest') {
                // Pass the logback config file as a system property to avoid chatty
                // logback startup due to multiple logback.xml files in the classpath
                // (:daemon & :cli).
                def script = file("${rootProject.projectDir}/haveno-$applicationName")
                script.text = script.text.replace(
                    'DEFAULT_JVM_OPTS=""', 'DEFAULT_JVM_OPTS="' +
                    '-Dlogback.configurationFile=apitest/build/resources/main/logback.xml"')
            }

            if (osdetector.os != 'windows')
                delete fileTree(dir: rootProject.projectDir, include: 'haveno-*.bat')
            else
                delete fileTree(dir: rootProject.projectDir, include: 'haveno-*', exclude: '*.bat')
        }
    }

    startScripts {
        // rename scripts from, e.g. `desktop` to `haveno-desktop`
        applicationName = "haveno-$applicationName"
    }
}

configure(project(':proto')) {
    apply plugin: 'com.google.protobuf'

    dependencies {
        implementation "com.google.protobuf:protobuf-java:$protobufVersion"
        implementation("io.grpc:grpc-protobuf:$grpcVersion") {
            exclude(module: 'guava')
            exclude(module: 'animal-sniffer-annotations')
        }
        implementation("io.grpc:grpc-stub:$grpcVersion") {
            exclude(module: 'guava')
            exclude(module: 'animal-sniffer-annotations')
        }
        implementation "com.google.guava:guava:$guavaVersion"
        implementation "org.slf4j:slf4j-api:$slf4jVersion"
        implementation "ch.qos.logback:logback-core:$logbackVersion"
        implementation "ch.qos.logback:logback-classic:$logbackVersion"
        compileOnly "org.projectlombok:lombok:$lombokVersion"
        compileOnly "javax.annotation:javax.annotation-api:$javaxAnnotationVersion"
        annotationProcessor "org.projectlombok:lombok:$lombokVersion"
    }

    sourceSets.main.java.srcDirs += [
        'build/generated/source/proto/main/grpc',
        'build/generated/source/proto/main/java'
    ]

    protobuf {
        protoc {
            artifact = "com.google.protobuf:protoc:${protocVersion}"
        }
        plugins {
            grpc {
                artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
            }
        }
        generateProtoTasks {
            all()*.plugins { grpc {} }
        }
    }
}

configure(project(':assets')) {
    dependencies {
        compile("com.github.bisq-network:bitcoinj:$bitcoinjVersion") {
            exclude(module: 'jsr305')
            exclude(module: 'slf4j-api')
            exclude(module: 'guava')
            exclude(module: 'protobuf-java')
            exclude(module: 'bcprov-jdk15on')
            exclude(module: 'okhttp')
            exclude(module: 'okio')
        }
        compile "com.google.guava:guava:$guavaVersion"
        compile "org.slf4j:slf4j-api:$slf4jVersion"
        compile "org.apache.commons:commons-lang3:$langVersion"
    }
}


configure(project(':common')) {
    dependencies {
        compile project(':proto')
        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:$gsonVersion"
        compile "net.sf.jopt-simple:jopt-simple:$joptVersion"
        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:$bitcoinjVersion") {
            exclude(module: 'jsr305')
            exclude(module: 'slf4j-api')
            exclude(module: 'guava')
            exclude(module: 'protobuf-java')
            exclude(module: 'bcprov-jdk15on')
            exclude(module: 'okhttp')
            exclude(module: 'okio')
        }
        runtimeOnly("io.grpc:grpc-netty-shaded:$grpcVersion") {
            exclude(module: 'guava')
            exclude(module: 'animal-sniffer-annotations')
        }
        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"
        testCompile "org.hamcrest:hamcrest-all:$hamcrestVersion"
    }
}


configure(project(':p2p')) {
    dependencies {
        compile project(':common')
        compile("com.github.bisq-network.netlayer:tor.native:$netlayerVersion") {
            exclude(module: 'slf4j-api')
        }
        compile("com.github.bisq-network.netlayer:tor.external:$netlayerVersion") {
            exclude(module: 'slf4j-api')
        }
        implementation("org.apache.httpcomponents:httpclient:$httpclientVersion") {
            exclude(module: 'commons-codec')
        }
        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")
    }

    processResources.doFirst {
        // Sanity check that Git LFS-managed data store files have actually been sync'd.
        // If they have not, e.g. because Git LFS is not installed, they will be text files
        // containing a sha256 hash of the remote object, indicating we should stop the
        // build and inform the user how to fix the problem.
        if (file('src/main/resources/AccountAgeWitnessStore_XMR_TESTNET_placeholder').text.contains("oid sha256:"))
            throw new GradleException("p2p data store files have not been synchronized. " +
                "To fix this, ensure you have Git LFS installed and run `git lfs pull`. " +
                "See docs/build.md for more information.")
    }
}


configure(project(':core')) {
    dependencies {
        compile project(':proto')
        compile project(':assets')
        compile project(':p2p')
        implementation "commons-codec:commons-codec:$codecVersion"
        implementation "com.google.code.gson:gson:$gsonVersion"
        implementation "org.apache.httpcomponents:httpcore:$httpcoreVersion"
        implementation("org.apache.httpcomponents:httpclient:$httpclientVersion") {
            exclude(module: 'commons-codec')
        }
        compile "com.google.guava:guava:$guavaVersion"
        compile("com.github.bisq-network:jsonrpc4j:$jsonrpc4jVersion") {
            exclude(module: 'base64')
            exclude(module: 'httpcore-nio')
        }
        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')
        }
        compile("io.github.monero-ecosystem:monero-java:$moneroJavaVersion") {
            exclude(module: 'jackson-core')
            exclude(module: 'jackson-annotations')
            exclude(module: 'jackson-databind')
            exclude(module: 'bcprov-jdk15on')
        }
        implementation("org.apache.httpcomponents.client5:httpclient5:$httpclient5Version")
        implementation "com.google.protobuf:protobuf-java:$protobufVersion"
        compileOnly "org.projectlombok:lombok:$lombokVersion"
        annotationProcessor "org.projectlombok:lombok:$lombokVersion"

        testCompile "org.hamcrest:hamcrest-all:$hamcrestVersion"
        testCompile "org.mockito:mockito-core:$mockitoVersion"
        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(':cli')) {
    mainClassName = 'bisq.cli.CliMain'

    dependencies {
        compile project(':proto')
        compile project(':core')
        implementation "net.sf.jopt-simple:jopt-simple:$joptVersion"
        implementation "com.google.guava:guava:$guavaVersion"
        implementation "com.google.protobuf:protobuf-java:$protobufVersion"
        implementation("io.grpc:grpc-core:$grpcVersion") {
            exclude(module: 'guava')
            exclude(module: 'animal-sniffer-annotations')
        }
        implementation("io.grpc:grpc-stub:$grpcVersion") {
            exclude(module: 'guava')
            exclude(module: 'animal-sniffer-annotations')
        }
        runtimeOnly("io.grpc:grpc-netty-shaded:$grpcVersion") {
            exclude(module: 'guava')
            exclude(module: 'animal-sniffer-annotations')
        }
        implementation "org.slf4j:slf4j-api:$slf4jVersion"
        implementation "ch.qos.logback:logback-core:$logbackVersion"
        implementation "ch.qos.logback:logback-classic:$logbackVersion"
        compileOnly "org.projectlombok:lombok:$lombokVersion"
        annotationProcessor "org.projectlombok:lombok:$lombokVersion"

        testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
        testImplementation "org.junit.jupiter:junit-jupiter-params:$jupiterVersion"
        testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
        testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
        testCompileOnly "org.projectlombok:lombok:$lombokVersion"
        testRuntime "javax.annotation:javax.annotation-api:$javaxAnnotationVersion"
    }

    test {
        useJUnitPlatform()
    }
}

configure(project(':desktop')) {
    apply plugin: 'com.github.johnrengelman.shadow'
    apply plugin: 'witness'
    apply from: '../gradle/witness/gradle-witness.gradle'
    apply from: 'package/package.gradle'

    version = '1.6.2-SNAPSHOT'

    jar.manifest.attributes(
        "Implementation-Title": project.name,
        "Implementation-Version": version)

    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 "net.glxn:qrgen:$qrgenVersion"
        compile "de.jensd:fontawesomefx:$fontawesomefxVersion"
        compile "de.jensd:fontawesomefx-commons:$fontawesomefxCommonsVersion"
        compile "de.jensd:fontawesomefx-materialdesignfont:$fontawesomefxMaterialdesignfontVersion"
        compile "com.google.guava:guava:$guavaVersion"
        compile "com.googlecode.jcsv:jcsv:$jcsvVersion"
        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 "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")

        compileOnly "org.projectlombok:lombok:$lombokVersion"
        annotationProcessor "org.projectlombok:lombok:$lombokVersion"

        implementation "com.google.code.gson:gson:$gsonVersion"
        implementation "commons-codec:commons-codec:$codecVersion"
        implementation "org.apache.httpcomponents:httpcore:$httpcoreVersion"
        implementation("org.apache.httpcomponents:httpclient:$httpclientVersion") {
            exclude(module: 'commons-codec')
        }
        compile("org.knowm.xchange:xchange-bitbay:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-btcmarkets:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-binance:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-bitfinex:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-bitflyer:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-bitstamp:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-cexio:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-coinmate:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-coinmarketcap:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-coinone:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-exmo:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-hitbtc:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-huobi:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-independentreserve:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-kraken:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-luno:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-mercadobitcoin:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-paribu:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-poloniex:$knowmXchangeVersion")
        compile("org.knowm.xchange:xchange-quoine:$knowmXchangeVersion")
        compile("org.springframework.boot:spring-boot-starter-web:$springBootVersion")
        compile("org.springframework.boot:spring-boot-starter-actuator")
        testCompile "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
        testCompile "org.junit.jupiter:junit-jupiter-params:$jupiterVersion"
        testRuntime("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
        testCompileOnly "org.projectlombok:lombok:$lombokVersion"
        testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
    }

    test {
        useJUnitPlatform()

        // Disabled by default, since spot provider tests include connections to external API endpoints
        // Can be enabled by adding -Dtest.pricenode.includeSpotProviderTests=true to the gradle command:
        // ./gradlew test -Dtest.pricenode.includeSpotProviderTests=true
        if (System.properties['test.pricenode.includeSpotProviderTests'] != 'true') {
            project.logger.lifecycle('Pricenode: Skipping spot provider tests')
            exclude 'bisq/price/spot/providers/**'
        }
    }

    task stage {
        dependsOn assemble
    }
}


configure(project(':relay')) {
    mainClassName = 'bisq.relay.RelayMain'

    dependencies {
        compile project(':common')
        implementation "io.grpc:grpc-auth:$grpcVersion"
        compile "com.sparkjava:spark-core:$sparkVersion"
        compile "com.turo:pushy:$pushyVersion"
        implementation("com.google.firebase:firebase-admin:$firebaseVersion") {
            exclude(module: 'commons-logging')
            exclude(module: 'httpclient')
            exclude(module: 'httpcore')
            exclude(module: 'grpc-auth')
        }
        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"
        implementation "com.google.guava:guava:$guavaVersion"
        annotationProcessor "org.projectlombok:lombok:$lombokVersion"
        testCompile "org.mockito:mockito-core:$mockitoVersion"
    }
}


configure(project(':statsnode')) {
    mainClassName = 'bisq.statistics.StatisticsMain'

    dependencies {
        compile project(':core')
        compileOnly "org.projectlombok:lombok:$lombokVersion"
        annotationProcessor "org.projectlombok:lombok:$lombokVersion"
    }
}

configure(project(':daemon')) {
    mainClassName = 'bisq.daemon.app.BisqDaemonMain'

    dependencies {
        compile project(':core')
        implementation "com.google.guava:guava:$guavaVersion"
        implementation "com.google.protobuf:protobuf-java:$protobufVersion"
        implementation("io.grpc:grpc-protobuf:$grpcVersion") {
            exclude(module: 'guava')
            exclude(module: 'animal-sniffer-annotations')
        }
        implementation("io.grpc:grpc-stub:$grpcVersion") {
            exclude(module: 'guava')
            exclude(module: 'animal-sniffer-annotations')
        }
        runtimeOnly("io.grpc:grpc-netty-shaded:$grpcVersion") {
            exclude(module: 'guava')
            exclude(module: 'animal-sniffer-annotations')
        }
        implementation "org.slf4j:slf4j-api:$slf4jVersion"
        implementation "ch.qos.logback:logback-core:$logbackVersion"
        implementation "ch.qos.logback:logback-classic:$logbackVersion"
        compileOnly "org.projectlombok:lombok:$lombokVersion"
        compileOnly "javax.annotation:javax.annotation-api:$javaxAnnotationVersion"
        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(':inventory')) {
    apply plugin: 'com.github.johnrengelman.shadow'

    mainClassName = 'bisq.inventory.InventoryMonitorMain'

    dependencies {
        compile project(':core')
        compile "com.google.guava:guava:$guavaVersion"
        compile "com.sparkjava:spark-core:$sparkVersion"

        compileOnly "org.projectlombok:lombok:$lombokVersion"
        annotationProcessor "org.projectlombok:lombok:$lombokVersion"
    }
}

configure(project(':apitest')) {
    mainClassName = 'bisq.apitest.ApiTestMain'

    // The external dao-setup.gradle file contains tasks to install and clean dao-setup
    // files downloaded from
    //          https://github.com/bisq-network/bisq/raw/master/docs/dao-setup.zip
    // These tasks are not run by the default build, but they can can be run during
    // full or partial builds, or by themselves.
    // To run the regular clean + build + test (non api), and install dao-setup files:
    //      ./gradlew clean build :apitest:installDaoSetup
    // To install or re-install dao-setup file only:
    //      ./gradlew :apitest:installDaoSetup -x test
    // To clean installed dao-setup files:
    //      ./gradlew :apitest:cleanDaoSetup -x test
    apply from: 'dao-setup.gradle'

    // We have to disable the :apitest 'test' task by default because we do not want
    // to interfere with normal builds.  To run JUnit tests in this subproject:
    // Run a normal build and install dao-setup files first, then run:
    //              'gradle  :apitest:test -DrunApiTests=true'
    test.enabled = System.getProperty("runApiTests") == "true"

    sourceSets {
        main {
            resources {
                exclude 'dao-setup'
                exclude 'dao-setup.zip'
            }
        }
    }

    test {
        useJUnitPlatform()
        outputs.upToDateWhen { false }          // Don't use previously cached test outputs.
        testLogging {
            showStackTraces = true              // Show full stack traces in the console.
            exceptionFormat = "full"
            // Show passed & failed tests, and anything printed to stderr by the tests in the console.
            // Do not show skipped tests in the console;  they are shown in the html report.
            events "passed", "failed", "standardError"
        }

        afterSuite { desc, result ->
            if (!desc.parent) {
                println("${result.resultType} " +
                    "[${result.testCount} tests, " +
                    "${result.successfulTestCount} passed, " +
                    "${result.failedTestCount} failed, " +
                    "${result.skippedTestCount} skipped]  html report contains skipped test info")

                // Show report link if all tests passed in case you want to see more detail, stdout, skipped, etc.
                if (result.resultType == TestResult.ResultType.SUCCESS) {
                    DirectoryReport htmlReport = getReports().getHtml()
                    String reportUrl = new org.gradle.internal.logging.ConsoleRenderer()
                        .asClickableFileUrl(htmlReport.getEntryPoint())
                    println("REPORT  " + reportUrl)
                }
            }
        }
    }

    dependencies {
        compile project(':proto')
        compile project(':common')
        compile project(':seednode')
        compile project(':desktop')
        compile project(':daemon')
        compile project(':cli')
        implementation "net.sf.jopt-simple:jopt-simple:$joptVersion"
        implementation "com.google.guava:guava:$guavaVersion"
        implementation "com.google.protobuf:protobuf-java:$protobufVersion"
        implementation("io.grpc:grpc-protobuf:$grpcVersion") {
            exclude(module: 'guava')
            exclude(module: 'animal-sniffer-annotations')
        }
        implementation("io.grpc:grpc-stub:$grpcVersion") {
            exclude(module: 'guava')
            exclude(module: 'animal-sniffer-annotations')
        }
        implementation "org.slf4j:slf4j-api:$slf4jVersion"
        implementation "ch.qos.logback:logback-core:$logbackVersion"
        implementation "ch.qos.logback:logback-classic:$logbackVersion"

        compileOnly "org.projectlombok:lombok:$lombokVersion"
        compileOnly "javax.annotation:javax.annotation-api:$javaxAnnotationVersion"
        annotationProcessor "org.projectlombok:lombok:$lombokVersion"

        testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion"
        testImplementation "org.junit.jupiter:junit-jupiter-params:$jupiterVersion"
        testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion")
        testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion"
        testCompileOnly "org.projectlombok:lombok:$lombokVersion"
        testRuntime "javax.annotation:javax.annotation-api:$javaxAnnotationVersion"
    }
}