From 6429311086aa067814bd2e0e688d64d53ff59eaf Mon Sep 17 00:00:00 2001 From: Adrian Sutton Date: Mon, 1 Jul 2019 08:29:07 +1000 Subject: [PATCH] Upload jars to bintray as part of releases (#1608) Signed-off-by: Adrian Sutton --- build.gradle | 127 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 95 insertions(+), 32 deletions(-) diff --git a/build.gradle b/build.gradle index 3ba255cc40..6d79182a65 100644 --- a/build.gradle +++ b/build.gradle @@ -57,13 +57,31 @@ def _strListCmdArg(name, defaultValue) { if (!project.hasProperty(name)) return defaultValue - return ((String)project.property(name)).tokenize(',') + return ((String) project.property(name)).tokenize(',') } def _strListCmdArg(name) { return _strListCmdArg(name, null) } +apply plugin: 'com.jfrog.bintray' + +def bintrayUser = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') +def bintrayKey = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_KEY') +def bintrayPackage = bintray.pkg { + repo = 'pegasys-repo' + name = 'pantheon' + userOrg = 'consensys' + licenses = ['Apache-2.0'] + websiteUrl = 'https://github.com/PegaSysEng/pantheon' + issueTrackerUrl = 'https://github.com/PegaSysEng/pantheon/issues' + vcsUrl = 'https://github.com/PegaSysEng/pantheon.git' + + version { + name = project.version + released = new Date() + } +} allprojects { apply plugin: 'java-library' @@ -82,6 +100,16 @@ allprojects { } } + task sourcesJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource + } + + task javadocJar(type: Jar, dependsOn: javadoc) { + classifier = 'javadoc' + from javadoc.destinationDir + } + sourceCompatibility = '1.8' targetCompatibility = '1.8' @@ -93,7 +121,7 @@ allprojects { jcenter() mavenCentral() mavenLocal() - maven { url "https://consensys.bintray.com/pegasys-repo" } + maven { url "https://consensys.bintray.com/pegasys-repo" } } } @@ -249,6 +277,54 @@ task deploy() {} subprojects { + if (file('src/main/java').directory) { + apply plugin: 'com.jfrog.bintray' + apply plugin: 'maven-publish' + + publishing { + publications { + mavenJava(MavenPublication) { + groupId "tech.pegasys.pantheon.internal" + version "${project.version}" + from components.java + artifact sourcesJar + artifact javadocJar + versionMapping { + usage('java-api') { fromResolutionOf('runtimeClasspath') } + usage('java-runtime') { fromResolutionResult() } + } + pom { + name = "Pantheon - ${project.name}" + url = 'http://github.com/PegaSysEng/pantheon' + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + scm { + connection = 'scm:git:git://github.com/PegaSysEng/pantheon.git' + developerConnection = 'scm:git:ssh://github.com/PegaSysEng/pantheon.git' + url = 'https://github.com/PegaSysEng/pantheon' + } + } + } + } + } + + bintray { + user = bintrayUser + key = bintrayKey + + publications = ['mavenJava'] + override = version.endsWith('SNAPSHOT') + + publish = true + + pkg = bintrayPackage + } + } + tasks.withType(Test) { // If GRADLE_MAX_TEST_FORKS is not set, use half the available processors maxParallelForks = (System.getenv('GRADLE_MAX_TEST_FORKS') ?: (Runtime.runtime.availableProcessors().intdiv(2) ?: 1)).toInteger() @@ -258,7 +334,6 @@ subprojects { options.fork = true options.incremental = true } - apply plugin: 'maven-publish' sourceSets { // test-support can be consumed as a library by other projects in their tests @@ -286,7 +361,7 @@ subprojects { testSupportArtifacts } - task testSupportJar (type: Jar) { + task testSupportJar(type: Jar) { baseName = "${project.name}-support-test" from sourceSets.testSupport.output } @@ -296,7 +371,7 @@ subprojects { integrationTestImplementation sourceSets.testSupport.output } - task integrationTest(type: Test, dependsOn:["compileTestJava"]){ + task integrationTest(type: Test, dependsOn: ["compileTestJava"]) { group = "verification" description = "Runs the Pantheon integration tests" @@ -343,7 +418,9 @@ applicationDefaultJvmArgs = [ run { args project.hasProperty("pantheon.run.args") ? project.property("pantheon.run.args").toString().split("\\s+") : [] doFirst { - applicationDefaultJvmArgs = applicationDefaultJvmArgs.collect{it.replace('PANTHEON_HOME', "$buildDir/pantheon")} + applicationDefaultJvmArgs = applicationDefaultJvmArgs.collect { + it.replace('PANTHEON_HOME', "$buildDir/pantheon") + } } } @@ -412,7 +489,7 @@ tasks.register("dockerDistUntar") { new File(dockerBuildDir).mkdir() copy { from tarTree(distTarFile) - into (dockerBuildDir) + into(dockerBuildDir) } file("${dockerBuildDir}/${distTarFileName}").renameTo("${dockerBuildDir}/pantheon") } @@ -446,7 +523,7 @@ configurations { annotationProcessor } // Prevent errorprone-checks being dependent upon errorprone-checks! // However, ensure all subprojects comply with the custom rules. -configure(subprojects.findAll {it.name != 'errorprone-checks'}) { +configure(subprojects.findAll { it.name != 'errorprone-checks' }) { dependencies { annotationProcessor project(":errorprone-checks") } tasks.withType(JavaCompile) { @@ -488,7 +565,7 @@ def getCheckedOutGitCommitHash() { def head = new File(gitFolder + "HEAD").text.split(":") // .git/HEAD def isCommit = head.length == 1 // e5a7c79edabbf7dd39888442df081b1c9d8e88fd - if(isCommit) return head[0].trim().take(takeFromHash) // e5a7c79edabb + if (isCommit) return head[0].trim().take(takeFromHash) // e5a7c79edabb def refHead = new File(gitFolder + head[1].trim()) // .git/refs/heads/master refHead.text.trim().take takeFromHash @@ -496,8 +573,8 @@ def getCheckedOutGitCommitHash() { apply plugin: 'net.researchgate.release' -task releaseIntegrationTest(type: Test){ - for(TaskContainer taskList : subprojects.tasks){ +task releaseIntegrationTest(type: Test) { + for (TaskContainer taskList : subprojects.tasks) { def subProjectIntegrationTask = taskList.findByName('integrationTest') if (subProjectIntegrationTask != null) { @@ -506,14 +583,14 @@ task releaseIntegrationTest(type: Test){ } } -task releaseReferenceTest(type: Test, dependsOn : [ +task releaseReferenceTest(type: Test, dependsOn: [ ':ethereum:core:referenceTests', ':ethereum:rlp:referenceTests', ':ethereum:trie:referenceTests' -]){ +]) { } -task releaseAcceptanceTest(type: Test, dependsOn : ':acceptance-tests:acceptanceTest') {} +task releaseAcceptanceTest(type: Test, dependsOn: ':acceptance-tests:acceptanceTest') {} release { preTagCommitMessage = '[Gradle Release Plugin] - pre tag commit: ' @@ -533,11 +610,9 @@ release { } } -apply plugin: 'com.jfrog.bintray' - bintray { - user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') - key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_KEY') + user = bintrayUser + key = bintrayKey filesSpec { from distTar.destinationDir.path @@ -546,21 +621,9 @@ bintray { } publish = true + override = version.endsWith('SNAPSHOT') - pkg { - repo = 'pegasys-repo' - name = 'pantheon' - userOrg = 'consensys' - licenses = ['Apache-2.0'] - websiteUrl = 'https://github.com/PegaSysEng/pantheon' - issueTrackerUrl = 'https://github.com/PegaSysEng/pantheon/issues' - vcsUrl = 'https://github.com/PegaSysEng/pantheon.git' - - version { - name = project.version - released = new Date() - } - } + pkg = bintrayPackage } afterReleaseBuild.dependsOn bintrayUpload