Posts by Hubert Klein Ikkink

Gradle Goodness: Passing Environment Variable Via Delegate Run Action In IntelliJ IDEA

Posted on by  
Hubert Klein Ikkink

IntelliJ IDEA 2016.3 introduced the option to delegate the run action to Gradle . This means when we have a run Configuration for our Java or Groovy classes we can use the Run action and IDEA will use Gradle to run the application. Actually IntelliJ IDEA creates a new task of type JavaExec dynamically for our specific run configuration with the main property set to the class we want to run.

In the Edit Configuration dialog window we can set the command line argument and Java system properties. These are passed on to the dynamically created JavaExec task and are accessible from within the class that runs. The environment variables that can be set in the Edit Configuration dialog windows are not passed to the JavaExec task configuration. But we can do it ourselves in the build script file of our project. We look for the dynamically created task and use the environment method to add a environment variable that can be access in the Java or Groovy class that is executed.

Continue reading →

Awesome Asciidoctor: Change Number Style For Ordered Lists

Posted on by  
Hubert Klein Ikkink

To write a (nested) ordered lists in Asciidoctor is easy. We need to start the line with a dot (.) followed by a space and the list item text. The number of dots reflects the levels of nesting. So with two dots (..) we have a nested list item. By default each nested level has a separate numbering style. The first level has arabic numbering, the second lower case alphanumeric, the third upper case alphanumeric, the fourth lower case roman and the fifth (which is maximum depth of nested levels in Asciidoctor) has style upper case roman. But we can change this by setting a block style for each nested level block. The name of the block style is arabic, loweralpha, upperalpha, lowerromann or upperroman. With the HTML5 backend we can also use decimal and lowergreek.

In the following example we have an ordered list where we set different block styles for the nested level:

Continue reading →

PlantUML Pleasantness: Using Current Date

Posted on by  
Hubert Klein Ikkink

In PlantUML we can use the special variable %date% to get the current date and time. The default format shows day of the week, date, time and timezone. We can change the date format by specifying our format with the Java SimpleDateFromat symbols. For example to only get the hours and minutes we would write %date[HH:mm]%.

In the following example we use the %date% variable as is and with a custom format:

Continue reading →

Grails Goodness: Writing Log Messages With Grails 3.2 (Slf4J)

Posted on by  
Hubert Klein Ikkink

Grails 3.2 changed the logging implementation for the log field that is automatically injected in the Grails artefacts, like controllers and services. Before Grails 3.2 the log field was from Jakarta Apache Commons Log class, but since Grails 3.2 this has become the Logger class from Slf4J API. A big difference is the fact that the methods for logging on the Logger class don’t accepts an Object as the first argument. Before there would be an implicit toString invocation on an object, but that doesn’t work anymore.

In the following example we try to use an object as the first argument of the debug method in a controller class:

Continue reading →

PlantUML Pleasantness: Check If PlantUML Is Up To Date

Posted on by  
Hubert Klein Ikkink

With the command line option -checkversion we can see if we have the latest PlantUML version. The command prints to the console our current PlantUML version and latest version that is available. Inside a PlantUML definition we can use the command checkversion and generate for example a PNG image with information about our PlantUML version and the latest version that can be downloaded.

First we use the command line option -checkversion for an out-of-date version:

Continue reading →

PlantUML Pleasantness: Generate Graphical Version Information

Posted on by  
Hubert Klein Ikkink

If we want to know which version of PlantUML we are using we can use the command line option -version. PlantUML will print the version and also some extra information like the machine name, memory and more. But we can also create a PlantUML definition with the command version and we can transform it to a graphical presentation like a PNG image. This can be handy if we use PlantUML in an environment like Asciidoctor with diagram support and we want to know which version of PlantUML is used.

In our first example we run PlantUML from the command line and use the -version option:

Continue reading →

PlantUML Pleasantness: Create A Sudoku :)

Posted on by  
Hubert Klein Ikkink

PlantUML has a fun command to create a Sudoku puzzle. We must use sudoku in our PlantUML definition and a random puzzle is generated. We can even give a seed value for a given Sudoku so it is generated again. In the following example PlantUML definition we use the sudoku command:

@startuml
sudoku
@enduml

Continue reading →

PlantUML Pleasantness: Include Partial Content From Files

Posted on by  
Hubert Klein Ikkink

With PlantUML we can include external files in our definition with the !include directive. We specify the file name and the content is included in our PlantUML definition. The included file can also have multiple @startuml ... @enduml sections and we can refer to individual sections with the !include directive. We must append to the include file name an exclamation mark (!) followed by either a number or identifier. If we use a number we specify which section we want to include, where section are numbered starting from 0. So to get the second section from a file commons.puml we would write !include commons.puml!1. Alternatively we can use identifiers in the include file. We append to @startuml an identifier as (id=idValue). Then from the definition that is including the file we refer to the identifier after an exclamation mark (!). If our included file commons.puml has a section with id user then we would include it as !include commons.puml!user.

In the following example PlantUML definition we define the file to be included. We have two sections with @startuml ... @enduml which both have an identifier:

Continue reading →

PlantUML Pleasantness: Customize Stereotype Styling

Posted on by  
Hubert Klein Ikkink

To change the styling of our generated diagrams with PlantUML we can use the skinparam command. We can set for example font size, style, color, background colors and much more. We can change the style for a specific element or for the whole diagram. We can even set specific styling options for stereotypes. The settings for the stereotype are then applied to all elements in our diagram with that stereotype. We must append <<stereotype name>> to the skin parameter name.

In the following example PlantUML description we apply custom background colors to each stereotype:

Continue reading →

PlantUML Pleasantness: Keeping Elements Together

Posted on by  
Hubert Klein Ikkink

When we write a PlantUML definition the generated graphical diagram is laid out by PlantUML. In a previous post we learned how to move elements using the length of the connection. But we can also use a together block with all elements that should be at the same level. PlantUML will try to keep the elements together when the diagram is drawn.

In the following sample PlantUML definition we want the PostgresDB and Mail elements to be at the same level, so we group them using a together block:

Continue reading →

PlantUML Pleasantness: Diagrams In Black And White

Posted on by  
Hubert Klein Ikkink

The default colors of PlantUML use red and yellow to draw the diagram elements. If we want our diagram to be in black, grey and white we can simply set skin parameter monochrome to true. The generated graphical diagram will now have black, grey and white colors.

In the following sample PlantUML definition we set the diagram skin parameter monochrone to true:

Continue reading →

shadow-left