thrifty/build.gradle

94 строки
3.4 KiB
Groovy
Исходник Обычный вид История

2015-12-22 23:46:23 +03:00
/*
* Thrifty
2015-12-22 23:46:23 +03:00
*
* Copyright (c) Microsoft Corporation
*
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the License);
2015-12-22 23:46:23 +03:00
* 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.
2015-12-22 23:46:23 +03:00
*
* See the Apache Version 2.0 License for specific language governing permissions and limitations under the License.
2015-12-22 23:46:23 +03:00
*/
plugins {
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.kotlin.jvm) apply false
2018-07-30 06:42:37 +03:00
id 'jacoco'
}
2020-08-23 03:17:09 +03:00
tasks.register("codeCoverageReport", JacocoReport) { t ->
t.dependsOn subprojects*.test
t.executionData fileTree(project.rootDir.absolutePath).include('**/build/jacoco/*.exec')
2017-03-10 01:21:28 +03:00
subprojects.each {
2020-08-23 03:17:09 +03:00
t.sourceSets it.sourceSets.main
2017-03-10 01:21:28 +03:00
}
2020-08-23 03:17:09 +03:00
t.reports {
xml.required = true
2020-08-23 03:17:09 +03:00
xml.destination layout.buildDirectory.file("reports/jacoco/report.xml").map { it.asFile }
html.required = true
csv.required = false
2017-03-10 01:21:28 +03:00
}
2020-08-23 03:17:09 +03:00
def filters = [ "**/AutoValue_*", "**/antlr/*", "com/microsoft/thrifty/test/gen/*"]
t.classDirectories.setFrom(files(t.classDirectories.files.collect {
fileTree(dir: it, exclude: filters)
}))
2017-03-10 01:21:28 +03:00
}
wrapper {
gradleVersion = "7.6"
distributionType = Wrapper.DistributionType.BIN
2020-08-16 09:34:10 +03:00
}
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")
}
}