In order to add default JVM options to our Maven mvn command we can define an environment variable MAVEN_OPTS. But we can also create a file jvm.config in the directory .mvn in our project root directory. On each line we define a Java option we want to apply. We can specify JVM options, but also Java system properties we want to apply each time we run the mvn command. This directory and file can be added to our source control so that all users that have access to the repository will use the same JVM options.
Continue reading →
A version catalog in Gradle is a central place in our project where we can define dependency references with their version or version rules. We can define a version catalog using an API in our build file, but we can also create an external file where we define our dependencies and version. In our dependencies section we can refer to the names in the version catalog using a type-safe accessor (if we use Kotlin for writing our build script) with code completion in a supported IDE (IntelliJ IDEA). If we want to share a version catalog between projects we can publish a version catalog to a Maven repository with a groupId, artifactId and version.
Continue reading →
Since Spock 2.1 we have 2 new operators we can use for assertions to check collections: =~ and ==~. We can use these operators with implementations of the Iterable interface when we want to check that a given collection has the same elements as an expected collection and we don’t care about the order of the elements. Without the new operators we would have to cast our collections to a Set first and than use the == operator.
Continue reading →
If you are familiar with the layers architectural pattern, it is only a small step to the even nicer hexagonal pattern. Here is an example of how you can do it.
Continue reading →
A Software Bill of Materials (SBOM) is a broad inventory of all components, libraries, and other third-party assets used in a software application.
It’s a detailed list of all the components that go into the software, much like a recipe lists the ingredients needed to prepare a dish.
Continue reading →
We’ll compare some code written with Either with similar code written using Exceptions and see how they are the same and how they differ.
Continue reading →
WireMock is a stub framework that helps you create stubs for outgoing HTTP traffic during your tests.
Most people use WireMock in their test suite during build time of the application.
Spin up the WireMock server, configure some stub rules, run the application tests, and tear everything down.
This is a good way of testing your HTTP clients, using real traffic towards an external server.
Continue reading →
The chunked extension method is added to the Iterable Java class and makes it possible to split an interable into fixed sized lists. We define the size of the lists as argument to the chunked method. The return result is a list of lists. Each of the lists will have the number of elements we have specified as argument. The last list can have less elements if the total number of elements cannot be divided exactly by the size we specified as argument. We can specify a lambda transformation function as second argument. The lambda function has the new sublist as argument and we can write code to transform that sublist.
Continue reading →
The method partition is available in Kotlin for arrays and iterable objects to split it into two lists. We pass a predicate lambda function to the partition method. The predicate should return either true or false based on a condition for each element from the array or iterable. The return result is a Pair instance where the first element is a List object with all elements that returned true from the predicate. The second element in the Pair object contains all elements for which the predicate returned false. As a String can be seen as an iterable of characters we can also use partition on a String instance.
Continue reading →
Developer experience, or DX for short, describes the overall feelings and perceptions a developer has while interacting with a language, tool or technique.
The easier it is for a developer to work with the language, tool or technique the higher their sense of DX is.
In this blog, I will briefly touch on DX but will also focus on experience in a broader meaning within software engineering.
Continue reading →