181 lines
6.4 KiB
Groovy
181 lines
6.4 KiB
Groovy
/*
|
|
* Copyright 2015 the original author or authors.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
// Source: https://github.com/ratpack/ratpack/blob/master/gradle/publish.gradle
|
|
|
|
apply plugin: "maven"
|
|
apply plugin: "com.jfrog.artifactory"
|
|
apply plugin: 'com.jfrog.bintray'
|
|
apply plugin: "signing"
|
|
|
|
afterEvaluate {
|
|
assert description: "Project $project.path is published, must have a description"
|
|
}
|
|
|
|
tasks.withType(Upload).matching { it.name != "install" }.all {
|
|
rootProject.subprojects {
|
|
mustRunAfter tasks.matching { it instanceof VerificationTask }
|
|
}
|
|
}
|
|
|
|
def isRoot = project.rootProject == project
|
|
if (!isRoot) {
|
|
apply from: "$rootDir/gradle/version.gradle"
|
|
apply from: "${rootDir}/gradle/pom.gradle"
|
|
|
|
def isCI = Boolean.parseBoolean("$System.env.CI")
|
|
|
|
signing {
|
|
required = isCI
|
|
sign configurations.archives
|
|
}
|
|
|
|
configurations {
|
|
configurations {
|
|
all {
|
|
incoming.afterResolve {
|
|
dependencies.withType(ModuleDependency) { dep ->
|
|
excludeRules.each {
|
|
if ([it.group, it.module].any { it == null }) {
|
|
throw new InvalidUserDataException(
|
|
"Partial exclude for dependency '$dep.group:$dep.name:$dep.version' of $project: [group: $it.group, module: $it.module]\n\nExcludes must specify both group and module and neither can be '*'."
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
def isSnapshot = version.endsWith("-SNAPSHOT")
|
|
// define in ~/.gradle/gradle.properties to override for testing
|
|
def forceLocal = project.hasProperty('forceLocal') && forceLocal
|
|
|
|
artifactoryPublish { 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")
|
|
}
|
|
}
|
|
}
|
|
|
|
artifactory {
|
|
gradle.taskGraph.whenReady { taskGraph ->
|
|
if (taskGraph.hasTask(artifactoryPublish)) {
|
|
assert !project.hasProperty("removeJarVersionNumbers") || !removeJarVersionNumbers
|
|
// trigger error if missing
|
|
bintrayUser
|
|
bintrayApiKey
|
|
}
|
|
}
|
|
|
|
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'
|
|
|
|
if (project.hasProperty("bintrayUser") && project.hasProperty("bintrayApiKey")) {
|
|
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 {
|
|
gradle.taskGraph.whenReady { taskGraph ->
|
|
if (taskGraph.hasTask(bintrayUpload)) {
|
|
assert !project.hasProperty("removeJarVersionNumbers") || !removeJarVersionNumbers
|
|
// trigger error if missing
|
|
bintrayUser
|
|
bintrayApiKey
|
|
}
|
|
}
|
|
|
|
if (project.hasProperty("bintrayUser") && project.hasProperty("bintrayApiKey")) {
|
|
user = bintrayUser
|
|
key = bintrayApiKey
|
|
}
|
|
|
|
if (!isRoot) {
|
|
configurations = ['archives']
|
|
}
|
|
|
|
// dryRun = true //[Default: false] Whether to run this as dry-run, without deploying
|
|
publish = true //[Default: false] Whether version should be auto published after an upload
|
|
// override = true //[Default: false] Whether to override version artifacts already published
|
|
|
|
//Package configuration. The plugin will use the repo and name properties to check if the package already exists. In that case, there's no need to configure the other package properties (like userOrg, desc, etc).
|
|
pkg {
|
|
repo = 'datadog-maven'
|
|
name = 'dd-trace-java'
|
|
userOrg = 'datadog' //An optional organization name when the repo belongs to one of the user's orgs
|
|
desc = 'Client libraries for Datadog APM'
|
|
websiteUrl = 'https://github.com/datadog/dd-trace-java'
|
|
issueTrackerUrl = 'https://github.com/datadog/dd-trace-java/issues'
|
|
vcsUrl = 'https://github.com/datadog/dd-trace-java.git'
|
|
licenses = ['Apache-2.0']
|
|
|
|
githubRepo = 'datadog/dd-trace-java' //Optional Github repository
|
|
githubReleaseNotesFile = 'README.md' //Optional Github readme file
|
|
|
|
// //Optional version descriptor
|
|
// version {
|
|
// name = '1.3-Final' //Bintray logical version name
|
|
// desc = //Optional - Version-specific description'
|
|
// released = //Optional - Date of the version release. 2 possible values: date in the format of 'yyyy-MM-dd'T'HH:mm:ss.SSSZZ' OR a java.util.Date instance
|
|
// vcsTag = '1.3.0'
|
|
// attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
|
|
// //Optional version-level attributes
|
|
// //Optional configuration for GPG signing
|
|
// gpg {
|
|
// sign = true //Determines whether to GPG sign the files. The default is false
|
|
// passphrase = 'passphrase' //Optional. The passphrase for GPG signing'
|
|
// }
|
|
// //Optional configuration for Maven Central sync of the version
|
|
// mavenCentralSync {
|
|
// sync = true //[Default: true] Determines whether to sync the version to Maven Central.
|
|
// user = 'userToken' //OSS user token: mandatory
|
|
// password = 'paasword' //OSS user password: mandatory
|
|
// close = '1'
|
|
// //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
|
|
// }
|
|
// }
|
|
}
|
|
}
|
|
|
|
if(!isSnapshot) {
|
|
artifactoryPublish.finalizedBy bintrayUpload
|
|
}
|