-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
junit-vintage-engine.gradle.kts
81 lines (73 loc) · 2.28 KB
/
junit-vintage-engine.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
import aQute.bnd.gradle.BundleTaskConvention
plugins {
`java-library-conventions`
`junit4-compatibility`
`testing-conventions`
`java-test-fixtures`
groovy
}
description = "JUnit Vintage Engine"
dependencies {
api(platform(projects.junitBom))
api(projects.junitPlatformEngine)
api(libs.junit4)
compileOnlyApi(libs.apiguardian)
testFixturesApi(platform(libs.groovy2.bom))
testFixturesApi(libs.spock1)
testFixturesImplementation(projects.junitPlatformRunner)
testImplementation(projects.junitPlatformLauncher)
testImplementation(projects.junitPlatformSuiteEngine)
testImplementation(projects.junitPlatformTestkit)
}
tasks {
compileTestFixturesGroovy {
javaLauncher.set(project.the<JavaToolchainService>().launcherFor {
// Groovy 2.x (used for Spock tests) does not support JDK 16
languageVersion.set(JavaLanguageVersion.of(11))
})
}
jar {
withConvention(BundleTaskConvention::class) {
val junit4Min = libs.versions.junit4Min.get()
bnd("""
# Import JUnit4 packages with a version
Import-Package: \
${extra["importAPIGuardian"]},\
junit.runner;version="[${junit4Min},5)",\
org.junit;version="[${junit4Min},5)",\
org.junit.experimental.categories;version="[${junit4Min},5)",\
org.junit.internal.builders;version="[${junit4Min},5)",\
org.junit.platform.commons.logging;status=INTERNAL,\
org.junit.runner.*;version="[${junit4Min},5)",\
org.junit.runners.model;version="[${junit4Min},5)",\
*
Provide-Capability:\
org.junit.platform.engine;\
org.junit.platform.engine='junit-vintage';\
version:Version="${'$'}{version_cleanup;${project.version}}"
""")
}
}
val testWithoutJUnit4 by registering(Test::class) {
(options as JUnitPlatformOptions).apply {
includeTags("missing-junit4")
}
setIncludes(listOf("**/JUnit4VersionCheckTests.class"))
classpath = classpath.filter {
!it.name.startsWith("junit-4")
}
}
withType<Test>().matching { it.name != testWithoutJUnit4.name }.configureEach {
(options as JUnitPlatformOptions).apply {
excludeTags("missing-junit4")
}
}
withType<Test>().configureEach {
// Workaround for Groovy 2.5
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
jvmArgs("--add-opens", "java.base/java.util=ALL-UNNAMED")
}
check {
dependsOn(testWithoutJUnit4)
}
}