Gradle – simple approach to adding external properties

Working on a project where the team would like to keep the project gradle.properties 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:

ext{
   buildAll=true
}

and now using the property within my script

if(project.hasProperty('buildAll')){
}

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 gradle.properties 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…