@@ -2,6 +2,7 @@ import org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask
2
2
import org.gradle.api.tasks.PathSensitivity.RELATIVE
3
3
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
4
4
import org.junit.gradle.exec.ClasspathSystemPropertyProvider
5
+ import org.junit.gradle.exec.RunConsoleLauncher
5
6
import org.junit.gradle.javadoc.ModuleSpecificJavadocFileOption
6
7
import java.io.ByteArrayOutputStream
7
8
import java.nio.file.Files
@@ -114,63 +115,21 @@ require(externalModulesWithoutModularJavadoc.values.all { it.endsWith("/") }) {
114
115
115
116
tasks {
116
117
117
- val consoleLauncherTest by registering {
118
- val runtimeClasspath = sourceSets[" test" ].runtimeClasspath
119
- inputs.files(runtimeClasspath).withNormalizer(ClasspathNormalizer ::class )
120
- val reportsDir = file(" $buildDir /test-results" )
121
- outputs.dir(reportsDir)
122
-
123
- val debugging = providers.gradleProperty(" consoleLauncherTestDebug" )
124
- .map { it != " false" }
125
- .orElse(false )
126
- outputs.cacheIf { ! debugging.get() }
127
- outputs.upToDateWhen { ! debugging.get() }
128
-
129
- // Track OS as input so that tests are executed on all configured operating systems on CI
130
- trackOperationSystemAsInput()
131
- doFirst {
132
- val output = ByteArrayOutputStream ()
133
- val result = javaexec {
134
- debug = project.findProperty(" debug" ) == " true"
135
- classpath = runtimeClasspath
136
- mainClass.set(" org.junit.platform.console.ConsoleLauncher" )
137
- args(" --scan-classpath" )
138
- args(" --config" , " enableHttpServer=true" )
139
- args(" --include-classname" , " .*Tests" )
140
- args(" --include-classname" , " .*Demo" )
141
- args(" --exclude-tag" , " exclude" )
142
- args(" --reports-dir" , reportsDir)
143
- args(" --config=junit.platform.reporting.output.dir=${reportsDir} " )
144
- args(" --config=junit.platform.reporting.open.xml.enabled=true" )
145
- systemProperty(" java.util.logging.manager" , " org.apache.logging.log4j.jul.LogManager" )
146
- debug = debugging.get()
147
- if (! debugging.get()) {
148
- standardOutput = output
149
- errorOutput = output
150
- }
151
- isIgnoreExitValue = true
152
- }
153
- if (result.exitValue != 0 && ! debugging.get()) {
154
- System .out .write(output.toByteArray())
155
- System .out .flush()
156
- }
157
- result.rethrowFailure().assertNormalExitValue()
158
- }
118
+ val consoleLauncherTest by registering(RunConsoleLauncher ::class ) {
119
+ args.addAll(" --config" , " enableHttpServer=true" )
120
+ args.addAll(" --include-classname" , " .*Tests" )
121
+ args.addAll(" --include-classname" , " .*Demo" )
122
+ args.addAll(" --exclude-tag" , " exclude" )
159
123
}
160
124
161
- register<JavaExec >(" consoleLauncher" ) {
162
- val reportsDir = file( " $buildDir /console-launcher " )
163
- outputs. dir(reportsDir )
125
+ register<RunConsoleLauncher >(" consoleLauncher" ) {
126
+ hideOutput.set( false )
127
+ reportsDir.set(layout.buildDirectory. dir(" console-launcher " ) )
164
128
outputs.upToDateWhen { false }
165
- classpath = sourceSets[" test" ].runtimeClasspath
166
- mainClass.set(" org.junit.platform.console.ConsoleLauncher" )
167
- args(" --scan-classpath" )
168
- args(" --config" , " enableHttpServer=true" )
169
- args(" --include-classname" , " .*Tests" )
170
- args(" --include-classname" , " .*Demo" )
171
- args(" --exclude-tag" , " exclude" )
172
- args(" --reports-dir" , reportsDir)
173
- systemProperty(" java.util.logging.manager" , " org.apache.logging.log4j.jul.LogManager" )
129
+ args.addAll(" --config" , " enableHttpServer=true" )
130
+ args.addAll(" --include-classname" , " .*Tests" )
131
+ args.addAll(" --include-classname" , " .*Demo" )
132
+ args.addAll(" --exclude-tag" , " exclude" )
174
133
}
175
134
176
135
test {
0 commit comments