i have some common gradle file with some tasks defined and with some ext variables defined. For ex:
common.gradle
ext {
myVar1 = 'abc' //some default value
}
tasks.register('myTask') {
println "$myVar1"
}
i’m including this gradle file to access the tasks in my project. Here i want to override that variable and when myTask gets called, it should have overriden value.
myproject/build.gradle
apply from '../common.gradle'
ext {
myVar1= "xyz" //actual value
}
when i call gradle myTask
its printing “abc” instead of “xyz”. I tried putting doLast
closure in myTask
but still its printing “abc” only.
I need to include common.gradle
in multiple projects, where i need to set project specific values
How to achieve this?