Services development

Over the past six to nine months I've been gravitating toward services development in Java. Having worked in .NET/C# for most of the past dozen years, I have had to enable my frustration shielding as I learned not just a new language but mostly a new set of development, debugging, build and deployment tools. The ride has been bumpy at times, exhilarating at others but in the final analysis is a great move for my career.

At New Relic, we develop the full-stack: web front-end, including lots of interactivity, a distributed, scalable infrastructure of services, data querying and analysis systems, mobile applications, agents, and lots of internally-used tools. Except for our .NET agent and our Azure portal integration, our choice of environment and tools is all Linux-based. As I've learned how to navigate in this new universe, it's been motivating to see how other, longer-established SaaS companies like LinkedIn, Twitter, Facebook and Google, develop open-sourced tools and frameworks that are adopted widely throughout the industry. Being part of New Relic's incredible engineering team gives me the chills sometimes!

Those of you who have read earlier posts in this blog have heard me say that I'm studying Data Science through the Johns Hopkins Data Science Specialization available on Coursera. I completed several of those courses and have even used R to do some exploratory data analysis of timeslice data at New Relic. I do not expect to be doing data analysis on anything close to a full-time basis, as I focus more on services and other utility development in my job. That doesn't mean I won't write some R scripts. I may even create an R package someday! Having the functional, data-science-oriented R language in my tool belt will help me to see data in more dimensions (see how I did that?). I'll try to get a post in once in a while on some data analysis topics.


When I developed my first Java service, I spent a lot of time reading other people's code and trying to get my head around the tooling. One of the first tools I ran into (head-on) was Gradle.

Gradle is great for integrating with other tools, including code actions in your declarative build file, dependency management and build reporting. It also has a lot of online documentation, although it is often difficult to find the answer to your question. Stack Overflow helps but I've recently decided that I need to fully understand what is really going on with Gradle, Groovy (the language used in Gradle build files and how Gradle plug-ins work. So I've downloaded some free books, purchased the highly-recommended Gradle In Action. Away I go!

The Build Lifecycle

A Gradle build is broken down into three phases:

  1. Initialization: what is to be built
  2. Configuration: creation of the build object model
  3. Execution: execution of the build actions

A Gradle Task can have both a Configuration and an Execution lifecycle. A Gradle Task is created using Groovy closures as shown below:

task initDatabase
initDatabase { }
initDatabase << { println 'Adding preset time data' }
initDatabase << { writeTimeRelativeData }

The task name is initDatabase. During the configuration phase of the build lifecycle, the script will be run. By not using the overloaded << operator, and using the curly braces, that script is considered part of the configuration. All configuration sections are run for a build regardless of whether their corresponding task execution sections are run.

The two code blocks following the << operators are put into the execution phase of the task.

Well, that's enough for today. It's the 4th of July anyway, isn't it? Got to help my better half get ready for a dinner party.