https://github.com/web3j/quorum
Raw File
Tip revision: 445175fec72663d413971d098c0b5591c5fcf35f authored by Antony Denyer on 17 September 2019, 14:23:32 UTC
Merge pull request #41 from AlexandrouR/patch-1
Tip revision: 445175f
build.gradle
buildscript {
    ext.kotlin_version = '1.2.71'
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

plugins {
    id "com.gradle.plugin-publish" version "0.10.0"
    id 'com.jfrog.bintray' version '1.8.4'
    id 'java-gradle-plugin'
    id 'java'

    // Required for JFrog Artifactory repository
    id 'jacoco'
    id 'maven-publish'

    // Required for Maven Nexus repository
    id 'maven'
    id 'signing'
    id 'idea'
}

apply plugin: 'kotlin'

description 'web3j Quorum API'
sourceCompatibility = 1.8

jacoco {
    toolVersion = '0.7.7.201606060606' // See http://www.eclemma.org/jacoco/.
}

jacocoTestReport {
    reports {
        xml.enabled true
    }
}


ext {
    web3jVersion = '4.+'
    jacksonKotlinVersion = '2.9.0'

    logbackVersion = '1.2.3'
    junitVersion = '4.12'
    mockitoVersion = '1.10.19'
    assertjCoreVersion = '3.8.0'

    ossrhUsername = project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : System.getenv('OSSRH_USERNAME')
    ossrhPassword = project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : System.getenv('OSSRH_PASSWORD')
    ossrhRepoUrl = project.hasProperty('ossrhRepoUrl') ? project.property('ossrhRepoUrl') : System.getenv('OSSRH_REPO_URL')
    bintrayUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
    bintrayKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
    bintrayGpgPassphrase = project.hasProperty('bintrayGpgPassphrase') ? project.property('bintrayGpgPassphrase') : System.getenv('BINTRAY_GPG_PASSPHRASE')
    isSnapshotVersion = project.version.endsWith("-SNAPSHOT")
    manualRelease = project.hasProperty('manualRelease') ? project.property('manualRelease').toBoolean() : false
}

repositories {
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version",
            "com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonKotlinVersion",
            "org.web3j:core:$web3jVersion"
    
    testCompile "junit:junit:$junitVersion",
            "ch.qos.logback:logback-core:$logbackVersion",
            "ch.qos.logback:logback-classic:$logbackVersion",
            "org.mockito:mockito-core:$mockitoVersion",
            "org.assertj:assertj-core:$assertjCoreVersion",
            "org.web3j:core:$web3jVersion:tests"
}

tasks.withType(Test) {
    reports.html.destination = file("${reporting.baseDir}/${name}")
}

task javadocJar(type: Jar) {
    classifier = 'javadoc'
    from javadoc
}

task sourcesJar(type: Jar) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

artifacts {
    archives sourcesJar, javadocJar
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java

            artifact sourcesJar {
                classifier 'sources'
            }

            artifact javadocJar {
                classifier 'javadoc'
            }

            pom {
                name = project.name
                description = project.description
                url = "https://github.com/web3j/quorum"

                licenses {
                    license {
                        name = "The Apache License, Version 2.0"
                        url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
                        distribution = "repo"
                    }
                }
                developers {
                    developer {
                        id = "conor10"
                        name = "Conor Svensson"
                        email = "conor10@gmail.com"
                    }
                }
                scm {
                    url = "https://github.com/web3j/quorum"
                    connection = "scm:https://github.com/web3j/quorum.git"
                    developerConnection = "scm:git://github.com/web3j/quorum.git"
                }
            }
        }
    }
}

signing {
    // We only want to sign the artifacts if we are building and publishing from local (manual release).
    // Otherwise, Gitlab CI/CD does it for us.
    required { manualRelease && gradle.taskGraph.hasTask('uploadArchives') }  // only execute as part of this task
    sign configurations.archives
}

