matthias
2011-08-10 07:57:31 UTC
Hey there,
I am running into a few issues when using apply from: <file>, and I just
don't understand why these things happen. What I want to do is make my build
scripts a little cleaner by separating code out into files that I include
using "apply from".
However, two things in particular struck me as not working anymore:
1) Within the included file, I cannot apply plugin: <plugin-id> anymore. I
have to spell out the fully qualified class name of the plug-in for it to
work. Example:
// build.gradle
apply from: 'included.gradle'
// included.gradle
buildscript {
// define repose and build script dependencies
}
apply plugin: 'plugin-id' // FAILS with "no plugin with that ID"
apply plugin: com.example.Plugin // works
However, if I keep the buildscript setup in the included file, and move the
apply call from included.gradle to build.gradle, then applying the plugin by
ID works! Why is that?
2) I don't understand why methods defined in an included file are not
visible in the file that includes it:
// included.gradle
def helper() {}
// build.gradle
apply from: 'included.gradle'
helper() // fails: no such method
Again, why is that? My understanding was that any "global" definition or
call is delegated to the project instance. So wouldn't that mean that helper
is both defined and called on the project object (well, apparently it's not,
but just trying to figure out what's happening here).
Thanks for you input.
--
View this message in context: http://gradle.1045684.n5.nabble.com/Understanding-apply-from-file-tp4684988p4684988.html
Sent from the gradle-user mailing list archive at Nabble.com.
I am running into a few issues when using apply from: <file>, and I just
don't understand why these things happen. What I want to do is make my build
scripts a little cleaner by separating code out into files that I include
using "apply from".
However, two things in particular struck me as not working anymore:
1) Within the included file, I cannot apply plugin: <plugin-id> anymore. I
have to spell out the fully qualified class name of the plug-in for it to
work. Example:
// build.gradle
apply from: 'included.gradle'
// included.gradle
buildscript {
// define repose and build script dependencies
}
apply plugin: 'plugin-id' // FAILS with "no plugin with that ID"
apply plugin: com.example.Plugin // works
However, if I keep the buildscript setup in the included file, and move the
apply call from included.gradle to build.gradle, then applying the plugin by
ID works! Why is that?
2) I don't understand why methods defined in an included file are not
visible in the file that includes it:
// included.gradle
def helper() {}
// build.gradle
apply from: 'included.gradle'
helper() // fails: no such method
Again, why is that? My understanding was that any "global" definition or
call is delegated to the project instance. So wouldn't that mean that helper
is both defined and called on the project object (well, apparently it's not,
but just trying to figure out what's happening here).
Thanks for you input.
--
View this message in context: http://gradle.1045684.n5.nabble.com/Understanding-apply-from-file-tp4684988p4684988.html
Sent from the gradle-user mailing list archive at Nabble.com.