-
Notifications
You must be signed in to change notification settings - Fork 403
/
build.gradle.kts
171 lines (147 loc) · 4.87 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
plugins {
alias(libs.plugins.kotlin)
alias(libs.plugins.android.lint)
alias(libs.plugins.jetbrains.bcv)
alias(libs.plugins.spotless)
groovy // Required for Spock tests.
id("shadow.convention.publish")
id("shadow.convention.deploy")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlin {
explicitApi()
compilerOptions {
// https://docs.gradle.org/current/userguide/compatibility.html#kotlin
apiVersion = KotlinVersion.KOTLIN_1_8
jvmTarget = JvmTarget.JVM_1_8
freeCompilerArgs.addAll(
"-Xjvm-default=all",
)
}
}
lint {
baseline = file("lint-baseline.xml")
}
spotless {
kotlin {
ktlint(libs.ktlint.get().version)
}
kotlinGradle {
ktlint(libs.ktlint.get().version)
target("**/*.kts")
targetExclude("build-logic/build/**")
}
}
val intiTest: SourceSet by sourceSets.creating
val intiTestImplementation: Configuration by configurations.getting {
extendsFrom(configurations.testImplementation.get())
}
val intiTestRuntimeOnly: Configuration by configurations.getting {
extendsFrom(configurations.testRuntimeOnly.get())
}
val funcTest: SourceSet by sourceSets.creating
val funcTestImplementation: Configuration by configurations.getting {
extendsFrom(configurations.testImplementation.get())
// TODO: this will be removed after we migrated all functional tests to Kotlin.
extendsFrom(intiTestImplementation)
}
val funcTestRuntimeOnly: Configuration by configurations.getting {
extendsFrom(configurations.testRuntimeOnly.get())
}
gradlePlugin {
testSourceSets.add(intiTest)
testSourceSets.add(funcTest)
}
dependencies {
implementation(libs.apache.ant)
implementation(libs.apache.commonsIo)
implementation(libs.apache.log4j)
implementation(libs.asm)
implementation(libs.jdependency)
implementation(libs.jdom2)
implementation(libs.plexus.utils)
implementation(libs.plexus.xml)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
testImplementation(libs.assertk)
testImplementation(libs.xmlunit)
testImplementation(libs.apache.commonsLang)
testRuntimeOnly(libs.junit.platformLauncher)
funcTestImplementation(libs.spock) {
exclude(group = "org.codehaus.groovy")
exclude(group = "org.hamcrest")
}
funcTestImplementation(sourceSets.main.get().output)
funcTestImplementation(intiTest.output)
intiTestImplementation(libs.okio)
intiTestImplementation(libs.apache.maven.modelBuilder)
intiTestImplementation(libs.apache.maven.repositoryMetadata)
// TODO: this will be removed after we migrated all functional tests to Kotlin.
intiTestImplementation(sourceSets.main.get().output)
lintChecks(libs.androidx.gradlePluginLints)
lintChecks(libs.assertk.lint)
}
val integrationTest by tasks.registering(Test::class) {
description = "Runs the integration tests."
group = LifecycleBasePlugin.VERIFICATION_GROUP
testClassesDirs = intiTest.output.classesDirs
classpath = intiTest.runtimeClasspath
val docsDir = file("src/docs")
// Add src/docs as an input directory to trigger ManualCodeSnippetTests re-run on changes.
inputs.dir(docsDir)
systemProperty("DOCS_DIR", docsDir.absolutePath)
}
val functionalTest by tasks.registering(Test::class) {
description = "Runs the functional tests."
group = LifecycleBasePlugin.VERIFICATION_GROUP
testClassesDirs = funcTest.output.classesDirs
classpath = funcTest.runtimeClasspath
}
tasks.check {
dependsOn(integrationTest, functionalTest)
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
maxParallelForks = Runtime.getRuntime().availableProcessors()
// Required to test configuration cache in tests when using withDebug()
// https://github.com/gradle/gradle/issues/22765#issuecomment-1339427241
jvmArgs(
"--add-opens",
"java.base/java.util=ALL-UNNAMED",
"--add-opens",
"java.base/java.util.concurrent.atomic=ALL-UNNAMED",
"--add-opens",
"java.base/java.lang.invoke=ALL-UNNAMED",
"--add-opens",
"java.base/java.net=ALL-UNNAMED",
)
}
tasks.whenTaskAdded {
if (name == "lintAnalyzeJvmTest") {
// This task often fails on Windows CI devices.
enabled = !providers.systemProperty("os.name").get().startsWith("Windows") &&
!providers.environmentVariable("CI").isPresent
}
}
tasks.clean {
val includedBuilds = gradle.includedBuilds
dependsOn(includedBuilds.map { it.task(path) })
val dirs = includedBuilds.map { it.projectDir } + projectDir
delete.addAll(dirs.map { it.resolve(".gradle") })
delete.addAll(dirs.map { it.resolve(".kotlin") })
delete.add("node_modules")
}
tasks.register("releaseAll") {
description = "Publishes the plugin to maven repos and deploys website."
group = PublishingPlugin.PUBLISH_TASK_GROUP
dependsOn(
tasks.publish,
tasks.publishPlugins,
tasks.gitPublishPush,
)
}