Automatically publish to bintray after artifactory
MODIFY
dd-trace-java.gradle
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'
}

MODIFY
gradle/publish.gradle
gradle/publish.gradle
@@ -73,6 +73,7 @@ artifactoryPublish { task ->
throw new IllegalStateException("cannot run " + task + " with --parallel and --max-workers > 1")
}
}
+}
artifactory {
publish {
@@ -83,17 +84,27 @@ artifactoryPublish { task ->
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')
}
}
}
+
+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")
+ }
+ }
}
bintray {
@@ -156,3 +167,7 @@ bintray {
// }
}
}
+
+if(!isSnapshot) {
+ artifactoryPublish.finalizedBy bintrayUpload
+}

Automatically publish to bintray after artifactory