Вопрос

I have 2 gradle scripts:

build.gradle and other.gradle

In my build.gradle I have: apply from: 'other.gradle'

task callotherscript << {
  thevar = "Thevariableiwanttogetsomeplaceelse"
  dosomecommand    

In my other.gradle I have:

task dosomecommand(type: Exec) {
  executable "someexe"
  args "aa", "<myarg>" + <thevar>, "<intomydir>"
}

My question is: How do I get "thevar" from build.gradle so I can use it in other.gradle.

I run: gradle callotherscript

The error message I am seeing is:

Could not find property 'thevar' on task ':dosomecommand'.

I have looked through the cookbook, and every gradle doc I thought was relevant, and I am just not seeing how to do it.

Thanks

Это было полезно?

Решение

You can declare an extra property, for example on project:

ext.foo = "bar"

Scripts applied further down can now access the property as foo.

It's important to understand that tasks don't call other tasks but depend on other tasks.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top