Gradle Tutorial
Introduction Installation Creating project using command line Simple gradle project in IntelliJ IDEA build.gradle file settings.gradle file Directory structure of Gradle project Built-in tasks User defined tasks Task dependencies Running gradle tasks Grouping tasks Repository management in Gradle Declaring dependencies in Gradle JUnit TestNG Test execution reports in Gradle Creating executable Jar using Gradle Generating project API documentation in Gradle Publishing and deployment of artifact in GradleUser defined tasks in gradle
Plugins provide most of the built in tasks in Gradle. For example – Java plugin provides default tasks. But you can also write your custom tasks in build.gradle file as shown below.
task task1;
task1.doFirst( {
println "This block of task1 will be executed first"
} );
task1.doLast( {
println "This block of task2 will be executed last"
} );
task1 <<{
println "This block will be executed after doLast block of task1"
}
//Another way to declare task
task task2 << {
println "Declaring and defining new task at the same time"
}
task2 << {
println "This block of task2 will be executed after task2 - doLast"
}
task2 << {
println "You can have as many blocks as possible for a task"
}
Note that you can also add your own code to be executed in specific task. For example – below lines of block will be executed at the time of compileJava task
compileJava.doFirst { println ‘This will be executed before starting compileJava task’ }
compileJava << { println ‘This will be executed after compileJava task’ }
Web development and Automation testing
solutions delivered!!