Reports directory variable

There were failing tests. See the report at: file:///G:/DWork/osource/spring-boot/archunit/build/reports/tests/test/index.html

Which is the variable that I can use to know the location of this file… I don’t want to hardcode this file name with $buildDir/reports/tests/test/index.html

from the project you can use reportsDir

Project (Gradle API 7.5) which has the directory of the reports

for the report file it self task that create report use this type Report - Gradle DSL Version 7.5

which has name property that has the file name

hope that help and have a nice day :slight_smile:

1 Like

Yes @justsoomeone… it is

test.reports.html.destination is the directory

hence using

Desktop.getDesktop().browse(new File(test.reports.html.destination, "index.html").toURI())
1 Like

Almost, test.reports.html.entryPoint is what you are after, that is directly the html page to display

1 Like

Thank you this script works awesome

commandLine 'cmd', '/c', 'start', "${test.reports.html.entryPoint}"

how can I know property names of each folder as per gradle directory structure or what is the way to know from the API, what is respective property name…

e.g I don’t know how to reach to test classes folder etc.

image

I am clear that this path internally gets resolved to getXX API hence check the pattern

Also, does each gradle plugin list all the properties of the files and dir it creates… what are the good practices in plugin development.

You should actually not get paths and configure paths.
You should wire task outputs to task inputs and thus also get the necessary task dependencies implicitly for all cases where they are necessary.
To get what you want, iirc you need sourceSets.test.output.classesDirs.

can you explain this with an example…

As I want to copy resources from x directory to y directory, not sure how what you said on wiring would help.

As hardcoding directories are a smell, I am trying to avoid it through such script properties as much as possible…

In Kotlin DSL:

val foo by tasks.registering(Sync::class) {
    from(sourceSets.test.map { it.output.classesDirs })
    into(layout.buildDirectory.dir("foo"))
}
1 Like