When I run gradle myTask the variable tmp can not be accessed. I tried to put it in and read from project.ext. I also tried to put the variable within buildscript { } because I read that this part is executed first because it sets the classpath for the execution or something like this.
I learnt that apply from: ‘foo.bar’ is not like including the text in there. Each seems to exist in its own variable scope.
My questions:
What is the reason that I cannot access the variable within the task defined in foo.gradle?
Is there a way to achive what I try here? To split a build.gradle in several files that exist in the same variable scope.
the ordering plays a role here. if you want to use the tmp field in the
script plugin during configuration phase, you need to ensure the
extension is already added.
You might want to have a look at the free available book “building & testing with gradle”. It is available here https://gradle.org/books/ and it is really a good and comprehensive introduction to gradle.