Posts by Sander Smeman

Reduce the code to noise ratio of maven POMs

Posted on by  
Sander Smeman

I really like maven for the structured way it provides for defining and building a project. But sometimes I wish for a less verbose notation than the XML of the Project Object Model (POM). For example, gradles dependency notation is far shorter than mavens dependency declaration. Looking for a less verbose way to declare a maven POM, I discovered polyglot maven. It are maven extensions that allow the maven POM to eb written in another dialect than XML. Since you see YAML more and more I decided to try that dialect, and see if my maven descriptor would be clearer.

  1. Create a directory to work in, {projectdir}, and change into it.

  2. To register the extensions for maven, create a file {projectdir}/.mvn/extensions.xml and add the extension:

  3. Now it’s possile to write the maven POM in YAML, {projectdir}/pom.yml:

    By using the yaml inline map. or dictionary notation declaring a dependency uses way less characters then when using XML.

Continue reading →

Easily build your own tech radar

Posted on by  
Sander Smeman

The Thoughtworks Technology Radar is well known for showing technology trends and choices. For my project I wanted to have the same thing, not use the hosted public version from Thoughtworks, but a selfhosted option. Therefore I choose to base it on the Zalando opensource tech radar, and create a way to use a CSV file as input so updating would be an easy thing to do. To accomplish that I took the following steps:

  1. Create a folder to put the tech radar into: ${project-folder}.

  2. Start with the HTML5 Boilerplate index.html file and put it into the ${project-folder} file.

  3. Insert the snippets as documented at Zalando Tech Radar, with one adjustment. I don’t fill the entries array with entries, but will do that later on, from the input in the CSV file. Note the names of the rings and quadrants, as they will be used in the next step, the CSV.

  4. Create a CSV file (${project-folder}/data.csv) as input for the tech radar. It has columns for the ring and quadrant where a technology should be put, and an indicator for movement. The names of the rings and quadrant should equal those in the configuration copied from the Zalando example. If you changed them, use those names instead. The movement indicator is (up, none, down) and in the next step translated in to value understood by the radar. The CSV will be translated into entries for the radar.

  5. Add the following D3.js library to parse CSV:

    This library provides functions to parse CSV file(s) into a map structure per row in the file.

  6. Create a function to transform a row in the CSV into an entry for the tech radar:

  7. This is the diversion from the steps in the Zalando tech radar description. Wrap the radar_visualization() function a custom one, that takes an array of entry, to render the transformed rows, e.g. draw_radar(entries).

  8. Finally glue everything together to fetch the CSV, parse and transform it, and draw the entries. The code below uses the functions I defined in the previous steps

    When you have followed the above steps, the result should look like this:

Continue reading →

Combining Spock and JUnit 5 tests

Posted on by  
Sander Smeman

Great projects keep moving forward. JUnit5 is available since September 2017 and Spock 1.2 is already complete. Since Spock is based on JUnit4, I wondered what it would take to use Spock 1.2 together with JUnit5.

As it turns out, it’s quite easy to make that happen. JUnit5 comes with the vintage engine to run JUnit4 based tests. If that is available on the test classpath, your Spock tests run like on JUnit4.

Continue reading →