Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Gradle Essentials

You're reading from   Gradle Essentials Master the fundamentals of Gradle using real-world projects with this quick and easy-to-read guide

Arrow left icon
Product type Paperback
Published in Dec 2015
Publisher
ISBN-13 9781783982363
Length 176 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
 Dabir Dabir
Author Profile Icon Dabir
Dabir
 Maheshwari Maheshwari
Author Profile Icon Maheshwari
Maheshwari
Arrow right icon
View More author details
Toc

The polyglot application


For the code example, in this chapter, let's build a simple Quote of the Day service that returns a quote based on the day of the year. Since we might have fewer quotes in our store, the service should repeat the quotes in a cyclic fashion. Again, as usual, we will try to keep it as simple as possible to focus more on build aspects rather than the application logic. We will create two separate Gradle projects to implement the exact same functionality, once in Groovy then in Scala.

Before going into language-specific details, let's start with defining the QotdService interface, which just declares only one method, getQuote. The contract is, as long as we pass the same date, we should get the same quote back:

package com.packtpub.ge.qotd;

import java.util.Date;

interface QotdService {
  String getQuote(Date day);
}

The logic to implement getQuote can use the Date object in any manner, such as using the entire date including the time for determining the quote. However...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images