Gradle – simple approach to adding external properties

Working on a project where the team would like to keep the project file standard for all projects, and have a second file to have custom properties

(gradle version 2.6)

within the build.gradle file I added the following file stub (top):

apply plugin: 'maven'
apply plugin: 'groovy'

if(new File("custom.gradle").exists()){
    apply from: 'custom.gradle'

and the contents of the custom.gradle file are as follows:


and now using the property within my script


Spring Cloud and Microservices Video

Just watched a video on the newer Spring projects that enable Microservices and Cloud based application development.

Definitely recommend watching the video!

Topics include:

Spring Cloud Config

“Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments.”

Config Server and Client

Spring Cloud Netflix

Some really interesting topics under Spring Cloud Netflix like:

  • Service Discovery: Eureka instances can be registered and clients can discover the instances using Spring-managed beans
  • Service Discovery: an embedded Eureka server can be created with declarative Java configuration
  • Circuit Breaker: Hystrix clients can be built with a simple annotation-driven method decorator
  • Circuit Breaker: embedded Hystrix dashboard with declarative Java configuration
  • Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations
  • Client Side Load Balancer: Ribbon
  • External Configuration: a bridge from the Spring Environment to Archaius (enables native configuration of Netflix components using Spring Boot conventions)
  • Router and Filter: automatic regsitration of Zuul filters, and a simple convention over configuration approach to reverse proxy creation

SpringBoot – spring-boot-starter-mail

Quick Tutorial on setting up and using the spring-boot-starter-mail component.

I recently had to create a project that required sending simple emails to a single email address, so I thought I would see what Spring Boot had to offer, as this seems like something I shouldn’t have to reinvent.  Great News… I was quite pleased to see that this task would be 100% solved by setting a few properties (to get the mailSender up and running), and my simple controller action.

Watch Video to see in action

Source Code


Gradle – Daemon for performance (how to start and stop)

We are currently using Gradle to manage IBM Integration Broker local developer workstations (projects), IIB Build (for BAR file generation), IIB Configure and lastly deploy to environments (while leveraging Artifactory for built artifacts).  This has been working well (using the underpinnings of Maven (binary repositories, dependency resolution, version management) while still having the flexibility to support the IBM IIB requirements through Gradle custom Plugins.

We recently started to use the Gradle Daemon to help with startup/performance.  However this can cause you issues with locked (Windows Workstation) files within your Maven local repository.

How we enabled the Daemon for performance…

To enable the Gradle Daemon we enable a property within the file “org.gradle.daemon=true”

Issue we observed

When trying to delete jar files from our local Maven <userdir>/.m2/repository windows would report that the file cannot be deleted because the file was being used by another process.

By default the Gradle Daemon will terminate after 3 hours of inactivity.  But for my testing I needed to release the file, so I was able to run the following command that released the file lock.

gradle –stop

After running the command the output terminal displayed

$ gradlew –stop
Stopping daemon(s).
Gradle daemon stopped.

That worked! and we were able to delete our files for testing…

Gradle Plugins — How to create your own in minutes

I have been recently migrating my Gradle script logic into Gradle Plugins, so I can use Test Driven Development.

For those who are familiar to Maven, and the notion of Maven Archetypes (in short allows you to repeatably and quickly stand up a project using a customizable project structure) you will be a little disappointed (however there are discussions to implement within Gradle) as it is not supported with version 2.6 or earlier.

Not the end of the world though!  There is a great community project that addresses the issue quite nicely.  See a quick demo below:


build.gradle contents

buildscript {
    repositories {
        maven {
            url ''
    dependencies {
        classpath 'gradle-templates:gradle-templates:1.4.1'
apply plugin:'templates'
task wrapper(type: Wrapper) {
    gradleVersion = '2.6'

The following are a list of options when you run the “gradlew tasks” command:

  • createGradlePlugin - Creates a new Gradle Plugin project in a new directory named after your project.
  • createGroovyClass - Creates a new Groovy class in the current project.
  • createGroovyProject - Creates a new Gradle Groovy project in a new directory named after your project.
  • createJavaClass - Creates a new Java class in the current project.
  • createJavaProject - Creates a new Gradle Java project in a new directory named after your project.
  • createScalaClass - Creates a new Scala class in the current project.
  • createScalaObject - Creates a new Scala object in the current project.
  • createScalaProject - Creates a new Gradle Scala project in a new directory named after your project.
  • createWebappProject - Creates a new Gradle Webapp project in a new directory named after your project.
  • initGradlePlugin - Initializes a new Gradle Plugin project in the current directory.
  • initGroovyProject - Initializes a new Gradle Groovy project in the current directory.
  • initJavaProject - Initializes a new Gradle Java project in the current directory.
  • initScalaProject - Initializes a new Gradle Scala project in the current directory.
  • initWebappProject - Initializes a new Gradle Webapp project in the current directory.