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.

Pass system properties down to Springboot in IntelliJ and Gradle

The most straight forward way to pass down Springboot config settings while developing to Gradle tasks is by environment variable (at least for me). E.g.:

SPRING_PROFILES_ACTIVE=dev gradle bootRun

Since IntelliJ does not allow passing environment variables down to Gradle tasks this does not work there. Thanks to Gradle we can make system properties available for tasks:

bootRun.systemProperties = System.properties

This way we can set in IntelliJ VM Options like -Dspring.profiles.active=dev for Gradle tasks.

Pattern for the Vat ID

According to Wikipedia:

@Pattern(regexp=/(ATU[0-9]{8})|(BE0[0-9]{9})|(BE[0-9]{10})|(BG[0-9]{9})|(BG[0-9]{10})|(CY[0-9]{8}L)|(CZ[0-9]{8,10})|(DE[0-9]{9})|(DK[0-9]{8})|(EE[0-9]{9})|(EL[0-9]{9})|(ESX[0-9]{7}X)|(FI[0-9]{8})|(FRXX[0-9]{9})|(GB[0-9]{9})|(GB[0-9]{12})|(GBGD[0-9]{3})|(GBHA[0-9]{3})|(HR[0-9]{11})|(HU[0-9]{8})|(IE[0-9]S[0-9]{5}L)|(IT[0-9]{11})|(LT[0-9]{9})|(LT[0-9]{12})|(LU[0-9]{8})|(LV[0-9]{11})|(MT[0-9]{8})|(NL[0-9]{9}B[0-9][0-9])|(PL[0-9]{10})|(PT[0-9]{9})|(RO[0-9]{9})|(SE[0-9]{12})|(SI[0-9]{8})|(SK[0-9]{10})/)

Excluding deps in configurations, added by plugin, in gradle

The gradle-vaadin-plugin adds its configurations, that later get used to gather the deps for the client compile run, when it runs. So one can not safely create configs and exclude deps there beforehand. But gradle let's you do even this at a later time. This fragment gets rid of springboot-starter-web, as this pulls in java-validation 1.1, which won't compile the client due to GWT restrictions.

project.afterEvaluate {
        configurations.'vaadin-client' {
                exclude module: 'spring-boot-starter-web'
        }
}

See my springboot-groovy-vaadin-starter

Helper to search maven central from command line

If the query contains a : search for all version otherwise do a regular search for latest versions

assert args.size()==1, "Missing parameter"
def q=args[0]
if (q.contains(':')) {
    def (g,a) = q.split(':')
    q = "g:\"$g\"+AND+a:\"$a\"&core=gav"
}
def result = new groovy.json.JsonSlurper().parseText(
    "http://search.maven.org/solrsearch/select?q=$q&wt=json&rows=50".toURL().text
)
result.response.docs.each {
    println "compile '$it.g:$it.a:${it.latestVersion?:it.v}'"
}