Understanding Implementation Options for Plugins
The choice between script, precompiled script, or binary plugins depends on your specific requirements and preferences.
Script Plugins are simple and easy to write as they are written directly in the build script. They are written in Kotlin DSL or Groovy DSL. They are suitable for small, one-off tasks or for quick experimentation. However, they can become hard to maintain as the build script grows in size and complexity.
Precompiled Script Plugins are Kotlin DSL scripts compiled into Java class files packaged in a library. They offer better performance and maintainability compared to script plugins, and they can be reused across different projects. You can also write them in Groovy DSL but that is not recommended.
Binary Plugins are full-fledged plugins written in Java or Kotlin, compiled into JAR files, and published to a repository. They offer the best performance, maintainability, and reusability. They are suitable for complex build logic that needs to be shared across projects, builds, and teams. You can also write them in Scala or Groovy but that is not recommended.
Here is a breakdown of all options for implementing Gradle plugins:
# | Using: | Type: | The Plugin is: | Created by applying: | Recommended? |
---|---|---|---|---|---|
1 |
Kotlin DSL |
Script plugin |
in a |
|
No[1] |
2 |
Groovy DSL |
Script plugin |
in a |
|
No[1] |
3 |
Kotlin DSL |
Pre-compiled script plugin |
a |
|
Yes[2] |
4 |
Groovy DSL |
Pre-compiled script plugin |
a |
|
No[3] |
5 |
Kotlin DSL |
Binary plugin |
a |
|
Yes[2] |
6 |
Groovy DSL |
Binary plugin |
a |
|
No[2] |
7 |
Java |
Binary plugin |
an abstract class that implements the |
|
Yes[2] |
8 |
Kotlin |
Binary plugin |
an abstract class that implements the |
|
Yes[2] |
9 |
Groovy |
Binary plugin |
an abstract class that implements the |
|
No[2] |
10 |
Scala |
Binary plugin |
an abstract class that implements the |
|
No[2] |
If you suspect issues with your plugin code, try creating a Build Scan to identify bottlenecks. The Gradle profiler can help automate Build Scan generation and gather more low-level information.
@groovy.transform.CompileStatic
.