forked from smithy-lang/smithy-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
93 lines (82 loc) · 2.68 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
buildscript {
repositories {
mavenCentral()
google()
}
val kotlinVersion: String by project
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}
plugins {
kotlin("jvm") version "1.3.72" apply false
id("org.jetbrains.dokka") version "0.10.0"
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
google()
}
}
apply(from = rootProject.file("gradle/maincodecoverage.gradle"))
val ktlint by configurations.creating {
// https://github.com/pinterest/ktlint/issues/1114#issuecomment-805793163
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
}
val ktlintVersion: String by project
dependencies {
ktlint("com.pinterest:ktlint:$ktlintVersion")
}
val lintPaths = listOf(
"codegen/src/**/*.kt"
)
tasks.register<JavaExec>("ktlint") {
description = "Check Kotlin code style."
group = "Verification"
classpath = configurations.getByName("ktlint")
main = "com.pinterest.ktlint.Main"
args = lintPaths
}
tasks.register<JavaExec>("ktlintFormat") {
description = "Auto fix Kotlin code style violations"
group = "formatting"
classpath = configurations.getByName("ktlint")
main = "com.pinterest.ktlint.Main"
args = listOf("-F") + lintPaths
}
@Suppress("UnstableApiUsage")
task<JacocoMerge>("jacocoMerge") {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Merge the JaCoCo data files from all subprojects into one"
afterEvaluate {
// An empty FileCollection
val execFiles = objects.fileCollection()
val projectList = subprojects + project
projectList.forEach { subProject: Project ->
if (subProject.pluginManager.hasPlugin("jacoco")) {
val testTasks = subProject.tasks.withType<Test>()
// ensure that .exec files are actually present
dependsOn(testTasks)
testTasks.forEach { task: Test ->
// The JacocoTaskExtension is the source of truth for the location of the .exec file.
val extension = task.extensions.findByType(JacocoTaskExtension::class.java)
extension?.let {
execFiles.from(it.destinationFile)
}
}
}
}
executionData = execFiles
}
doFirst {
// .exec files might be missing if a project has no tests. Filter in execution phase.
executionData = executionData.filter { it.canRead() }
}
}