- Create a new example kotlin project using ``gradle init``
- Output:
-


- Project structure:

- 
- The settings.gradle.kts file has two interesting lines
```
rootProject.name = "gradle-example" // assigns a name to the build
...
...
@@ -322,11 +326,11 @@ cleanTask — task rule
- As we can see in the previous output, gradle omits a lot of details in the console logs.
The best way to learn more about what the command is doing behind the scene, is to publish a build scan. To do so, run Gradle with the --scan flag. ``gradle build --scan``
@@ -336,14 +340,14 @@ The best way to learn more about what the command is doing behind the scene, is
1. Create a custom plugin/task
- There are several places to put the source for the plugin.
Build script
*Build script*
include the source for the plugin directly in the build script. This has the benefit that the plugin is automatically compiled and included in the classpath of the build script without you having to do anything. However, the plugin is not visible outside the build script, and cannot be reused outside of the build.
buildSrc project
*buildSrc project*
put the source for the plugin in the rootProjectDir/buildSrc/src/main/java directory (or rootProjectDir/buildSrc/src/main/groovy or rootProjectDir/buildSrc/src/main/kotlin depending on the prefered language). Gradle will take care of compiling and testing the plugin and making it available on the classpath of the build script. The plugin is visible to every build script used by the build. However, it is not visible outside the build, and cannot be reused outside of the build.
Standalone project
*Standalone project*
create a separate project for the plugin. This project produces and publishes a JAR which can then be used in multiple builds and share with others. Generally, this JAR might include some plugins, or bundle several related task classes into a single library. Or some combination of the two.
| Uses Extensible Markup Language(XML) for creating project structure. | Uses a Groovy-based Domain-specific language(DSL) for creating project structure. |
| Scripts are longer than Gradle's | Scripts are shorter and cleaner than Maven's |
| Extensive console output | Minimal console output and advanced analysis with build scan |
| Developing custom plugin takes more time because testing requires publishing plugin to a (local) repository | Developing custom task/plugin is faster because plugin can be defined in build script |