uploadArchives {
    repositories {
        mavenDeployer {

            onlyIf {
                // Only run if this is a manual release triggered by a user, or an automated release for snapshots.
                // We don't need to run this for automated releases.
                isSnapshotVersion && ossrhUsername != '' && ossrhPassword != '' && ossrhRepoUrl != ''
            }

            repository(url: ossrhRepoUrl) {
                authentication(
                        userName: ossrhUsername,
                        password: ossrhPassword
                )
            }

            pom.project {
                name project.name
                packaging 'jar'
                description project.description
                url 'https://web3j.io'

                scm {
                    url 'https://github.com/web3j/quorum'
                    connection 'scm:https://github.com/web3j/quorum.git'
                    developerConnection 'scm:git://github.com/web3j/quorum.git'
                }

                licenses {
                    license {
                        name 'The Apache License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                        distribution 'repo'
                    }
                }

                developers {
                    developer {
                        id 'conor10'
                        name 'Conor Svensson'
                        email 'conor10@gmail.com'
                    }
                }
            }
        }
    }
}

bintray {
    user = bintrayUser
    key = bintrayKey
    publications = ['mavenJava']
    publish = true
    pkg {
        repo = 'maven'
        name = 'quorum'
        desc = 'web3j Quorum API'
        userOrg = 'web3j'
        licenses = ['Apache-2.0']
        issueTrackerUrl = 'https://github.com/web3j/web3j-gradle-plugin/issues'
        vcsUrl = 'https://github.com/web3j/web3j-gradle-plugin.git'
        websiteUrl = 'http://web3j.io'
        publicDownloadNumbers = true
        version {
            gpg {
                sign = true
                passphrase = bintrayGpgPassphrase
            }
            mavenCentralSync {
                sync = true
                user = ossrhUsername
                password = ossrhPassword
                close = '1'
            }
        }
    }
}

task release {
    dependsOn 'build'
    dependsOn 'uploadArchives'

    doLast {
        // Validates the user inputs before a release can be performed.
        if (isSnapshotVersion) {
            // Only need OSSRH details.
            logger.lifecycle("About to perform {} snapshot release ...", manualRelease ? "a manual" : "an automated")

            if (!ossrhUsername || !ossrhPassword || !ossrhRepoUrl) {
                throw new InvalidUserDataException("Required parameters missing:  'ossrhUsername', 'ossrhPassword', 'ossrhRepoUrl'")
            }

            logger.lifecycle(" - ossrhUsername={}", ossrhUsername)
            logger.lifecycle(" - ossrhPassword={}", ossrhPassword ? "provided" : "not_provided")
            logger.lifecycle(" - ossrhRepoUrl={}", ossrhRepoUrl)
        } else {
            // Release => Need OSSRH and bintray.
            if (!ossrhUsername || !ossrhPassword || !ossrhRepoUrl) {
                throw new InvalidUserDataException("Required parameters missing:  'ossrhUsername', 'ossrhPassword', 'ossrhRepoUrl'")
            }
            if (!bintrayUser || !bintrayKey || !bintrayGpgPassphrase) {
                throw new InvalidUserDataException("Required parameters missing:  'bintrayUser', 'bintrayKey', 'bintrayGpgPassphrase'")
            }
            logger.lifecycle("About to perform {} full release ...", manualRelease ? "a manual" : "an automated")
            logger.lifecycle(" - ossrhUsername={}", ossrhUsername)
            logger.lifecycle(" - ossrhPassword={}", ossrhPassword ? "provided" : "not_provided")
            logger.lifecycle(" - ossrhRepoUrl={}", ossrhRepoUrl)
            logger.lifecycle(" - bintrayUser={}", bintrayUser)
            logger.lifecycle(" - bintrayKey={}", bintrayKey ? "provided" : "not_provided")
            logger.lifecycle(" - bintrayGpgPassphrase={}", bintrayGpgPassphrase ? "provided" : "not_provided")
        }
    }

    // Snapshots go to nexus, non-snapshots go to bintray.
    if (isSnapshotVersion) {
        dependsOn 'uploadArchives'
        tasks.findByName('uploadArchives').mustRunAfter 'build'
    } else {
        dependsOn 'bintrayUpload'
        tasks.findByName('bintrayUpload').mustRunAfter 'build'
    }
}

compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
back to top