- Copy the Gradle distribution from the USB stick to your hard disk.
- Download and unzip the Workshop Exercises from https://github.com/pniederw/gradle-workshop-gr8conf/zipball/master.
- Add an environment variable
GRADLE_HOME
pointing to the top-level directory of the Gradle distribution. - Add
GRADLE_HOME/bin
to thePATH
environment variable. - Activate the Gradle Daemon by setting the environment variable
GRADLE_OPTS
to-Dorg.gradle.daemon=true
. - Open a terminal and execute
gradle -v
. - Have a look at
http://gradle.org/downloads.html
.
- Go to
GRADLE_HOME/samples/java/quickstart
. - Check the output of
gradle help
,gradle -?
andgradle tasks
. - Build the archives for this Java project and try to find them.
- Run the tests of this project with the Gradle UI. Start the UI with
gradle --gui
.
- Go to
GRADLE_HOME/samples/java/quickstart
. - Run
gradle clean build
. - Run
gradle build
. Observe that all tasks are up-to-date. - Add an arbitrary method to the project's main source code. Which tasks will be run again on the next build?
- Add an arbitrary comment to the project's main source code. Which tasks will be run again on the next build?
- Add a
hello
task that prints 'hello world'. - Execute this task.
- Add a
date
task that prints out the current date. - Execute this task.
- Write a custom task class of type
Greeting
. Add a propertygreeting
for the greeting text. Assign a default value to it. The task action should print the greeting text property. Add two tasks to your build script, both of typeGreeting
. One should assign a custom value to the greeting property. Execute both tasks.
- Make the
date
task depend on thehello
task. - Execute the
date
task. - Execute
gradle tasks --all
. - The
--dry-run
(or-m
) command line option executes the build but disables all actions. Executedate
with thedry-run
option. - Add some top level
println
statements to the script. - Add a
println
statement to the configuration block of thedate
task. - Execute the
hello
task and analyze the output.
- Apply the plugin
info.gradle
in theplugins
directory to the build. Executegradle tasks
to see what task has been added. Execute the task.
-
Run the tests with
testReport
set to false. What do you see? -
Run the tests with different settings for
forkEvery
. What do you see? -
Run the tests with different settings for
maxParallelForks
. What do you see? -
(Optional) Add a listener that, if a test fails, opens the test results XML file.
Hint:
- The test results XML file can be found at
build/test-results/TEST-<test-class-name>.xml
. - To execute an external command in Groovy, use
"command args".execute()
. - Check the Javadoc of the
org.gradle.api.tasks.testing.Test.afterTest
method to learn about its arguments.
- The test results XML file can be found at
- Add the Maven Central repository and a configuration named
mydeps
. Assign theorg.apache.httpcomponents:httpclient:4.0.3
dependency tomydeps
. - Add a task
showDeps
that prints out the files of themydeps
configuration. - Add task
copyDeps
that copies the files of themydeps
configuration into thebuild/deps
dir. - Execute
gradle dependencies
.
- Investigate the structure of the multi project build. Execute the
build
task from the root project and observe what is happening. - Go to the
api
project. Executebuild
from there. Execute alsobuildNeeded
andbuildDependent
. What is different compared to executing the build task? - Execute the
build
task of theapi
project from the root project directory. - Execute
gradle projects
from the root directory. - Execute
gradle projects
andgradle :projects
from the services directory. - Execute
gradle tasks
andgradle :api:tasks
from the root project directory. - Execute
gradle :services:webservice:properties
from the root project directory. - Execute
gradle --profile clean build
from the root project. Have a look at the profile report inbuild/reports/profile
.