Microsoft Word – 20180305_lab_09_r001.docx
SE (M) 2017-2018 Lab 9 Build Systems (Gradle)
Revision: 20180305a
The aim of this lab is to introduce you to build automation system by going through a
practical tutorial. Once you have completed the basic tutorial, we encourage you to try
setting this up with some of your own code from e.g. programming or SE.
1) Install & Running Gradle in the Lab (Windows)
Gradle is easily installed (5 min) by…
a) Download https://services.gradle.org/distributions/gradle-4.6-
bin.zip?_ga=2.97905119.1560486001.1520087634-776118813.1519745587 (as zip
file) to c:\local\ (typically called gradle-4.6-bin.zip.).
b) Unzip the zip to c:\local\ gradle-4.6\ (after unzipping make sure you have
a folder called C:\local\gradle-4.6\bin)
c) Open a windows terminal / command prompt (e.g. available in the start menu, search
by typing “cmd”)
d) Add the folder to the path variable by typing:
set PATH=%PATH%;C:\Local\gradle-4.6\bin
…then press enter. Note: you need to do this every time you open a new
terminal.
e) Verify that Gradle starts up and builds (Should say something like “Welcome to
Gradle 4.6… BUILD SUCCESSFUL”)
… leave the terminal open.
2) Creating a trivial build
We follow this guide to create a trivial build (Note you may need to replace the
command “gradlew” with “gradle” on Windows systems)
https://guides.gradle.org/creating-new-gradle-builds/
Do not be put off if all the output of the commands you enter is not the same as what is
listed in the guide. Changes made between versions of Gradle mean that some
behaviour is different from what is documented. Call a demonstrator if you need help.
At some point the above guide invites you to analyse your build using a build
scan. This requires you to enter an email address. Do this if you wish.
3) Building a Jar file and testing Java code
The previous guide ends with links which show you how to build example projects in
various languages. Follow the Building Java Libraries guide:
https://guides.gradle.org/building-java-libraries/
Again, the output of some commands won’t be the same as the output listed in the
text. Don’t be put off by this if you builds are successful. Call a demonstrator if you
need help.
4) What’s next?
Check out what other things the Gradle Java plugin can do:
https://docs.gradle.org/current/userguide/java_plugin.html
Gradle isn’t the only build system avaliable. You may have already used Maven or Ant
with your Java projects. Another build automation tool is Make, which was first
written in 1976. Software Carpentry have the following guide on Make:
http://swcarpentry.github.io/make-novice/