SDKMAN! is a very useful tool to manage versions of so-called software development kits. There are a lot of SDKs supported by SDKMAN!: Java, Groovy, Kotlin, Scala, Gradle, Maven, Leiningen, Micronaut, Grails, Vert.x, JBake, AsciidoctorJ and more. When we look at Java we can use a simple install java <version>
command from the command-line to install a version of Java on our computer. SDKMAN! will take care of downloading the Java version and setting all the correct system variables to use that Java version. With the use
command we can switch between version in the current shell we are working in. But we can even automatically switch to a specific installed Java version when we enter a directory. This is very useful when we have to work on multiple projects on our computer and each project requires a specific Java version to be used.
To support automatic switching of a Java version we must first run the env init
command in the directory of our project. This creates a new file .sdkmanrc
in the directory. The file contains the Java version that was active when we invoked the env init
command. It is a text file so we can change the Java version in the file, or regenerate the file by running the env init
command again, but with a different active Java version.
Continue reading →
Kotlin data classes and annotations go really well together, but it is easy to mess it up.
Continue reading →
When dealing with Maps in Kotlin, sometimes we’re only interested in entries for which the value is not null
.
Although the Kotlin Standard Library contains a filterValues
function that seems to be appropriate, this function
does not do any type conversions, resulting in a Map
which won’t contain null
values,
but is still a Map with values of a nullable type according to the compiler. There is a feature request
for the JetBrains team to add this functionality, but for now it has not been implemented (yet?).
Continue reading →
To find the maximum or minimum value for numeric values we can use the max
and min
function. The functions accept one or more numeric arguments and the value that is maximum or minimum is returned. If the numbers are already in a sequence we can use apply max
or apply min
. If the values are not numbers we can use the max-key
or min-key
functions. These functions take as first argument a function that returns a number. So we can get the value that has the maximum or minimum return value for the function we pass as first argument.
In the next exmaple code we use the max
, min
, max-key
and min-key
functions:
Continue reading →
Lamda expressions were introduced in Java 8 and have been around for a while.
They are in my opinion one of the better features of Java 8, allowing for a more functional approach to writing code, and thus enabling most of the java 8 features.
So let’s take a closer look at lambda’s and see what they are, how to reason about them, and why they are a good addition.
Continue reading →
Until recently I’ve found unsubscribing to be a confusing subject. Apparently, you have to unsubscribe if you want to avoid memory leaks. But NOT doing so doesn’t always result in a memory leak. So what causes these leaks and how can we avoid them?
Continue reading →
Building Event Driven systems is great, but not all systems are Event Driven. Communication with those systems can be via HTTP and those systems may not be able to respond quickly to a request, taking up to minutes to serve a response.
Are there tools to mock such a situation to be used for testing?
When a system takes up to minutes to respond to a request, it is possible to first respond technically to the request and later respond functionally.
The other system can POST
the functional response.
Then the response is asynchronously served.
Continue reading →
In every organization and in every team, I run into one or two customs that people tell me are part of "Scrum by the
book", that aren’t actually in the book.
Continue reading →
Locally deployed clusters can be a convenient part of a modern software development cycle, reducing feedback loops and give a developer a useful representation of the live version of an app, even if it’s just a stub. Unfortunately, they have a reputation for eating up your precious resources like they’re mashed taters. Since this year working from a home office has become the norm for many developers around the world. Enter the home desktop to "share the load" with our brave little work laptop. We will form a fellowship with our loyal home desktop, to help us through this new and uncertain adventure. Keep reading to find out how we can take off and escape this "Mount Doom" scenario!
Continue reading →
In a previous post we learned how to replace a file in an archive with Gradle.
In this blog post we use Maven to achieve the same goal.
With Maven we first have to extract the contents of the archive and then assemble a new archive where we use a file replacement to replace an original file from the archive.
To extract the contents we use the task unzip
with the maven-antrun-plugin.
To create a new archive we use the maven-assembly-plugin.
The destination directory of the extracted contents is the input fileset for the assembly definition together with the files we want to overwrite.
The end result is a new archive with replaced files.
In the following pom.xml
we configure the maven-antrun-plugin and maven-assembly-plugin:
Continue reading →
Sometimes we might need to replace one or more files in an existing archive file. The archive file could be a zip, jar, war or other archive. Without Gradle we would unpack the archive file, copy our new file into the destination directory of the unpacked archive and archive the directory again. To achieve this with Gradle we can simply create a single task of type Zip
. To get the content of the original archive we can use the project.zipTree
method. We leave out the file we want to replace and define the new file as replacement. As extra safeguard we can let the tsak fail if duplicate files are in the archive, because of our replacement.
The following code shows an example of a task to replace a README
file in an archive sample.zip
using Groovy and Kotlin DSL. First the Groovy DSL:
Continue reading →
At my current customer we use Github a lot.
Everything requires a review via a Pull Request.
It is sometimes tedious to switch from your IDE or terminal to the browser while creating a PR.
Github has a command line utility called gh
which you can use to automatically create a PR from the command line.
It has lots of extra stuff as well, such as downloading releases, viewing issues, creating gists, cloning repo’s and code completion.
Start by following the installation steps in https://github.com/cli/cli to install the gh binary.
There are packages for all operating systems.
Continue reading →