How to add a class / an enum to settings gradle script on gradle 6.0+?

I want to add an enum called modules with the path of the sub module and some compilation types.

I used to have this in the buildSrc before gradle 6 and it was accessible in the settings.gradle

But from gradle 6.0, settings.gradle is compiled before buildSrc project. I have moved my enum to the settings.gradle, now it is not accessible to other project level gradle scripts.

The behaviour change is outlined in the below release notes. https://docs.gradle.org/current/userguide/upgrading_version_5.html#changes_to_plugins_and_build_scripts

They suggest to add the enums / classes used in the settings.gradle to the build script closure, but I am not really sure how to do that.

https://docs.gradle.org/current/userguide/upgrading_version_5.html#plugins_and_classes_loaded_in_settings_scripts_are_visible_to_project_scripts_and_buildsrc

1 Like