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.

Make the wrapper the default in IntelliJ when generating the project files with Gradle

When generating the project files for IntelliJ with Gradle (e.g. gradle idea), the default makes IntelliJ ask about an existing Gradle project and defaults to the local Gradle version. Since the project is generated already via Gradle the point is moot and defaulting to the wrapper is the most sensible default.

Gradle allows manipulation of the generated files of the idea plug-in. It's easy to compare the XML file <project>.ipr before and after the changes are made from IntelliJ. Extract the XML fragment and store it (e.g. in gradle/idea/gradleSettings.xml):

<component name="GradleSettings">
        <option name="linkedExternalProjectsSettings">
                <GradleProjectSettings>
                        <option name="distributionType" value="WRAPPED" />
                        <option name="externalProjectPath" value="$PROJECT_DIR$" />
                        <option name="modules">
                                <set>
                                        <option value="$PROJECT_DIR$" />
                                </set>
                        </option>
                </GradleProjectSettings>
        </option>
</component>

Add in your build.gradle the code to append this chunk:

idea {
        project.ipr {
                withXml { provider ->
                        // set local wrapper via gradle settings
                        provider.node.append(new XmlParser().parse(file("gradle/idea/gradleSettings.xml")))
                }
        }
}

So close to a tweetable Springboot Vaadin application

Springboot allows you to run a Groovy script with nearly no ceremonial boilerplate code around it from command line (e.g. just annotate a Groovy class with @RestController). For quick GUI tests this would be great. Right now, sadly it needs alot boilerplate...

@Grapes([
@Grab('org.vaadin.spring:spring-boot-vaadin:0.0.5.RELEASE'),
@Grab('com.vaadin:vaadin-server:7.4.1'),
@Grab('com.vaadin:vaadin-client-compiled:7.4.1'),
@Grab('com.vaadin:vaadin-themes:7.4.1'),
])
import org.vaadin.spring.annotation.VaadinUI
import com.vaadin.server.VaadinRequest
import com.vaadin.ui.*

@VaadinUI
class MyUI extends UI {
        protected void init(VaadinRequest request) {
                setContent(new Label("Hello World"))
        }
}

Store as vaadin.groovy and run with spring run vaadin.groovy (or even with spring run vaadin.groovy --watch to make it reload automatically). Then navigate your browser to http://localhost:8080.

spring-boot-vaadin pulls in the autoconfiguration for Springboot. And the themes and client-compiled are needed for the theme and the widgetset. server is for having the proper versions (or else we get the transitive ones from the plugin)

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.