Getting the settings object from the buildscript file

I am trying to access the settings object from the project's build root script.

The reason is that I want to define a list in the settings.gradle file that will be a list of subprojects, like:

settings.gradle

projectNames = ['prjA', 'prjB']

      

I would like to do something like:

build.gradle (root project)

projectNames = settings.projectNames
// Use projectName in tasks

      

And then run it in build.gradle file for various tasks like resolving those names to urls on git-clone them. However, I can't seem to find a way to declare any arbitrary groovy object that is visible between these two scripts. Note. It might seem to me that this list would be related, but not the same as project names. I am guessing the question is summarized for POGO sharing between the two and accessing the settings object.

I am new to Gradle.

+3


source to share


1 answer


Can't get to object settings

from build script. However, both scripts share an object gradle

that can be used to set an additional property in the script settings (for example gradle.ext.foo = "bar"

) and read it in the assembly script (for example println gradle.foo

).



+6


source







All Articles