-
-
Notifications
You must be signed in to change notification settings - Fork 757
/
build.gradle.kts
153 lines (130 loc) · 4.79 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import org.gradle.api.internal.classpath.ModuleRegistry
import org.gradle.kotlin.dsl.support.serviceOf
plugins {
id("module")
`java-gradle-plugin`
`java-test-fixtures`
idea
alias(libs.plugins.pluginPublishing)
}
detekt {
source.from("src/functionalTest/kotlin")
}
repositories {
mavenCentral()
google()
}
testing {
suites {
getByName("test", JvmTestSuite::class) {
dependencies {
implementation(libs.assertj)
implementation(libs.kotlin.gradle)
implementation(gradleKotlinDsl())
// Workaround for gradle/gradle#16774, see
// https://github.com/gradle/gradle/issues/16774#issuecomment-853407822
// This should be reviewed and dropped if fixed as planned in Gradle 7.5
runtimeOnly(
files(
serviceOf<ModuleRegistry>()
.getModule("gradle-tooling-api-builders")
.classpath
.asFiles
.first()
)
)
}
targets {
all {
testTask.configure {
inputs.property("androidSdkRoot", System.getenv("ANDROID_SDK_ROOT")).optional(true)
inputs.property("androidHome", System.getenv("ANDROID_HOME")).optional(true)
}
}
}
}
register("functionalTest", JvmTestSuite::class) {
useJUnitJupiter(libs.versions.junit.get())
dependencies {
implementation(libs.assertj)
}
}
}
}
val pluginCompileOnly: Configuration by configurations.creating
val functionalTestImplementation: Configuration by configurations.getting
configurations.compileOnly { extendsFrom(pluginCompileOnly) }
dependencies {
compileOnly(libs.kotlin.gradlePluginApi)
implementation(libs.sarif4k)
// Migrate to `implementation(testFixtures(project))` in test suite configuration when Gradle 7.5 released
// (https://github.com/gradle/gradle/pull/19472)
functionalTestImplementation(testFixtures(project))
pluginCompileOnly(libs.android.gradle)
pluginCompileOnly(libs.kotlin.gradle)
}
gradlePlugin {
// hack to prevent building two jar's overwriting each other and leading to invalid signatures
// when publishing the Gradle plugin, this property must be present
isAutomatedPublishing = System.getProperty("automatePublishing")?.toBoolean() ?: false
plugins {
register("detektPlugin") {
id = "io.gitlab.arturbosch.detekt"
implementationClass = "io.gitlab.arturbosch.detekt.DetektPlugin"
}
}
// Source sets that require the Gradle TestKit dependency
testSourceSets(
sourceSets["testFixtures"],
sourceSets["functionalTest"],
)
}
// Some functional tests reference internal functions in the Gradle plugin. This should become unnecessary as further
// updates are made to the functional test suite.
kotlin.target.compilations.getByName("functionalTest") {
associateWith(target.compilations.getByName("main"))
}
// Manually inject dependency to gradle-testkit since the default injected plugin classpath is from `main.runtime`.
tasks.pluginUnderTestMetadata {
pluginClasspath.from(pluginCompileOnly)
}
tasks.validatePlugins {
enableStricterValidation.set(true)
}
pluginBundle {
website = "https://detekt.dev"
vcsUrl = "https://github.com/detekt/detekt"
description = "Static code analysis for Kotlin"
tags = listOf("kotlin", "detekt", "code-analysis", "linter", "codesmells", "android")
(plugins) {
"detektPlugin" {
id = "io.gitlab.arturbosch.detekt"
displayName = "Static code analysis for Kotlin"
}
}
}
tasks {
val writeDetektVersionProperties by registering(WriteProperties::class) {
description = "Write the properties file with the Detekt version to be used by the plugin"
encoding = "UTF-8"
outputFile = file("$buildDir/versions.properties")
property("detektVersion", project.version)
}
processResources {
from(writeDetektVersionProperties)
}
processTestResources {
from(writeDetektVersionProperties)
}
check {
dependsOn(testing.suites.named("functionalTest"))
}
ideaModule {
notCompatibleWithConfigurationCache("https://github.com/gradle/gradle/issues/13480")
}
}
// Skip publishing of test fixture API & runtime variants
with(components["java"] as AdhocComponentWithVariants) {
withVariantsFromConfiguration(configurations["testFixturesApiElements"]) { skip() }
withVariantsFromConfiguration(configurations["testFixturesRuntimeElements"]) { skip() }
}