Enable support for java.time.* with Jackson-jr

Jackson-jr is super neat, but does not (yet) support serialization of java.time.* (e.g. java.time.LocalDate, LocalDateTime) out-of-the-box. However, it is actually super easy to extend it. My example is in Groovy, but it will also work in Java if you add some boilerplate code such as “;”. First create some utility class to encapsulate the Jackson-jr […]

CodeNarc 1.5 with Grails 4

When I bumped CodeNarc from 1.4 to 1.5 at my Grails 4.x project, I kept getting the “groovy/text/TemplateEngine” error which is reported here: https://github.com/CodeNarc/CodeNarc/issues/449 The suggested solution was not too clear, so here is exactly what you gotta do – add the following to build.gradle: codenarc “org.codenarc:CodeNarc:${codenarc.toolVersion}” codenarc ‘org.codehaus.groovy:groovy-templates’

Adding @GrailsCompileStatic to all production grails code (not test grails code)

When coding Groovy, @CompileStatic can help to spot errors and improve performance of production code. Unfortunately, @CompileStatic is optional and hence easy to forget, but thankfully Groovy has documented a way to make @CompileStatic for all production code: http://docs.groovy-lang.org/latest/html/documentation/#_static_compilation_by_default (Test code is not affected, because it is nice with flexibility when testing.) However, with Grails […]