Skip to main content

Open Source Consultant, Software Developer and System Administrator

If you are interrested in hiring a consultant for the effective use of open source software on an enterprise grade, take a look around in the About section to see, what I have to offer.

Blog and snippets

Various snippets or code parts I found useful, so I keep them here for reference.

Minimalistic Gradle build.gradle file for Groovy projects

apply plugin: 'groovy'

repositories {
        jcenter()
}

dependencies {
        compile 'org.codehaus.groovy:groovy-all:2.3.+'
}

and for Spring Boot

buildscript {
        repositories {
                jcenter()
        }
        dependencies {
                classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.0.2.RELEASE'
        }
}

apply plugin: 'groovy'
apply plugin: 'spring-boot'

repositories {
        jcenter()
}

dependencies {
        compile 'org.codehaus.groovy:groovy-all:2.3.+'
        // e.g. compile("org.springframework.boot:spring-boot-starter-web")
}

Add an expression dialect to thymeleaf to access groovy's collate

Easy way to add collate for separting lists into rows with a certain size

class Groovy {
    List<List> collate(List list, Integer columns) {
        return list.collate(columns)
    }
}

class GroovyDialect extends AbstractDialect implements IExpressionEnhancingDialect {

    @Override
    Map<String, Object> getAdditionalExpressionObjects(IProcessingContext processingContext) {
        return [ groovy: new Groovy() ]
    }

    @Override
    String getPrefix() {
        return "groovy"
    }
}

Add dialects to TemplateEngine (code based approach), see additionalDialects in XML:

def templateEngine = new TemplateEngine().with{
    // ...
    setAdditionalDialects([new GroovyDialect()] as Set<IDialect>)
    return it
}

Use in template:

<div th:each="row : ${#groovy.collate(entries, 4)}" class="row-fluid">
    <ul class="thumbnails">
        <li th:each="entry : ${row}" class="span3">
            <div class="thumbnail">...</div>
        </li>
    </ul>
</div>

Run(-app) Grails 2.3 non-forked with reloading in IntelliJ 12

Add these VM options to the run-app to get class reloading working in IntelliJ 12

-javaagent:${GRAILS_HOME}/lib/org.springframework/springloaded/jars/springloaded-1.1.5.RELEASE.jar -Xverify:none  -noverify -Dspringloaded.synchronize=true -Djdk.reflect.allowGetCallerClass=true -Dspringloaded=profile=grails;cacheDir=/tmp/slcache

Note, that the version (1.1.5) depends on your Grails version (this is for 2.3.7) and the cache location is changed to /tmp/slcache - the default is ~/.grails/<verison>/.slcache).