94 строки
3.4 KiB
Groovy
94 строки
3.4 KiB
Groovy
/*
|
|
* Thrifty
|
|
*
|
|
* Copyright (c) Microsoft Corporation
|
|
*
|
|
* All rights reserved.
|
|
*
|
|
* 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
|
|
*
|
|
* THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR
|
|
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
|
|
* WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE,
|
|
* FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
*
|
|
* See the Apache Version 2.0 License for specific language governing permissions and limitations under the License.
|
|
*/
|
|
|
|
plugins {
|
|
alias(libs.plugins.mavenPublish) apply false
|
|
alias(libs.plugins.dokka) apply false
|
|
alias(libs.plugins.kotlin.jvm) apply false
|
|
|
|
id 'jacoco'
|
|
}
|
|
|
|
tasks.register("codeCoverageReport", JacocoReport) { t ->
|
|
t.dependsOn subprojects*.test
|
|
|
|
t.executionData fileTree(project.rootDir.absolutePath).include('**/build/jacoco/*.exec')
|
|
|
|
subprojects.each {
|
|
t.sourceSets it.sourceSets.main
|
|
}
|
|
|
|
t.reports {
|
|
xml.required = true
|
|
xml.destination layout.buildDirectory.file("reports/jacoco/report.xml").map { it.asFile }
|
|
html.required = true
|
|
csv.required = false
|
|
}
|
|
|
|
def filters = [ "**/AutoValue_*", "**/antlr/*", "com/microsoft/thrifty/test/gen/*"]
|
|
t.classDirectories.setFrom(files(t.classDirectories.files.collect {
|
|
fileTree(dir: it, exclude: filters)
|
|
}))
|
|
}
|
|
|
|
wrapper {
|
|
gradleVersion = "7.6"
|
|
distributionType = Wrapper.DistributionType.BIN
|
|
}
|
|
|
|
def ci = providers.environmentVariable("CI").forUseAtConfigurationTime()
|
|
def travisRepoSlug = providers.environmentVariable("TRAVIS_REPO_SLUG").forUseAtConfigurationTime()
|
|
def travisBranch = providers.environmentVariable("TRAVIS_BRANCH").forUseAtConfigurationTime()
|
|
def travisPullRequest = providers.environmentVariable("TRAVIS_PULL_REQUEST").forUseAtConfigurationTime()
|
|
def versionName = providers.gradleProperty("VERSION_NAME").forUseAtConfigurationTime()
|
|
def currentJavaVersion = providers.systemProperty("java.version").forUseAtConfigurationTime()
|
|
|
|
tasks.register("uploadSnapshot") {
|
|
def isCi = ci.getOrElse("") == "true"
|
|
def isMainRepo = travisRepoSlug.getOrElse("").matches("[Mm]icrosoft/thrifty")
|
|
def isMainBranch = travisBranch.getOrElse("") == "master"
|
|
def isNotPR = travisPullRequest.getOrElse("") == "false"
|
|
def isSnapshot = versionName.get().endsWith("-SNAPSHOT")
|
|
def isJava8 = currentJavaVersion.map { JavaVersion.toVersion(it) }.get().isJava8()
|
|
|
|
// We only want to upload snapshots if we're a CI build,
|
|
// for the main repo, on the main branch (and not due to a
|
|
// new/updated PR), and our current version is a snapshot version,
|
|
// _and_ we're being built using JDK 8.
|
|
|
|
if (!isCi) {
|
|
doFirst { logger.lifecycle("Not a CI build") }
|
|
} else if (!isMainRepo) {
|
|
doFirst { logger.lifecycle("Wrong repo") }
|
|
} else if (!isMainBranch) {
|
|
doFirst { logger.lifecycle("Wrong branch") }
|
|
} else if (!isNotPR) {
|
|
doFirst { logger.lifecycle("Pull request") }
|
|
} else if (!isSnapshot) {
|
|
doFirst { logger.lifecycle("Not a snapshot") }
|
|
} else if (!isJava8) {
|
|
doFirst { logger.lifecycle("Wrong JDK version") }
|
|
} else {
|
|
// whew
|
|
dependsOn subprojects*.tasks*.named("uploadArchives")
|
|
}
|
|
}
|