-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.gradle.kts
136 lines (118 loc) · 4.18 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
import java.lang.Thread.sleep
import java.time.Duration
plugins {
`kotlin-dsl`
`kotlin-convention`
`publishing-convention`
`coverage-convention`
`shadow-convention`
`test-fixtures-convention`
`linter-convention`
}
group = "dev.monosoul.jooq"
tasks {
shadowJar {
archiveClassifier.set("")
// workaround to separate shadowed testcontainers configuration
relocate("docker.client.strategy", "${project.group}.docker.client.strategy")
relocate(
"TESTCONTAINERS_DOCKER_CLIENT_STRATEGY",
"${project.group.toString().uppercase().replace(".", "_")}_TESTCONTAINERS_DOCKER_CLIENT_STRATEGY",
)
}
assemble {
dependsOn(shadowJar)
}
pluginUnderTestMetadata {
pluginClasspath.from(configurations.shadow) // provides complete plugin classpath to the Gradle testkit
}
processTemplates {
filter {
it.replace("@jooq.version@", libs.versions.jooq.get())
.replace("@flyway.version@", libs.versions.flyway.get())
}
}
}
dependencies {
/**
* This is counter-intuitive, but dependencies in implementation or api configuration will actually
* be shadowed, while dependencies in shadow configuration will be skipped from shadowing and just added as
* transitive. This is a quirk of the shadow plugin.
*/
shadow(libs.jooq.codegen)
shadow(libs.bundles.flyway)
implementation(libs.testcontainers.jdbc) {
exclude(group = libs.jna.get().group) // cannot be shadowed
exclude(group = "org.slf4j") // provided by Gradle
}
shadow(libs.jna)
testFixturesApi(libs.testcontainers.postgresql)
testFixturesApi(enforcedPlatform(libs.junit.bom))
testFixturesApi(libs.junit.jupiter)
testFixturesApi(libs.strikt)
testFixturesApi(libs.mockk)
testFixturesApi(gradleTestKit())
}
val functionalTestSuiteName = "functionalTest"
val extraTestSuiteName = "extraTest"
@Suppress("UnstableApiUsage")
testing {
suites {
register<JvmTestSuite>(functionalTestSuiteName) {
useJUnitJupiter()
dependencies {
implementation(project())
implementation(testFixtures(project()))
runtimeOnly(files(tasks.pluginUnderTestMetadata))
}
targets {
all {
testTask.configure {
dependsOn(tasks.pluginUnderTestMetadata)
shouldRunAfter(tasks.test)
extensions.configure<JacocoTaskExtension> {
isEnabled = false
}
// workaround for https://github.com/gradle/gradle/issues/16603
doLast {
sleep(
Duration.ofSeconds(2).toMillis(),
)
}
}
}
}
}
register<JvmTestSuite>(extraTestSuiteName) {
/**
* This test suite is required because Gradle doesn't support Java agents
* when using TestKit with configuration cache enabled
*
* https://docs.gradle.org/7.5.1/userguide/configuration_cache.html#config_cache:not_yet_implemented:testkit_build_with_java_agent
*/
useJUnitJupiter()
dependencies {
implementation(project())
implementation(testFixtures(project()))
runtimeOnly(files(tasks.pluginUnderTestMetadata))
}
targets {
all {
testTask.configure {
dependsOn(tasks.pluginUnderTestMetadata)
shouldRunAfter(tasks.test)
extensions.configure<JacocoTaskExtension> {
isEnabled = false
}
}
}
}
}
}
}
jacocoTestKit {
applyTo("${functionalTestSuiteName}RuntimeOnly", tasks.named(functionalTestSuiteName))
}
tasks.check {
dependsOn(tasks.named(functionalTestSuiteName), tasks.named(extraTestSuiteName))
}