-
Notifications
You must be signed in to change notification settings - Fork 434
Unable to apply plugins from an applied build script file #179
Comments
This is a known limitation of Gradle, not specific to Kotlin. This can only be solved by supporting script plugins in the new plugins DSL. You only have a binary choice at the moment: Put everything related to the HelloPlugin into the project script or put everything related to the HelloPlugin in the script plugin (including the buildscript block). You cannot mix both at the moment. |
Would you be so kind to provide a link for more information regarding this gradle issue? I guess it's due to dynamic (default) nature of groovy but it seamlessly worked in my groovy/gradle projects before. Use case looks rather common to me - creating modular build scripts for all aspects of a project (e.g. versioning) by applying relevant plugins and configuring them in related build script files. Now regarding the second choice, do you mean that I should create a plugin in |
The classloaders of each script are isolated from each other. The script plugin cannot see your project's classpath and the project cannot see the script plugin's classpath. What we want to allow in the future is to make dependencies and classes of the script plugin available to your project's buildscript. This will put script plugins on par with "normal" plugins.
Correct, this only works because of Groovy's dynamic nature. Try referring to an explicit type and you'll see that it fails just like in the Kotlin sample.
I meant to put everything related to |
Thank you for taking the time to explain.
I have update the sample project and indeed, after moving everything (except for the |
Superseded by #180. |
I have created a small sample project: https://github.com/tadaskay/issues/tree/master/gradle-script-kotlin-apply-from-plugin
It's not possible to
apply<HelloWorldPlugin>()
from an applied script (applyFrom("applied.gradle.kts")
inbuild.gradle.kts
)BTW if you use
apply { plugin("...") }
syntax, it seems to work for applying plugin itself, but then you have the same problem when you try to configure the extension classes in the applied script.The text was updated successfully, but these errors were encountered: