Settings.properties define variable use in root project of multiproject

Hi,

Is it possible to create variable/property in settings.properties and use it in multiproject root project tasks?

I need bootstrap task to checkout project structure from cvs (20 - 25 cvs modules).

Currently I have settings.propertis with project includes + some logic not to include optional projects:

def addOptionalProject(String projectDir){
      if (file(projectDir).exists()){
        include projectDir
        println "Optional project added. Project ${projectDir}"
    }
}

I would like to be able to checkout all cvs modules/sub-projects.

I need checkout projects which are optional and are not included in actual sub-projects list and I thought best way would be create list of project names in settings.properties and use it in custom task to perform cvs checkout and in loop in settings.properties to include projects while building after checkout.

Is it possible? Do you think there is better way to avoid duplicate project definition in settings.properties and in my task/plugin configuration in build.gradle?

Thanks.

Regards, Zdenek

no need for cvs more.

I use custom gradle config file to define projects and its types, this is used in settings.gradle and in the installer to generate dependencies during config phase.

One way to get information across is via an extra property on the ‘gradle’ object.

settings.gradle

gradle.ext.foo = "bar"

build.gradle

println gradle.foo
1 Like

If setting a value on the extra property of the gradle object, does it always have to be referenced via “gradle.foo” from within the build.gradle as well?

Is there a way to set the property in the settings.gradle file so that from within any project in a multi-project build, the said property could simply be referenced from either “project.foo”, or even just “foo”?

Try ‘gradle.rootProject.ext.foo = “bar”’. Then you should be able to refer to the property as ‘foo’ from anywhere.

Thanks Peter for your help with this. For what it is worth, when attempting what you suggested resulted in the following:

http://forums.gradle.org/gradle/topics/java_lang_illegalstateexception_the_root_project_is_not_yet_available_for_build

This was using Gradle v1.10. Don’t know if this if a bug or what, but wanted to let you know.

Thanks again!

I don’t think it’s a bug. ‘gradle.ext.foo = “foo”’ and ‘println foo’ seems like the correct solution.