Is there any way to turn on build profiling by default without sending it via command-line parameter?

Is there any way to turn on build profiling by default without sending it via command-line parameter? For example by specifying it in gradle.properties or maybe within the build script itself.

gradle.startParameter.profile = true

Hi Peter, that didn’t seem to work. I tried adding this in gradle.properties but when I print this in the build script, it gives me “false”. I also tried changing this directly in the build script in settings.gradle, but it looks like this property is already read prior to this for profiling.

Upon searching a bit at the source code, this property seems to be read by in the org.gradle.initialization.DefaultGradleLauncherFactory#newInstance() method which I’m guessing happens prior to invoking any build scripts.

I tried imitating the portion that adds the profile generator listener in the build script like this and that worked.

gradle.services.get(ListenerManager).addListener(new ReportGeneratingProfileListener())

But this seems hacky. Is there a cleaner way of achieving this? Also, in general do we have any way of injecting some default gradle start parameters through gradle.properties?