From 43436999c46f04e3931e83d2dee04fa794ad3ba9 Mon Sep 17 00:00:00 2001 From: Tyler Benson Date: Thu, 7 Sep 2017 10:22:36 -0700 Subject: [PATCH] Automatically publish to bintray after artifactory --- dd-trace-java.gradle | 22 ---------------------- gradle/publish.gradle | 39 +++++++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/dd-trace-java.gradle b/dd-trace-java.gradle index e36bb49f9f..52e927b558 100644 --- a/dd-trace-java.gradle +++ b/dd-trace-java.gradle @@ -27,28 +27,6 @@ description = 'dd-trace-java' // Applied here to allow publishing of artifactory build info apply from: "${rootDir}/gradle/publish.gradle" -// Source: https://github.com/ratpack/ratpack/blob/master/ratpack.gradle#L101 -task bintrayPublish() { - doLast { - if (!project.hasProperty("bintrayApiKey") || bintrayApiKey.length() < 20) { - throw new InvalidUserDataException("You must provide a valid bintrayApiKey") - } - - if (!project.hasProperty('buildNumber') || !"$buildNumber".isInteger()) { - throw new TaskExecutionException("Must provide buildNumber of a release from https://oss.jfrog.org/artifactory/webapp/#/builds/dd-trace-java") - } - - def curl = [ - 'curl', - '-X', 'POST', - '-u', "${bintrayUser}:${bintrayApiKey}", - '-d', '', - "http://oss.jfrog.org/api/plugins/build/promote/snapshotsToBintray/dd-trace-java/$project.buildNumber" - ].execute() - logger.info("Received response: ${curl.text}") - } -} - task wrapper(type: Wrapper) { gradleVersion = '4.0' } diff --git a/gradle/publish.gradle b/gradle/publish.gradle index 4aa52d1f47..690dced6dc 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -73,25 +73,36 @@ artifactoryPublish { task -> throw new IllegalStateException("cannot run " + task + " with --parallel and --max-workers > 1") } } +} - artifactory { - publish { - contextUrl = forceLocal ? 'http://localhost:8080/artifactory' : 'https://oss.jfrog.org' - repository { - if (forceLocal) - repoKey = isSnapshot ? 'libs-snapshot-local' : 'libs-release-local' - else - repoKey = isSnapshot ? 'oss-snapshot-local' : 'oss-release-local' - gradle.taskGraph.whenReady { taskGraph -> +artifactory { + publish { + contextUrl = forceLocal ? 'http://localhost:8080/artifactory' : 'https://oss.jfrog.org' + repository { + if (forceLocal) + repoKey = isSnapshot ? 'libs-snapshot-local' : 'libs-release-local' + else + repoKey = isSnapshot ? 'oss-snapshot-local' : 'oss-release-local' + gradle.taskGraph.whenReady { taskGraph -> + artifactoryPublish { task -> if (taskGraph.hasTask(task)) { username = bintrayUser password = bintrayApiKey } } } - defaults { - if (!isRoot) publishConfigs('archives') - } + } + defaults { + if (!isRoot) publishConfigs('archives') + } + } +} + +bintrayUpload { task -> + gradle.taskGraph.whenReady { taskGraph -> + def startParameter = project.gradle.startParameter + if (taskGraph.hasTask(task) && startParameter.parallelProjectExecutionEnabled && startParameter.maxWorkerCount > 1) { + throw new IllegalStateException("cannot run " + task + " with --parallel and --max-workers > 1") } } } @@ -156,3 +167,7 @@ bintray { // } } } + +if(!isSnapshot) { + artifactoryPublish.finalizedBy bintrayUpload +}