Has the same effect add the "apply plugin" at the beginning or end of the file build.gradle in Android Studio projects?
For example to add the 'com.google.gms.google-services' plugin, Firebase official documentation recommends adding at the end, but I've seen other codes add it at the beginning.
I know the question seems irrelevant, but I'm developing a plugin for Android Studio to manage dependencies and have this doubt.
Thanks in advance
Put the source of the plugin directly into the build. gradle file. One big advantage of this approach is that the class is automatically compiled and added to the classpath of the build script without you configuring anything.
Applying a plugin to a project allows the plugin to extend the project's capabilities. It can do things such as: Extend the Gradle model (e.g. add new DSL elements that can be configured) Configure the project according to conventions (e.g. add new tasks or configure sensible defaults)
The Base Plugin provides some tasks and conventions that are common to most builds and adds a structure to the build that promotes consistency in how they are run.
Gradle scripts are interpreted top to bottom so order can be important. Keep in mind that gradle has a configuration phase and an execution phase so sometimes order isn't important. It's common to apply your plugins at the top of the script since plugins often add extension objects and tasks to the gradle model which can then be configured lower down in the build script.
For example, you can't do the following because the test
task is added by the java
plugin:
test {
include 'org/foo/**'
}
apply plugin: 'java'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With