2015-12-22 23:46:23 +03:00
|
|
|
/*
|
2016-02-23 04:14:48 +03:00
|
|
|
* Thrifty
|
2015-12-22 23:46:23 +03:00
|
|
|
*
|
2016-02-23 04:14:48 +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
|
|
|
|
*
|
2016-02-23 04:14:48 +03:00
|
|
|
* 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
|
|
|
*
|
2016-02-23 04:14:48 +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
|
|
|
*/
|
|
|
|
|
2021-08-02 06:22:45 +03:00
|
|
|
plugins {
|
2022-04-12 08:29:58 +03:00
|
|
|
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
|
|
|
|
2021-08-02 06:22:45 +03:00
|
|
|
id 'jacoco'
|
2015-10-28 08:51:35 +03:00
|
|
|
}
|
|
|
|
|
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 {
|
2021-08-02 06:22:45 +03:00
|
|
|
xml.required = true
|
2020-08-23 03:17:09 +03:00
|
|
|
xml.destination layout.buildDirectory.file("reports/jacoco/report.xml").map { it.asFile }
|
2021-08-02 06:22:45 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-05-15 10:41:11 +03:00
|
|
|
wrapper {
|
2022-12-09 00:10:42 +03:00
|
|
|
gradleVersion = "7.6"
|
2021-08-02 06:22:45 +03:00
|
|
|
distributionType = Wrapper.DistributionType.BIN
|
2020-08-16 09:34:10 +03:00
|
|
|
}
|
2020-08-23 00:45:40 +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")
|
|
|
|
}
|
|
|
|
}
|