mirror of
https://github.com/ysoftdevs/gradle-training.git
synced 2026-04-17 14:10:08 +02:00
09 example with doLast - config/exec phase
This commit is contained in:
10
09-custom-task-dolast/build.gradle
Normal file
10
09-custom-task-dolast/build.gradle
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
task helloWorld {
|
||||||
|
// Configuration phase - Gradle learns about tasks.
|
||||||
|
// This scope is executed first
|
||||||
|
description "Say hello :-)"
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
// Execution phase
|
||||||
|
println "Greetings from Brno"
|
||||||
|
}
|
||||||
|
}
|
||||||
38
README.md
38
README.md
@@ -1,11 +1,9 @@
|
|||||||
Gradle training
|
# Gradle training
|
||||||
===============
|
|
||||||
|
|
||||||
Training files for learning Gradle
|
Training files for learning Gradle
|
||||||
|
|
||||||
|
|
||||||
01-build-and-test
|
##01-build-and-test
|
||||||
-----------------
|
|
||||||
|
|
||||||
Example contains one class and one simple test written in TestNG.
|
Example contains one class and one simple test written in TestNG.
|
||||||
List all available tasks:
|
List all available tasks:
|
||||||
@@ -23,8 +21,7 @@ Run tests:
|
|||||||
Test report is available in build/reports/tests/index.html
|
Test report is available in build/reports/tests/index.html
|
||||||
|
|
||||||
|
|
||||||
02-pmd
|
## 02-pmd
|
||||||
------
|
|
||||||
|
|
||||||
Execute PMD check on project.
|
Execute PMD check on project.
|
||||||
|
|
||||||
@@ -34,8 +31,7 @@ You should see one warning about empty if statement in source code.
|
|||||||
Results are stored in: build/reports/pmd/main.html
|
Results are stored in: build/reports/pmd/main.html
|
||||||
|
|
||||||
|
|
||||||
03-checkstyle
|
## 03-checkstyle
|
||||||
-------------
|
|
||||||
|
|
||||||
Execute Checkstyle on project. Configuration of Checkstyle is stored in config/checkstyle/checkstyle.xml
|
Execute Checkstyle on project. Configuration of Checkstyle is stored in config/checkstyle/checkstyle.xml
|
||||||
|
|
||||||
@@ -44,8 +40,7 @@ Execute Checkstyle on project. Configuration of Checkstyle is stored in config/c
|
|||||||
Error report is available in file: build/reports/checkstyle/main.xml
|
Error report is available in file: build/reports/checkstyle/main.xml
|
||||||
|
|
||||||
|
|
||||||
04-findbugs
|
## 04-findbugs
|
||||||
-----------
|
|
||||||
|
|
||||||
Execute FindBugs on project.
|
Execute FindBugs on project.
|
||||||
|
|
||||||
@@ -54,8 +49,7 @@ Execute FindBugs on project.
|
|||||||
Report is available in file: build/reports/findbugs/main.html
|
Report is available in file: build/reports/findbugs/main.html
|
||||||
|
|
||||||
|
|
||||||
05-jdepend
|
## 05-jdepend
|
||||||
----------
|
|
||||||
|
|
||||||
Execute JDepend on project.
|
Execute JDepend on project.
|
||||||
|
|
||||||
@@ -65,8 +59,7 @@ Report is available in file: build/reports/jdepend/main.txt
|
|||||||
You should see there one dependency cyle.
|
You should see there one dependency cyle.
|
||||||
|
|
||||||
|
|
||||||
06-maven-deployer
|
## 06-maven-deployer
|
||||||
-----------------
|
|
||||||
|
|
||||||
Upload artifact to local repo (directory).
|
Upload artifact to local repo (directory).
|
||||||
|
|
||||||
@@ -75,8 +68,7 @@ Upload artifact to local repo (directory).
|
|||||||
Artifact will be stored at: /idea/training/repo
|
Artifact will be stored at: /idea/training/repo
|
||||||
|
|
||||||
|
|
||||||
07-c-language
|
## 07-c-language
|
||||||
-------------
|
|
||||||
|
|
||||||
It is possible to build project written in C language by gradle.
|
It is possible to build project written in C language by gradle.
|
||||||
Gradle automatically detects toolchain e.g. Visual Studio or GCC.
|
Gradle automatically detects toolchain e.g. Visual Studio or GCC.
|
||||||
@@ -86,12 +78,22 @@ Gradle automatically detects toolchain e.g. Visual Studio or GCC.
|
|||||||
Binary is stored in build/binaries/mainExecutable
|
Binary is stored in build/binaries/mainExecutable
|
||||||
|
|
||||||
|
|
||||||
08-c-visual-studio
|
## 08-c-visual-studio
|
||||||
------------------
|
|
||||||
|
|
||||||
Gradle is able to generate project files for Visual Studio for C/C++.
|
Gradle is able to generate project files for Visual Studio for C/C++.
|
||||||
|
|
||||||
gradle mainVisualStudio
|
gradle mainVisualStudio
|
||||||
ii .\visualStudio\mainExe.sln
|
ii .\visualStudio\mainExe.sln
|
||||||
|
|
||||||
|
|
||||||
|
## 09-custom-task-dolast
|
||||||
|
|
||||||
|
Gradle evaluates build scripts in two phases. The first one is configuration.
|
||||||
|
Gradle examines each task definition and execute code in definition.
|
||||||
|
The second phase is execution where it actually executes code.
|
||||||
|
The code is stored in doLast block. If you omit that block then println
|
||||||
|
will execute always even when you run `gradle tasks`
|
||||||
|
|
||||||
|
gradle tasks
|
||||||
|
gradle helloWorld
|
||||||
Solution file is stored in visualStudio/mainExe.sln
|
Solution file is stored in visualStudio/mainExe.sln
|
||||||
|
|||||||
Reference in New Issue
Block a user