All posts with tag groovy

Groovy 3 @NullCheck annotation - less code and less NPE

Groovy 3 helps you write less, but more secure code. Today I want to show you one of the features added in the latest release - @NullCheck annotat...

Groovy 3 String GDK improvements - takeRight, takeBetween, and a few others

Groovy 3 was released a few days ago[1], and it introduced a lot of important new features to the language. Today I want to show you a few useful ...

Jenkins Scripted Pipeline vs. Declarative Pipeline - the 4 practical differences

If you read this blog post, there is a high chance you’re looking for information about practical differences between scripted and declarati...

Three Groovy String methods that will make your life Groovier!

Groovy String API offers many useful methods to make working with strings much more pleasant. Today I would like to show you three, not so very po...

Quicksort in Groovy - can it be as fast as implemented in Java?

I started reading "Cracking the Coding Interview, 6th Edition" book recently and it inspired me to experiment a bit. It’s been a w...

Building Java and Maven docker images using parallelized Jenkins Pipeline and SDKMAN!

In the last article, I have shown you how you can build a docker image for Jenkins Pipeline using SDKMAN! command-line tool. Today I will show you...

Using SDKMAN! as a docker image for Jenkins Pipeline - a step by step guide

A few days ago, I was struggling with some Docker images I use in my Jenkins CI environment. I run some Jenkins Pipelines, and I like to define bu...

Jenkins Pipeline Environment Variables - The Definitive Guide

Have you run into troubles when you started using Jenkins Environment Variables in your Jenkinsfile? In this blog post, I show you how to use envi...

Groovy Trampoline Closure - a step into recursive closures

A few weeks ago an interesting question was asked on the StackOverflow. Someone experimented with a recursion in Groovy and stepped into Closure.t...

GR8Conf EU 2019 Recap

It’s been a week since GR8Conf EU 2019 is over, so it is the right time to write some recap of this outstanding event. It was my first time ...

GR8Conf EU 2019 - what can you expect from my talks?

GR8Conf EU 2019 starts precisely in 13 days (on May 27th). Each year Copenhagen becomes a heart of Groovy vibrant community for 3 days. The confer...

Spock random order of tests - how to?

Spock Framework executes test methods (features) in a single class (specification) in the declaration order. There is nothing wrong in this defaul...

Using the same prefix with different HTTP methods in Ratpack

Ratpack is an excellent tool for building RESTful[1] applications. However, to benefit most of it, we need to know the tool a little bit better. I...

Groovy Regular Expressions - The Benchmark (Part 2)

In the second part of the "Groovy Regular Expression" blog post, I want to show you some benchmarks. And let me make one thing clear - the followi...

Groovy Regular Expressions - The Definitive Guide (Part 1)

Welcome to "Groovy Regular Expressions - The Definitive Guide"! In the next 15 minutes, you are going to learn everything you need to start workin...

How to remove any class annotation with Groovy compiler configuration script?

One of the most interesting Groovy features is its ability to configure advanced compiler[1] options using DSL script. It becomes handy when you w...

GraalVM native image inside docker container - does it make sense?

We have learned how to create GraalVM native image from standalone Groovy script in the previous blog post. Today we continue the experiments, and...

GraalVM with Groovy and Grape - creating native image of a standalone script

The Apache Groovy programming language has extraordinary scripting capabilities. When you combine it with the Grape dependency management system, ...

Programming Groovy 2 - book review

When I get the paperback copy of the "Programming Groovy 2" book back in the June 2017, I was wondering if I can find something new or exciting in...

Spock assertion inside if-statement doesn't work - why?

Spock Framework is one of my favorite tools in the Groovy ecosystem toolbox. It makes writing automated tests a few times more pleasant thanks to ...

JUnit Assume.assumeNotNull(obj) throws NullPointerException in Groovy - what's wrong?

Ignoring some of the unit tests when given conditions are not satisfied is a handy feature of a JUnit framework. I guess you have used many times ...

List of combinations from a list of lists in Groovy

Groovy has many useful functions built-in, and one of them is Iterable.combinations() that takes aggregated collections and finds all combinations...

Tail-recursive methods in Groovy

Most of the object-oriented programmers prefer constructing algorithms using imperative style over using recursion. This is pretty obvious in the ...

How to avoid "No tests were found" when using JUnit 5 with Groovy?

In this short blog post I would like to explain how to avoid popular mistake when you write your first JUnit 5 test case in Groovy.

GraalVM and Groovy - how to start?

GraalVM became one of the most popular topics in the JVM ecosystem. It promises the highest possible speed of running JVM-based programs (when com...

What is the most efficient way to iterate collection in Groovy? Let's play with JMH!

I guess you may heard about Groovy’s Collection.each(Closure cl) method - it was introduced 15 years ago [1] and it was a great alternative ...

How Groovy's equal operator differs from Java?

One of the first mistakes people do when starting their journey with Java programming language is using == to compare objects instead calling a.eq...

Groovy: static propertyMissing and methodMissing methods - limitations and possible issues

Some time ago I have found another interesting Groovy related question on Stack Overflow. This time someone was asking about static variants of po...

Groovy: dynamic types coercion and promotion - you have been warned!

Groovy is a very powerful language on a JVM platform and with this great power comes great responsibility. There are many language features that a...

How to name Groovy script file?

Some time ago I have found a very interesting question on Stack Overflow about forbidden characters in Groovy script filenames. Let’s use it...

Groovy: split string and avoid getting IndexOutOfBoundsException

If you use Groovy for scripting or other similar tasks you probably faced a situation where you get an input as a text and you need to process it ...

Ratpack: register SessionModule in handler unit test

Unit testing Ratpack handlers has many benefits. In the previous post we have learned how to mock Session object to use it with GroovyRequestFixtu...

Ratpack: mocking Session object in GroovyRequestFixture test

Ratpack allows you unit test handlers using GroovyRequestFixture class. The good thing about this approach is that it does not require running the...

Groovy script: closure does not modify @Field annotated variable

Recently I have answered a few questions on Stack Overflow related to Groovy scripts and how they work in combination with closures and delegated ...

Why "grails package" executes Config.groovy file?

This blog post is inspired by one of my recent Stack Overflow answers to following question: Grails: why is the Config.groovy file executed during...