Skip to content

Commit 410adb7

Browse files
authored
Merge pull request #125 from DataDog/tyler/auto-publish
Automatically publish to bintray after artifactory
2 parents a790e7b + 4343699 commit 410adb7

File tree

2 files changed

+27
-34
lines changed

2 files changed

+27
-34
lines changed

dd-trace-java.gradle

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,6 @@ description = 'dd-trace-java'
2727
// Applied here to allow publishing of artifactory build info
2828
apply from: "${rootDir}/gradle/publish.gradle"
2929

30-
// Source: https://github.com/ratpack/ratpack/blob/master/ratpack.gradle#L101
31-
task bintrayPublish() {
32-
doLast {
33-
if (!project.hasProperty("bintrayApiKey") || bintrayApiKey.length() < 20) {
34-
throw new InvalidUserDataException("You must provide a valid bintrayApiKey")
35-
}
36-
37-
if (!project.hasProperty('buildNumber') || !"$buildNumber".isInteger()) {
38-
throw new TaskExecutionException("Must provide buildNumber of a release from https://oss.jfrog.org/artifactory/webapp/#/builds/dd-trace-java")
39-
}
40-
41-
def curl = [
42-
'curl',
43-
'-X', 'POST',
44-
'-u', "${bintrayUser}:${bintrayApiKey}",
45-
'-d', '',
46-
"http://oss.jfrog.org/api/plugins/build/promote/snapshotsToBintray/dd-trace-java/$project.buildNumber"
47-
].execute()
48-
logger.info("Received response: ${curl.text}")
49-
}
50-
}
51-
5230
task wrapper(type: Wrapper) {
5331
gradleVersion = '4.0'
5432
}

gradle/publish.gradle

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,36 @@ artifactoryPublish { task ->
7373
throw new IllegalStateException("cannot run " + task + " with --parallel and --max-workers > 1")
7474
}
7575
}
76+
}
7677

77-
artifactory {
78-
publish {
79-
contextUrl = forceLocal ? 'http://localhost:8080/artifactory' : 'https://oss.jfrog.org'
80-
repository {
81-
if (forceLocal)
82-
repoKey = isSnapshot ? 'libs-snapshot-local' : 'libs-release-local'
83-
else
84-
repoKey = isSnapshot ? 'oss-snapshot-local' : 'oss-release-local'
85-
gradle.taskGraph.whenReady { taskGraph ->
78+
artifactory {
79+
publish {
80+
contextUrl = forceLocal ? 'http://localhost:8080/artifactory' : 'https://oss.jfrog.org'
81+
repository {
82+
if (forceLocal)
83+
repoKey = isSnapshot ? 'libs-snapshot-local' : 'libs-release-local'
84+
else
85+
repoKey = isSnapshot ? 'oss-snapshot-local' : 'oss-release-local'
86+
gradle.taskGraph.whenReady { taskGraph ->
87+
artifactoryPublish { task ->
8688
if (taskGraph.hasTask(task)) {
8789
username = bintrayUser
8890
password = bintrayApiKey
8991
}
9092
}
9193
}
92-
defaults {
93-
if (!isRoot) publishConfigs('archives')
94-
}
94+
}
95+
defaults {
96+
if (!isRoot) publishConfigs('archives')
97+
}
98+
}
99+
}
100+
101+
bintrayUpload { task ->
102+
gradle.taskGraph.whenReady { taskGraph ->
103+
def startParameter = project.gradle.startParameter
104+
if (taskGraph.hasTask(task) && startParameter.parallelProjectExecutionEnabled && startParameter.maxWorkerCount > 1) {
105+
throw new IllegalStateException("cannot run " + task + " with --parallel and --max-workers > 1")
95106
}
96107
}
97108
}
@@ -156,3 +167,7 @@ bintray {
156167
// }
157168
}
158169
}
170+
171+
if(!isSnapshot) {
172+
artifactoryPublish.finalizedBy bintrayUpload
173+
}

0 commit comments

Comments
 (0)