-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathjunit-vintage-engine.gradle.kts
More file actions
113 lines (102 loc) · 3.69 KB
/
Copy pathjunit-vintage-engine.gradle.kts
File metadata and controls
113 lines (102 loc) · 3.69 KB
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
plugins {
id("junitbuild.java-library-conventions")
id("junitbuild.junit4-compatibility")
id("junitbuild.testing-conventions")
`java-test-fixtures`
groovy
}
description = "JUnit Vintage Engine"
dependencies {
annotationProcessor(projects.junitPlatformConfigurationProcessor)
api(platform(projects.junitBom))
api(projects.junitPlatformEngine)
api(libs.junit4)
compileOnlyApi(libs.apiguardian)
compileOnlyApi(libs.jspecify)
compileOnly(projects.junitPlatformConfigurationApi)
testFixturesApi(platform(libs.groovy2.bom))
testFixturesApi(libs.spock1)
testFixturesImplementation(projects.junitPlatformSuiteApi)
testImplementation(projects.junitPlatformLauncher)
testImplementation(projects.junitPlatformSuiteEngine)
testImplementation(projects.junitPlatformTestkit)
testImplementation(testFixtures(projects.junitPlatformCommons))
testImplementation(testFixtures(projects.junitJupiterApi))
testImplementation(testFixtures(projects.junitPlatformLauncher))
testImplementation(testFixtures(projects.junitPlatformReporting))
osgiVerification(projects.junitPlatformLauncher)
}
tasks {
compileJava {
options.compilerArgs.add("-Xlint:-requires-automatic,-processing") // -requires-automatic: JUnit 4, -module: due to qualified exports, -processing: not all annotations need to be processed
}
compileTestFixturesGroovy {
javaLauncher = project.javaToolchains.launcherFor {
// Groovy 2.x (used for Spock tests) does not run on more recent JDKs
languageVersion = JavaLanguageVersion.of(17)
}
}
jar {
bundle {
val junit4Min = libs.versions.junit4Min.get()
val version = project.version
bnd("""
# Import JUnit4 packages with a version
Import-Package: \
${extra["importAPIGuardian"]},\
${extra["importJSpecify"]},\
${extra["importCommonsLogging"]},\
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.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;$version}"
Require-Capability:\
org.junit.platform.launcher;\
filter:='(&(org.junit.platform.launcher=junit-platform-launcher)(version>=${'$'}{version_cleanup;$version})(!(version>=${'$'}{versionmask;+;${'$'}{version_cleanup;$version}})))';\
effective:=active
""")
}
}
val testWithoutJUnit4 = register("testWithoutJUnit4", Test::class) {
val test = testing.suites.named<JvmTestSuite>("test")
(options as JUnitPlatformOptions).apply {
includeTags("missing-junit4")
}
setIncludes(listOf("**/JUnit4VersionCheckTests.class"))
testClassesDirs = files(test.map { it.sources.output.classesDirs })
classpath = files(test.map { it.sources.runtimeClasspath }).filter {
!it.name.startsWith("junit-4")
}
}
withType<Test>().named { it != 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)
}
}
eclipse {
classpath {
// Avoid exposing test resources to dependent projects
containsTestFixtures = false
}
project {
// Remove Groovy Nature, since we don't require a Groovy plugin for Eclipse
// in order for developers to work with the code base.
natures.removeAll { it == "org.eclipse.jdt.groovy.core.groovyNature" }
}
}