0

Is it possible to read arbitrary variables from settings.gradle in build.gradle?

Currently my settings.gradle is only setting the project name. This seems like a reasonable place to add some other constants that are likely to only be touched once during the project lifecycle.

I know I can create a gradle.properties file and set properties there, but it feels weird splitting my constants across two locations when my settings.gradle file is so short anyway.

logworthy
  • 1,218
  • 2
  • 11
  • 23
  • This are a lots of options for this! It depends on the variables you want to share, but usually it's a good idea to use [Project Properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:project_properties). These can have defaults in the project's `gradle.properties`, but can be overridden - which is very useful for CI/CD (example: [repository credentials](https://stackoverflow.com/a/72075210/4161471)). You could also create a [convention-plugin](https://stackoverflow.com/a/72139946/4161471) that creates an [extension](https://stackoverflow.com/a/73551796/4161471). – aSemy Apr 24 '23 at 09:10

0 Answers0