List of all the predefined build variables in gradle

Like $buildDir I want to know all the directory variables that are available, e.g I want to know what is the test report file name… as in the final output it says see report at

report at: file:///G:/DWork/osource/spring-boot/archunit/build/reports/tests/test/index.html

I want to the name of the variable that has this info or at least test directory root in this case file:///G:/DWork/osource/spring-boot/archunit/build/reports/tests/test/

There are no “pre-defined build variables”.
All are properties of some object or convention properties added by some plugins.
You find them in the documentation of Gradle and that plugins you use.
buildDir for example is a property of Project: Project - Gradle DSL Version 7.5.1.

I highly recommend using the Kotlin DSL instead of the Groovy DSL.
For a small time penalty in certain situations you gain an immense comfort when editing build scripts,
as you right away have type-safe build scripts and an amazing IDE support including proper auto-completion. At least if you use IntelliJ IDEA which I would recommend anyway. :smiley:

But actually, you should almost never use such “path” variables to manually build paths.
Usually the tasks you are interested in are outputs of some tasks.
You should query those tasks for the path, so you also get reconfigured values automatically.
Most times when you manually construct a path to a file you want to consume, you are adding a code smell actually.

And if you use those task outputs as inputs to other tasks, or other settings that understand task dependencies like source directories and similar, you also automatically get the needed task dependencies implicitly, because also writing explicit dependsOn (except if on the left-hand side is a lifecycle task) is a code smell.

The concrete example you mentioned should for example be available as tasks.test.get().reports.html.outputLocation.

Btw. you should usually also not use gradle to build a Gradle project. I usually even never have any Gradle version installed. Each project should include the four Gradle wrapper files that define which Gradle version the build is designed for and known to run properly with and take care that this version is automatically used to build the project.