Commit 349cd71e authored by Quynh Nguyen's avatar Quynh Nguyen
Browse files

updated buildTool docs

parent ab497c5c
......@@ -10,6 +10,7 @@
to the console so the developer can solve it while waiting for the other build tasks to finish
## Execute tasks with Maven
### Execute basic build tasks
#### init and project structure
......@@ -18,6 +19,7 @@ To create a simple project, execute ``mvn -B archetype:generate -DgroupId=de.onc
- Console output:
![alt text](img/mvn-init.png "maven init")
- Project structure:
![alt text](img/mvn-project-tree.png "maven tree")
- Apart from the source code, maven generates a pom.xml file. A Project Object Model or POM \
is the fundamental unit of work in Maven. It is an XML file that contains information about \
......@@ -229,17 +231,19 @@ Output files were added to .m2 local repository:
5. Execute task by running ``mvn sample.plugin:math-maven-plugin:1.0.0:getMathProblem`` on the command line
![alt text](img/mvn-output-easy.png "maven output")
![alt text](img/mvn-easy.png "maven easy")
## Execute tasks with Gradle
### Execute basic build tasks
#### init and project structure
- Create a new example kotlin project using ``gradle init``
- Output:
![alt text](img/gradle-init-1.png "gradle init1")
![alt text](img/gradle-init-2.png "gradle init2")
- Project structure:
![alt text](img/gradle-pj.png "gradle project")
- ![alt text](img/gradle-pj.png "gradle project")
- The settings.gradle.kts file has two interesting lines
``` = "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``
- Build scan output:
1. Summary
1. Summary \
![alt text](img/gradle-scan-1.png "gradle scan 1")
![alt text](img/gradle-scan-2.png "gradle scan 2")
![alt text](img/gradle-scan-3.png "gradle scan 3")
2. Console output
2. Console output \
![alt text](img/gradle-console-output.png "gradle console output")
3. Timeline
......@@ -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.
......@@ -408,3 +412,11 @@ tasks.register<MathTask>("math-hard") {
- Run `gradle math-hard` to execute the task with difficulty level hard
![alt text](img/gradle-hard.png "gradle hard")
## Summary
| Maven | Gradle |
| 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 |
......@@ -60,5 +60,17 @@
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment