plugins {
    id 'java-library'
    id 'com.google.protobuf'
    id 'maven-publish'
}

version = '0.16-SNAPSHOT'
archivesBaseName = 'libdohj-core'

dependencies {
    api 'org.bitcoinj:bitcoinj-core:0.16.1'
    api 'org.bouncycastle:bcprov-jdk15to18:1.70'
    api 'com.google.guava:guava:31.0.1-android'
    api 'com.google.protobuf:protobuf-javalite:3.18.0'
    api 'com.squareup.okhttp3:okhttp:3.14.9'
    implementation 'org.slf4j:slf4j-api:1.7.32'
    implementation 'net.jcip:jcip-annotations:1.0'
    implementation 'com.lambdaworks:scrypt:1.4.0'
    compileOnly 'org.fusesource.leveldbjni:leveldbjni-all:1.8'
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
    testImplementation 'org.slf4j:slf4j-jdk14:1.7.32'
    testImplementation 'org.fusesource.leveldbjni:leveldbjni-all:1.8'
}

sourceCompatibility = 8

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.18.0'
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java {
                    option "lite"
                }
            }
        }
    }
    generatedFilesBaseDir = new File(projectDir, '/src') // workaround for '$projectDir/src'
}

test {
    exclude 'org/libdohj/net/NetworkAbstractionTests*'
    testLogging {
        events "failed"
        exceptionFormat "full"
    }
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    archiveClassifier  = 'javadoc'
    from javadoc.destinationDir
}

task sourcesJar(type: Jar, dependsOn: classes) {
    archiveClassifier  = 'sources'
    from sourceSets.main.allSource
}

artifacts {
    archives sourcesJar
    archives javadocJar
}

publishing {
    publications {
        maven(MavenPublication) {
            groupId = 'org.libdohj'
            artifactId = 'libdohj'
            version = '0.16-SNAPSHOT'

            from components.java
        }
    }
}
