opentelemetry-java-instrume.../gradle/publish.gradle

96 lines
3.0 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: "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 }
}
}
if (project.rootProject != project) {
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 {
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 ->
if (taskGraph.hasTask(task)) {
username = bintrayUser
password = bintrayApiKey
}
}
}
defaults {
publishConfigs('archives')
}
}
}
}