I am working on a repo that has a Composite Build:...
# community-support
a
I am working on a repo that has a Composite Build: Project A -> Composite Build "Shared" • B • C (uses properties to configure) I know you can call Gradle on the command line using
./gradlew -Pproperty1=helloworld :a:assemble
and
C
will get configured with the
property1
value being passed into the configuration. We use a
version
file that contains some information that is used by
C
but could be different based on the calling outer project
A
or some other project. What would be the best practice to be able to read the
version
file and pass it down to project
C
? Ideally I would be able to set the properties from the outer project
A
before the configuration gets called for
C
but that doesn't seem to be possible since
A
happens after
C
Is there something that can be done in the settings.gradle.kts? I know this can be done via the root projects
gradle.properties
or the command line
-P
option, but it is unclear to me how it can be done outside of those options. Is there a way to load a set of properties in the root project and pass those properties into the composite build?
To give more context we are using the `buildConfigField`s based on these properties that can be configured differently across multiple projects. This isn't an issue when we just include a non-composite module, but using composite modules it becomes an issue not being able to configure it differently based on different configuration (ie
version
) files.
I'd also like to adhere to the Isolated Projects best practices so that we don't incur tech debt
e
a
Unfortunately this issue looks pretty old... I'm curious if anyone has come up with a workaround in the settings.gradle.kts or init.scripts.kts allowing you to load properties there before evaluation. I tried using the
gradle.beforeProject
but that didn't do anything The only thing I found that could modify the properties prior to the configuration outside of the specific build.gradle.kts file was the init scripts. But the problem with that is that has to be configured for specific user Home or Gradle installations or specified on the command line which isn't something we can do.