JDriven Blog

Grails Goodness: Use Random Server Port In Integration Tests

Posted on by  
Hubert Klein Ikkink

Because Grails 3 is based on Spring Boot we can use a lot of the functionality of Spring Boot in our Grails applications. For example we can start Grails 3 with a random available port number, which is useful in integration testing scenario's. To use a random port we must set the application property server.port to the value 0. If we want to use the random port number in our code we can access it via the @Value annotation with the expression ${local.server.port}.

Let's create a very simple controller with a corresponding integration test. The controller is called Sample:

Continue reading →

Gradle Goodness: Get Property Value With findProperty

Posted on by  
Hubert Klein Ikkink

Gradle 2.13 added a new method to get a property value: findProperty. This method will return a property value if the property exists or null if the property cannot be found. Gradle also has the property method to return a property value, but this method will throw an exception if the property is missing. With the new findProperty method and the Groovy elvis operator (?:) we can try to get a property value and if not found return a default value.

In the following example we have a task that tries to print the value of the properties sampleOld and sampleNew. We use the findProperty for sampleNew and the property method for sampleOld:

Continue reading →

Grails Goodness: Change Version For Dependency Defined By BOM

Posted on by  
Hubert Klein Ikkink

Since Grails 3 we use Gradle as the build system. This means we also use Gradle to define dependencies we need. The default Gradle build file that is created when we create a new Grails application contains the Gradle dependency management plugin via the Gradle Grails plugin. With the dependency management plugin we can import a Maven Bill Of Materials (BOM) file. And that is exactly what Grails does by importing a BOM with Grails dependencies. A lot of the versions of these dependencies can be overridden via Gradle project properties.

To get the list of version properties we write a simple Gradle task to print out the values:

Continue reading →

Mission to Mars follow up

Posted on by  
Jeroen Resoort

Last week I presented my talk 'MISSION TO MARS: EXPLORING NEW WORLDS WITH AWS IOT' at IoT Tech Day 2016 and it was great fun! In the presentation I showed how to build a small robot and control it over MQTT messaging via Amazons IoT platform. The room was packed and the demo went well too. I promised to share some info about it on my blog so here we are. I've composed a shopping list and a collection of useful links: Mission to Mars - Shopping list Mission to Mars - Useful links The original presentation is available here: Mission_to_Mars-Jeroen_Resoort-IoT_Tech_Day.pdf So what's next? I should publish my Pi robot and Mission Control Center web client code on github. Maybe I'll extend the python code for controlling the mBot over a serial connection and make a proper library for it.

Will keep you updated...

Continue reading →

Grasping AngularJS 1.5 directive bindings by learning from Angular 2

Posted on by  
Emil van Galen

In AngularJS 1.5 we can use attribute binding to allow easy use of input-only, output-only and two-way attributes for a directive or component. Instead of manually parsing, watching and modifying attribute values through code, we can simply specify an attribute binding by adding a property to the object hash of:

Continue reading →

Gradle Goodness: Source Sets As IntelliJ IDEA Modules

Posted on by  
Hubert Klein Ikkink

IntelliJ IDEA 2016.1 introduced better support for Gradle source sets. Each source set in our project becomes a module in the IntelliJ IDEA project. And each module has it's own dependencies, also between source sets. For example if we simply apply the java plugin in our project we already get two source sets: main and test. For compiling the test sources there is a dependency to the main source set. IntelliJ now knows how to handle this.

Let's create a sample Gradle build file with an extra custom source set and see what we get in IntelliJ IDEA. In the following example build file we add the source set api. This source set contains interfaces without implementations. The implementations for the interfaces are in the default main source set. Finally we have some tests in the test source set that depend on the classes generated by the api and main source sets.

Continue reading →

Gradle Goodness: Add Spring Facet To IntelliJ IDEA Module

Posted on by  
Hubert Klein Ikkink

To create IntelliJ IDEA project files with Gradle we first need to apply the idea plugin. We can then further customise the created files. In this blog post we will add a Spring facet to the generated module file. By adding the Spring facet IntelliJ IDEA can automatically search for Spring configuration files. We can then use the Spring view to see which beans are configured in our project.

In the following example build file we use the withXml hook. This method is invoked just before the XML file is generated. We get an argument of type XmlProvider. From the XmlProvider we can access the XML as org.w3c.dom.Element, StringBuilder or groovy.util.Node. We use Node to alter the XML. We check if a FacetManager component is available. We need this to add a facet of type Spring.

Continue reading →

Gradle Goodness: Set VCS For IntelliJ IDEA In Build File

Posted on by  
Hubert Klein Ikkink

When we use the IDEA plugin in Gradle we can generate IntelliJ IDEA project files. We can customise the generated files in different ways. One of them is using a simple DSL to configure certain parts of the project file. With the DSL it is easy to set the version control system (VCS) used in our project.

In the next example build file we customise the generated IDEA project file and set Git as the version control system. The property is still incubating, but we can use it to have a proper configuration.

Continue reading →

Gradle Goodness: Configure IntelliJ IDEA To Use Gradle As Testrunner

Posted on by  
Hubert Klein Ikkink

When we run tests in IntelliJ IDEA the code is compiled by IntelliJ IDEA and the JUnit test runner is used. We get a nice graphical overview of the tasks that are executed and their results. If we use Gradle as the build tool for our project we can tell IntelliJ IDEA to always use Gradle for running tests.

We must open the Preferences or Settings dialog window. There we can search for Gradle and then look for Build, Execution, Deployment | Build Tools | Gradle | Runner:

Continue reading →

shadow-left