Creating slides like a boss
It was Paul’s first conference ever,
a little nervous he went from home.
Hopped on a train and entered the building,
stepped so in the unknown.
It was Paul’s first conference ever,
a little nervous he went from home.
Hopped on a train and entered the building,
stepped so in the unknown.
Groovy 4 added some built-in macros that we can use in our code. A macro is code that will create new code. It does this by manipulating the Abstract Syntax Tree (AST) before the code is compiled. So when we use a macro, the macro will change the AST and those changes will be compiled. The three built-in macros SV
, SVI
and SVD
can create a GString
instance with the names and values of the variables that are passed as argument. This can be very useful to create some meaningful debugging statements. Normally we would have to type in the variable name ourselves followed by the value. Now with these macros we don’t have to type the variable as the macro will add that to the AST for us.
DataWeave has a nice language feature called literal types. Literal types are types with a single predefined values and can be defined using a String
, Number
or Boolean
value. So the value of a literal type is a fixed value. We can combine multiple literal types into a new type using a union type to define an enumaration in DataWeave. The enumaration can only be one of the literal types used to define it.
Together with overloaded functions literal types are very useful. We can define a function where one of the input arguments is a literal type to define specific behaviour based on the literal type. Then we can overload the function for other literal types with different behaviour. DataWeave will make sure the correct function is called based on the value of the input argument and how it matches to the literal type value.
Groovy supports ranges for a long time. But Groovy 4 adds a new feature for ranges and that is the support for open (exclusive) ranges at the beginning of a range. Open means the number that defines the range is not part of the actual range result and we must use the less-than character (<
). This is also referred to as exclusive, where the value is excluded from the range. When a range is closed the value is included, also called inclusive. Before Groovy 4 we could already define the end of the range to be exclusive or inclusive, but now we can also define the beginning of the range to be exclusive.
Vulnerable and Outdated Components are a top 10 OWASP security threat to applications. To mitigate this risk, there’s a commonly used OWASP dependency-check to scan software to identify the use of known vulnerable components.
In this blogpost we will outline a way to run the OWASP dependency-check for Maven projects on GitLab.com.
Sonarcloud.io is the cloud offering of SonarQube.org. It offers code quality and security scanning, to help developers build maintainable and secure applications. Typically developers install a SonarLint.org plugin in their IDE, for direct feedback. Merge request decoration acts as second line of defence, to ensure no new findings make it past the merge or pull request review.
This blogpost walks you through the steps to setting up Merge request decoration on GitLab.com for Apache Maven projects. There’s a few gotcha’s around setting up merge request decoration, which could lead you to threads like these to debug what you did wrong.
SDKMAN! has a home
command that will return the absolute path of any SDK we pass as argument. This can be useful in scripts where we need the absolute path to a SDK. We can specify the name of the SDK after the home
command and the version. To use the current version that is set as default we can use as version current
.
Groovy 4 introduced support for TOML configuration file. In a previous post we already learned how we can parse TOML content. In this post we will see we can use a builder syntax to create TOML content. We need the class TomlBuilder
and then define our structure using a nice builder DSL. The DSL is comparable to create JSON using the JsonBuilder
. The names of the nodes in the DSL structure will be the names of the properties. Nodes within nodes will result in concatenated property names with the name of each node separated by a dot (.
). We can also use collections as arguments and those will translated to TOML arrays. A collection can optionally be followed by a closure that processes each item in the collection to generate the content for the TOML array.
Since Groovy 4 we can parse TOML configuration data into a Map
. Once the TOML data is transformed into the Map
we can use all possibilities in Groovy to lookup keys and their values in maps. For example we can use GPath expressions to easily get the value of a (nested) key. To parse TOML configuration data we must use the TomlSlurper
class that is in the groovy.toml
package. We can use the parse
method when we have a file, reader or stream with our configuration. To parse a String
value with TOML configuration we use the parseText
method.
Unfortunately Oracle databases aren’t compatible with the new Apple Silicon CPU architecture. Due to this fact you’re not able to run an Oracle XE image with TestContainers on your brand-new MacBook, but there’s a workaround!
TLDR;
Run colima start --arch x86_64 --memory 4
Set TestContainers env vars
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
export DOCKER_HOST="unix://${HOME}/.colima/docker.sock"
Run your tests based on Gerald Venzl's Oracle XE image
Unfortunately Oracle databases aren’t compatible with the new Apple Silicon CPU architecture. Due to this fact you’re not able to run an Oracle XE database on your brand-new MacBook, but there’s a workaround!
TLDR;
Run colima start --arch x86_64 --memory 4
Run the Oracle XE docker image docker run -d -p 1521:1521 -e ORACLE_PASSWORD=<your password> gvenzl/oracle-xe
GINQ (Groovy-INtegrated Query) is added since Groovy 4.
With GINQ we can query in-memory collections with SQL like statements.
If we want to get the row numbers for each row in the query result set we can use the implicit variable _rn
.
We must specify _rn
in the select
expression of our GINQ query. We can even use as
to give it a meaningful name in the result set.