1+
12import com.gradle.develocity.agent.gradle.internal.test.PredictiveTestSelectionConfigurationInternal
23import com.gradle.develocity.agent.gradle.test.PredictiveTestSelectionMode
34import org.gradle.api.tasks.PathSensitivity.NONE
@@ -16,25 +17,34 @@ var openTestReportingCliClasspath = configurations.resolvable("openTestReporting
1617 extendsFrom(openTestReportingCli.get())
1718}
1819
19- val htmlReportFile = layout.buildDirectory.file(" reports/open-test-report.html" )
20- val eventXmlFiles =
21- files(tasks.withType<Test >().map { it.reports.junitXml.outputLocation.get().asFileTree.matching { include(" junit-platform-events-*.xml" ) } })
22-
2320val generateOpenTestHtmlReport by tasks.registering(JavaExec ::class ) {
2421 mustRunAfter(tasks.withType<Test >())
2522 mainClass.set(" org.opentest4j.reporting.cli.ReportingCli" )
2623 args(" html-report" )
2724 classpath(openTestReportingCliClasspath)
28- outputs.file(htmlReportFile)
29- inputs.files( eventXmlFiles).withPathSensitivity( NONE ).skipWhenEmpty()
30- argumentProviders + = CommandLineArgumentProvider {
31- listOf (
32- " --output " ,
33- htmlReportFile.get().asFile.absolutePath
34- ) + eventXmlFiles.files.map { it.absolutePath }.toList( )
25+ argumentProviders + = objects.newInstance( HtmlReportParameters :: class ). apply {
26+ eventXmlFiles.from(tasks.withType< Test >().map {
27+ objects.fileTree()
28+ .from(it.reports.junitXml.outputLocation)
29+ .include( " junit-platform-events-*.xml " )
30+ })
31+ outputLocation = layout.buildDirectory.file( " reports/open-test-report.html " )
3532 }
3633}
3734
35+ abstract class HtmlReportParameters : CommandLineArgumentProvider {
36+
37+ @get:InputFiles
38+ @get:PathSensitive(NONE )
39+ abstract val eventXmlFiles: ConfigurableFileCollection
40+
41+ @get:OutputFile
42+ abstract val outputLocation: RegularFileProperty
43+
44+ override fun asArguments () = listOf (" --output" , outputLocation.get().asFile.absolutePath) +
45+ eventXmlFiles.map { it.absolutePath }.toList()
46+ }
47+
3848tasks.withType<Test >().configureEach {
3949 useJUnitPlatform {
4050 includeEngines(" junit-jupiter" )
@@ -106,10 +116,9 @@ tasks.withType<Test>().configureEach {
106116 )
107117 }
108118
119+ val reportFiles = objects.fileTree().from(reports.junitXml.outputLocation).matching { include(" junit-platform-events-*.xml" ) }
109120 doFirst {
110- files(reports.junitXml.outputLocation.get().asFileTree.matching {
111- include(" junit-platform-events-*.xml" )
112- }).files.forEach {
121+ reportFiles.files.forEach {
113122 Files .delete(it.toPath())
114123 }
115124 }
0 commit comments